[Devel] [PATCH RHEL8 COMMIT] ploop: Refactor ploop_map_discard()

Konstantin Khorenko khorenko at virtuozzo.com
Mon May 17 19:04:59 MSK 2021


The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.30
------>
commit 8b28d846b9ab1ed471dc8640dbf9cdd57f800ab5
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Mon May 17 19:04:58 2021 +0300

    ploop: Refactor ploop_map_discard()
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    
    =====================
    Patchset description:
    
    dm-ploop: Kill loop
    
    Intermediate patches can't be base for bisect.
    
    In scope of https://jira.sw.ru/browse/PSBM-123654
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/md/dm-ploop-map.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 5a5ce5183d8b..b8a78d50f82e 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -195,8 +195,7 @@ static void queue_discard_index_wb(struct ploop *ploop, struct pio *pio)
 	queue_work(ploop->wq, &ploop->worker);
 }
 
-/* This 1)defers looking suitable discard bios and 2)ends the rest of them. */
-static int ploop_map_discard(struct ploop *ploop, struct pio *pio)
+static int endio_if_unsupported_discard(struct ploop *ploop, struct pio *pio)
 {
 	bool supported = false;
 	unsigned int cluster;
@@ -213,14 +212,12 @@ static int ploop_map_discard(struct ploop *ploop, struct pio *pio)
 		read_unlock_irqrestore(&ploop->bat_rwlock, flags);
 	}
 
-	if (supported) {
-		defer_pios(ploop, pio, NULL);
-	} else {
+	if (!supported) {
 		pio->bi_status = BLK_STS_NOTSUPP;
 		pio_endio(pio);
 	}
 
-	return DM_MAPIO_SUBMITTED;
+	return !supported;
 }
 
 /* Zero @count bytes of @qio->bi_io_vec since @from byte */
@@ -1663,8 +1660,9 @@ int ploop_map(struct dm_target *ti, struct bio *bio)
 	if (pio->bi_iter.bi_size) {
 		if (ploop_pio_cluster(ploop, pio, &cluster) < 0)
 			return DM_MAPIO_KILL;
-		if (op_is_discard(pio->bi_opf))
-			return ploop_map_discard(ploop, pio);
+		if (op_is_discard(pio->bi_opf) &&
+		    endio_if_unsupported_discard(ploop, pio))
+			return DM_MAPIO_SUBMITTED;
 
 		defer_pios(ploop, pio, NULL);
 		return DM_MAPIO_SUBMITTED;


More information about the Devel mailing list