[Devel] [RFC PATCH vz9 v6 52/62] dm-ploop: resize operation - add holes bitmap locking
Alexander Atanasov
alexander.atanasov at virtuozzo.com
Fri Dec 6 00:56:25 MSK 2024
lock bitmap in grow update header and disable delayed writeback
https://virtuozzo.atlassian.net/browse/VSTOR-91821
Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
---
drivers/md/dm-ploop-cmd.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 78cdcc81c75f..c919d796e108 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -294,19 +294,24 @@ static int ploop_grow_relocate_cluster(struct ploop *ploop,
dst_clu = cmd->resize.dst_clu;
+ spin_lock_irq(&ploop->bat_lock);
+
/* Relocate clu and update index */
clu = ploop_find_bat_entry(ploop, dst_clu, &is_locked);
if (clu == UINT_MAX || is_locked) {
/* dst_clu in top delta is not occupied? */
if (!test_bit(dst_clu, ploop->holes_bitmap) || is_locked) {
WARN_ON_ONCE(1);
+ spin_unlock_irq(&ploop->bat_lock);
ret = -EIO;
goto out;
}
/* Cluster is free, occupy it. Skip relocaton */
ploop_hole_clear_bit(dst_clu, ploop);
+ spin_unlock_irq(&ploop->bat_lock);
goto not_occupied;
}
+ spin_unlock_irq(&ploop->bat_lock);
/* Read full clu sync */
ret = ploop_read_cluster_sync(ploop, pio, dst_clu);
@@ -438,6 +443,7 @@ static int ploop_process_resize_cmd(struct ploop *ploop, struct ploop_cmd *cmd)
u32 dst_clu;
int ret = 0;
+ ploop_disable_writeback_delay(ploop);
/* Update memory arrays and hb_nr, but do not update nr_bat_entries. */
ploop_advance_holes_bitmap(ploop, cmd);
@@ -466,6 +472,8 @@ static int ploop_process_resize_cmd(struct ploop *ploop, struct ploop_cmd *cmd)
}
spin_unlock_irq(&ploop->bat_lock);
+ ploop_enable_writeback_delay(ploop);
+
return ret;
}
ALLOW_ERROR_INJECTION(ploop_process_resize_cmd, ERRNO);
--
2.43.0
More information about the Devel
mailing list