From: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
To: Konstantin Khorenko <khorenko@virtuozzo.com>
Cc: Den Lunev <den@virtuozzo.com>, devel@openvz.org
Subject: [Devel] [PATCH hci-8.2 2/3] dm/push_backup: free the bitmaps of an expired session on restart
Date: Wed, 25 Nov 2026 11:29:52 +0000 [thread overview]
Message-ID: <20261125-push-backup-fixes-v1-2-8d5cc55c30a1@virtuozzo.com> (raw)
In-Reply-To: <20261125-push-backup-fixes-v1-0-8d5cc55c30a1@virtuozzo.com>
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@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
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-11-25 11:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 11:29 [Devel] [PATCH hci-8.2 0/3] dm/push_backup: fix two old bugs and remove the unused messages Vasileios Almpanis
2026-11-25 11:29 ` [Devel] [PATCH hci-8.2 1/3] dm/push_backup: reject a cluster size of 0 Vasileios Almpanis
2026-11-25 11:29 ` Vasileios Almpanis [this message]
2026-11-25 11:47 ` [Devel] [PATCH hci-8.2 2/3] dm/push_backup: free the bitmaps of an expired session on restart Konstantin Khorenko
2026-11-25 11:29 ` [Devel] [PATCH hci-8.2 3/3] dm/push_backup: remove the push_backup_read and push_backup_write messages Vasileios Almpanis
2026-11-25 11:47 ` Konstantin Khorenko
2026-11-25 11:47 ` [Devel] [PATCH hci-8.2 0/3] dm/push_backup: fix two old bugs and remove the unused messages Konstantin Khorenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261125-push-backup-fixes-v1-2-8d5cc55c30a1@virtuozzo.com \
--to=vasileios.almpanis@virtuozzo.com \
--cc=den@virtuozzo.com \
--cc=devel@openvz.org \
--cc=khorenko@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox