[Devel] [PATCH hci-8.2 2/3] dm/push_backup: free the bitmaps of an expired session on restart
Vasileios Almpanis
vasileios.almpanis at virtuozzo.com
Wed Nov 25 14:29:52 MSK 2026
When a backup session expires, cleanup_backup() clears pb->alive but
keeps pb->map and pb->pending_map, so that the target status can still
report the session as expired. push_backup_start() refuses to start
only while pb->alive is set, so a start after an expiry goes on to
setup_pb(), which overwrites both pointers with new bitmaps. The old
bitmaps are lost until the target is destroyed, because only
push_backup_stop() and pb_destroy() free them, and they see only the
current pointers.
Each bitmap takes one bit per cluster. For example, on a 32 GiB device
with a cluster size of 1 sector each bitmap is 8 MiB, so every restart
loses 16 MiB. With fail_on_process_exit the session expires as soon as
the sender exits, so this is easy to hit in a loop:
for i in $(seq 1000); do
dmsetup message <pb_dev> 0 push_backup_start 60 0 fail_on_process_exit
done
Swap the new bitmaps in under pb->lock and free the old ones in
setup_pb(). Nothing dereferences the bitmaps of an expired session
without holding pb->lock, so they can be freed once the lock is
dropped. If setting up the new session fails, the expired session
keeps its bitmaps and its expired state.
https://virtuozzo.atlassian.net/browse/VSTOR-155790
Feature: dm-backup: push backup target driver
Fixes: 162123bc62c7 ("dm: Add push backup driver")
Signed-off-by: Vasileios Almpanis <vasileios.almpanis at virtuozzo.com>
---
drivers/md/dm-push-backup.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/md/dm-push-backup.c b/drivers/md/dm-push-backup.c
index 504713a9430e..433c61b63802 100644
--- a/drivers/md/dm-push-backup.c
+++ b/drivers/md/dm-push-backup.c
@@ -434,11 +434,13 @@ static int setup_pb(struct push_backup *pb, void __user *mask, int timeout)
map_bits = bitmap_weight(map, clus);
spin_lock_irq(&pb->lock);
- pb->map = map;
+ swap(pb->map, map);
pb->map_bits = map_bits;
- pb->pending_map = pending_map;
+ swap(pb->pending_map, pending_map);
pb->alive = true;
spin_unlock_irq(&pb->lock);
+ kvfree(map);
+ kvfree(pending_map);
return 0;
err:
kvfree(map);
--
2.43.0
More information about the Devel
mailing list