[Devel] [PATCH RH8 44/61] ploop: Refactor ploop_map_discard()
Kirill Tkhai
ktkhai at virtuozzo.com
Fri May 14 18:58:33 MSK 2021
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