[Devel] [PATCH RH8] ploop: Care about unaligned discards

Kirill Tkhai ktkhai at virtuozzo.com
Wed Jun 9 18:32:22 MSK 2021


Despite we have discard_granuality properly set,
we may receive shorter requests. This is possible,
in case of boundary requests, or just short bios,
which are submitted from fstrim. Fix that.

Note, we have this check before loop removal, and
whole_cluster even became unused after loop is killed.
Make it used again.

https://jira.sw.ru/browse/PSBM-130521
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/md/dm-ploop-map.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index e876aa8b835a..a89164ed3736 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -544,6 +544,18 @@ static void handle_discard_pio(struct ploop *ploop, struct pio *pio,
 	loff_t pos;
 	int ret;
 
+	if (!whole_cluster(ploop, pio)) {
+		/*
+		 * Despite discard_granularity is given, block level
+		 * may submit shorter reqs. E.g., these are boundary
+		 * bios around trimed continuous hunk. For discard
+		 * it's OK to just ignore such reqs. Keep in mind
+		 * this implementing REQ_OP_WRITE_ZEROES etc.
+		 */
+		pio_endio(pio);
+		return;
+	}
+
 	if (!cluster_is_in_top_delta(ploop, cluster)) {
 		pio_endio(pio);
 		return;




More information about the Devel mailing list