* [Devel] [PATCH hci-8.2 v2 0/3] dm/push_backup: stop the backup when the process that started it exits
@ 2026-11-18 13:57 Vasileios Almpanis
2026-11-18 13:57 ` [Devel] [PATCH hci-8.2 v2 1/3] dm/push_backup: return -EINVAL for malformed target messages Vasileios Almpanis
` (5 more replies)
0 siblings, 6 replies; 10+ messages in thread
From: Vasileios Almpanis @ 2026-11-18 13:57 UTC (permalink / raw)
To: Konstantin Khorenko; +Cc: Den Lunev, devel
When ploop-backup dies, the writes to the device and every sync() on
the host stay blocked until the push_backup deadline timer fires. The
last patch adds the fail_on_process_exit argument to
push_backup_start, so that the session expires as soon as the process
that started it exits. As discussed with Andrey, we hook to
pid->wait_pidfd instead of counting the open event fds as proposed in
the ticket, because the fd is bound to the target and not to a backup
session. ploop-backup needs a separate change to pass the new argument
when the target version is 1.2.0 or later.
The first patch is the fix for VSTOR-155761. Without it a malformed
push_backup_start returns success without starting anything, and the
last patch would add one more way to get there, a misspelled
fail_on_process_exit. The second patch makes push_backup_statistics
report expires_in as 0 for every expired session. Before it the value
was computed from the deadline, which is negative after a timer expiry
and positive or huge after a process exit.
I tested it on a VHI 8.1 node, both with the module built for the stock
6.12.0-211.75.1.24.1.vz10 kernel and with a debug kernel with KASAN and
lockdep. A small helper starts the backup, takes the event fd and forks
a child that keeps a copy of it. After a SIGKILL of the helper the
postponed write completed in less than 0.1 s instead of waiting for the
timeout, the child got ESTALE on the fd and expires_in was 0. Without
the argument the write still waited for the whole timeout. I also
checked that the exit of the main thread alone does not expire the
session, and that a clean stop followed by a new session, a restart of
an expired session and dmsetup remove while the process is watched all
work. Malformed start, read, write and get_fd messages now fail with
EINVAL. 200 rounds of start, kill and stop left dmesg clean.
A session whose backup has finished also expires if the process exits
before push_backup_stop, and the fd then returns ESTALE instead of 0.
This is intended: the backup tool died before it stopped the session,
so we treat it as a failed backup.
The target keeps its reference on the struct pid of the dead process
until push_backup_stop, the next push_backup_start or the target
destroy. This is the same as the rest of the expired session state,
such as the backup bitmap, and an open pidfd also keeps the struct pid
of a dead process. Dropping it earlier would need more synchronization
between the wake callback, the worker and the control path, and it
would only free one struct pid.
The other older bugs that sashiko found in the driver have separate
tickets:
VSTOR-155790 restarting an expired session leaks the backup bitmaps
VSTOR-155791 a cluster size of 0 divides by zero in the constructor
https://virtuozzo.atlassian.net/browse/VSTOR-153891
Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
---
Changes in v2:
- Add the fix for VSTOR-155761 as the first patch, so that an unknown
fourth argument of push_backup_start returns -EINVAL.
- Report expires_in as 0 for every expired session, also when writes
were postponed and the deadline is still in the future. This is now
a separate patch.
- Commit message: say that the message has to come from the backup
process, fix the reason for watching the process and not the fd, say
that 60 seconds is the ploop-backup default and split the paragraph
about the mechanism.
- Link to v1: http://lore.virtuozzo.com/20261118-vstor-153891-v1-1-f31daea66355@virtuozzo.com
---
Vasileios Almpanis (3):
dm/push_backup: return -EINVAL for malformed target messages
dm/push_backup: report expires_in as 0 for an expired session
dm/push_backup: stop the backup when the process that started it exits
drivers/md/dm-push-backup.c | 64 ++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 60 insertions(+), 4 deletions(-)
---
base-commit: 5c8ade0760b8aba04b51b69556b629f77e72261e
change-id: 20261118-vstor-153891-2b6ada96728a
--
Best regards, Vasileios Almpanis
Software Developer, Virtuozzo.
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Devel] [PATCH hci-8.2 v2 1/3] dm/push_backup: return -EINVAL for malformed target messages
2026-11-18 13:57 [Devel] [PATCH hci-8.2 v2 0/3] dm/push_backup: stop the backup when the process that started it exits Vasileios Almpanis
@ 2026-11-18 13:57 ` Vasileios Almpanis
2026-11-18 14:00 ` no-reply
2026-11-18 13:57 ` [Devel] [PATCH hci-8.2 v2 2/3] dm/push_backup: report expires_in as 0 for an expired session Vasileios Almpanis
` (4 subsequent siblings)
5 siblings, 1 reply; 10+ messages in thread
From: Vasileios Almpanis @ 2026-11-18 13:57 UTC (permalink / raw)
To: Konstantin Khorenko; +Cc: Den Lunev, devel
pb_message() sets ret to -EINVAL before it checks the arguments, but
then it overwrites ret with the result of taking ctl_rwsem, which is 0
on success. Because of that every argument check after the lock jumps
to unlock with ret == 0. The message is rejected and nothing is done,
but the caller sees success:
# dmsetup message pbt 0 push_backup_start abc
# echo $?
0
# dmsetup status pbt
0 2097152 push_backup 7:0 128 0 inactive
This affects push_backup_start with a wrong number of arguments or an
unparsable timeout or mask, push_backup_read and push_backup_get_fd
with extra arguments, and push_backup_write with a malformed range.
push_backup_stop is not affected, because it checks its arguments
before the lock is taken.
Fix this by setting ret back to -EINVAL after the lock is taken.
https://virtuozzo.atlassian.net/browse/VSTOR-155761
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 | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/md/dm-push-backup.c b/drivers/md/dm-push-backup.c
index 4f6dc1f3c130..4406f0dc8f68 100644
--- a/drivers/md/dm-push-backup.c
+++ b/drivers/md/dm-push-backup.c
@@ -723,6 +723,7 @@ static int pb_message(struct dm_target *ti, unsigned int argc, char **argv,
if (unlikely(ret))
goto out;
+ ret = -EINVAL;
if (!strcmp(argv[0], "push_backup_start")) {
if (argc < 2 || argc > 3)
goto unlock;
--
2.43.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Devel] [PATCH hci-8.2 v2 2/3] dm/push_backup: report expires_in as 0 for an expired session
2026-11-18 13:57 [Devel] [PATCH hci-8.2 v2 0/3] dm/push_backup: stop the backup when the process that started it exits Vasileios Almpanis
2026-11-18 13:57 ` [Devel] [PATCH hci-8.2 v2 1/3] dm/push_backup: return -EINVAL for malformed target messages Vasileios Almpanis
@ 2026-11-18 13:57 ` Vasileios Almpanis
2026-11-18 14:00 ` no-reply
2026-11-18 13:57 ` [Devel] [PATCH hci-8.2 v2 3/3] dm/push_backup: stop the backup when the process that started it exits Vasileios Almpanis
` (3 subsequent siblings)
5 siblings, 1 reply; 10+ messages in thread
From: Vasileios Almpanis @ 2026-11-18 13:57 UTC (permalink / raw)
To: Konstantin Khorenko; +Cc: Den Lunev, devel
When the deadline timer expires a backup session, push_backup_statistics
keeps computing expires_in from the deadline that has already passed. So
an expired session reports a negative expires_in that keeps decreasing,
for example -30 half a minute after the expiry.
The time until the deadline means nothing once the session has expired.
Report expires_in as 0 for an expired session instead.
https://virtuozzo.atlassian.net/browse/VSTOR-153891
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 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/md/dm-push-backup.c b/drivers/md/dm-push-backup.c
index 4406f0dc8f68..4c6fb97bbb5e 100644
--- a/drivers/md/dm-push-backup.c
+++ b/drivers/md/dm-push-backup.c
@@ -678,7 +678,7 @@ static int push_backup_statistics(struct push_backup *pb, char *result,
if (pb->deadline_jiffies != S64_MAX)
expires = pb->deadline_jiffies - jiffies_64;
} else if (pb->map) {
- expires = pb->deadline_jiffies - jiffies_64;
+ expires = 0;
}
DMEMIT("nr_remaining_clus=%llu\n", pb->map_bits);
DMEMIT("nr_delayed_bios=%d\n", pb->nr_delayed);
--
2.43.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Devel] [PATCH hci-8.2 v2 3/3] dm/push_backup: stop the backup when the process that started it exits
2026-11-18 13:57 [Devel] [PATCH hci-8.2 v2 0/3] dm/push_backup: stop the backup when the process that started it exits Vasileios Almpanis
2026-11-18 13:57 ` [Devel] [PATCH hci-8.2 v2 1/3] dm/push_backup: return -EINVAL for malformed target messages Vasileios Almpanis
2026-11-18 13:57 ` [Devel] [PATCH hci-8.2 v2 2/3] dm/push_backup: report expires_in as 0 for an expired session Vasileios Almpanis
@ 2026-11-18 13:57 ` Vasileios Almpanis
2026-11-18 14:04 ` no-reply
2026-11-18 14:05 ` [Devel] [PATCH hci-8.2 v2 0/3] " Andrey Zhadchenko
` (2 subsequent siblings)
5 siblings, 1 reply; 10+ messages in thread
From: Vasileios Almpanis @ 2026-11-18 13:57 UTC (permalink / raw)
To: Konstantin Khorenko; +Cc: Den Lunev, devel
When ploop-backup dies, the push_backup target does not notice it. The
writes that wait for a backup stay postponed until the deadline timer
fires. The timeout is a required argument of push_backup_start, and
ploop-backup passes 60 seconds by default. During that time every
writer to the device blocks, and so does every sync() on the host,
because writeback waits for the postponed requests. We cannot simply
lower the timeout, because a live ploop-backup can legitimately stall
on IO for tens of seconds.
Add an optional argument to push_backup_start:
push_backup_start <timeout> <mask|0> fail_on_process_exit
With this argument the target watches the process that sent the
message. To do that we add our own entry to the pid->wait_pidfd wait
queue of its thread group. The kernel wakes up this queue when the
process exits and when it is reaped. When the whole process is gone,
the entry removes itself from the queue and queues the same work as the
deadline timer. The exit of the main thread alone does not count while
other threads of the process are still running.
So when the backup process dies, the session expires in the same way
as on the deadline. The postponed writes are resubmitted immediately,
the target reports the session as expired and reads on the event fd
return ESTALE.
Because the target watches the sender, the message has to come from
the backup process itself. If it is sent with "dmsetup message", the
session expires as soon as dmsetup exits.
We watch the process and not the event fd, because the fd is bound to
the target and not to a backup session, see commit d723a1617e61
("dm/push_backup: add event file descriptor interface"). Also a session
that is driven by push_backup_read and push_backup_write has no fd at
all.
The watch is dropped on push_backup_stop, on the next
push_backup_start and when the target is destroyed. Bump the target
version to 1.2.0 so that userspace can check that the argument is
supported.
https://virtuozzo.atlassian.net/browse/VSTOR-153891
Feature: dm-backup: push backup target driver
Suggested-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
---
drivers/md/dm-push-backup.c | 61 ++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 58 insertions(+), 3 deletions(-)
diff --git a/drivers/md/dm-push-backup.c b/drivers/md/dm-push-backup.c
index 4c6fb97bbb5e..745ed28fd074 100644
--- a/drivers/md/dm-push-backup.c
+++ b/drivers/md/dm-push-backup.c
@@ -19,6 +19,8 @@
#include <linux/file.h>
#include <linux/kref.h>
#include <linux/uaccess.h>
+#include <linux/pid.h>
+#include <linux/sched/signal.h>
#include <linux/dm-push-backup.h>
@@ -75,6 +77,9 @@ struct push_backup {
struct work_struct worker;
struct rw_semaphore ctl_rwsem;
+
+ struct pid *watched_pid;
+ struct wait_queue_entry pid_wait;
};
static void pb_release(struct kref *ref)
@@ -271,6 +276,48 @@ static void pb_timer_func(struct timer_list *timer)
spin_unlock_irqrestore(&pb->lock, flags);
}
+static bool pb_process_exited(struct pid *pid)
+{
+ struct task_struct *task;
+
+ guard(rcu)();
+ task = pid_task(pid, PIDTYPE_TGID);
+ return !task || (task->exit_state && thread_group_empty(task));
+}
+
+/*
+ * Called under tasklist_lock with irqs disabled when the watched process
+ * exits or is reaped. If the whole process is gone, stop watching it and
+ * expire the backup in the same way as the deadline timer does.
+ */
+static int pb_pid_wake(struct wait_queue_entry *wait, unsigned int mode,
+ int flags, void *key)
+{
+ struct push_backup *pb = container_of(wait, struct push_backup, pid_wait);
+
+ if (pb_process_exited(pb->watched_pid)) {
+ list_del_init(&wait->entry);
+ queue_work(pb->wq, &pb->worker);
+ }
+ return 0;
+}
+
+static void pb_watch_pid(struct push_backup *pb)
+{
+ pb->watched_pid = get_task_pid(current, PIDTYPE_TGID);
+ add_wait_queue(&pb->watched_pid->wait_pidfd, &pb->pid_wait);
+}
+
+static void pb_unwatch_pid(struct push_backup *pb)
+{
+ if (!pb->watched_pid)
+ return;
+ remove_wait_queue(&pb->watched_pid->wait_pidfd, &pb->pid_wait);
+ put_pid(pb->watched_pid);
+ pb->watched_pid = NULL;
+ flush_work(&pb->worker);
+}
+
static int postpone_if_required_for_backup(struct push_backup *pb,
struct request *rq)
{
@@ -406,6 +453,7 @@ static int push_backup_start(struct push_backup *pb, u64 timeout,
return -EEXIST;
if (timeout == 0 || timeout >= 60UL * 60 * 5)
return -EINVAL;
+ pb_unwatch_pid(pb);
return setup_pb(pb, mask, timeout);
}
@@ -417,6 +465,7 @@ static int push_backup_stop(struct push_backup *pb,
if (!pb->map)
return -EBADF;
cleanup_backup(pb);
+ pb_unwatch_pid(pb);
timer_delete_sync(&pb->deadline_timer);
flush_workqueue(pb->wq);
@@ -725,14 +774,18 @@ static int pb_message(struct dm_target *ti, unsigned int argc, char **argv,
ret = -EINVAL;
if (!strcmp(argv[0], "push_backup_start")) {
- if (argc < 2 || argc > 3)
+ if (argc < 2 || argc > 4)
goto unlock;
if (kstrtou64(argv[1], 10, &val) < 0)
goto unlock;
val2 = 0;
- if (argc == 3 && kstrtou64(argv[2], 10, &val2) < 0)
+ if (argc >= 3 && kstrtou64(argv[2], 10, &val2) < 0)
+ goto unlock;
+ if (argc == 4 && strcmp(argv[3], "fail_on_process_exit"))
goto unlock;
ret = push_backup_start(pb, val, (void *)val2);
+ if (!ret && argc == 4)
+ pb_watch_pid(pb);
} else if (!strcmp(argv[0], "push_backup_stop")) {
ret = push_backup_stop(pb, result, maxlen);
} else if (!strcmp(argv[0], "push_backup_read")) {
@@ -777,6 +830,7 @@ static void pb_destroy(struct push_backup *pb)
wake_up_interruptible(&pb->waitq);
+ pb_unwatch_pid(pb);
timer_shutdown_sync(&pb->deadline_timer);
if (pb->wq)
destroy_workqueue(pb->wq);
@@ -818,6 +872,7 @@ static int pb_ctr(struct dm_target *ti, unsigned int argc, char **argv)
timer_setup(&pb->deadline_timer, pb_timer_func, 0);
init_waitqueue_head(&pb->waitq);
INIT_WORK(&pb->worker, do_pb_work);
+ init_waitqueue_func_entry(&pb->pid_wait, pb_pid_wake);
pb->pbio_pool = mempool_create_slab_pool(PUSH_BACKUP_POOL_SIZE,
pbio_cache);
@@ -920,7 +975,7 @@ static loff_t pb_llseek_hole(struct dm_target *ti, loff_t offset,
static struct target_type pb_target = {
.name = "push_backup",
- .version = {1, 1, 0},
+ .version = {1, 2, 0},
.features = DM_TARGET_SINGLETON,
.module = THIS_MODULE,
.ctr = pb_ctr,
--
2.43.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Devel] [PATCH hci-8.2 v2 1/3] dm/push_backup: return -EINVAL for malformed target messages
2026-11-18 13:57 ` [Devel] [PATCH hci-8.2 v2 1/3] dm/push_backup: return -EINVAL for malformed target messages Vasileios Almpanis
@ 2026-11-18 14:00 ` no-reply
0 siblings, 0 replies; 10+ messages in thread
From: no-reply @ 2026-11-18 14:00 UTC (permalink / raw)
To: Vasileios Almpanis, Konstantin Khorenko; +Cc: Den Lunev, devel
> pb_message() sets ret to -EINVAL before it checks the arguments, but
> then it overwrites ret with the result of taking ctl_rwsem, which is 0
> on success. Because of that every argument check after the lock jumps
> to unlock with ret == 0. The message is rejected and nothing is done,
> but the caller sees success:
>
> # dmsetup message pbt 0 push_backup_start abc
> # echo $?
> 0
> # dmsetup status pbt
> 0 2097152 push_backup 7:0 128 0 inactive
>
> This affects push_backup_start with a wrong number of arguments or an
> unparsable timeout or mask, push_backup_read and push_backup_get_fd
> with extra arguments, and push_backup_write with a malformed range.
> push_backup_stop is not affected, because it checks its arguments
> before the lock is taken.
>
> Fix this by setting ret back to -EINVAL after the lock is taken.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-155761
>
> Feature: dm-backup: push backup target driver
> Fixes: 162123bc62c7 ("dm: Add push backup driver")
> Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261118-vstor-153891-v2-0-e91753150b91@virtuozzo.com?part=1
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Devel] [PATCH hci-8.2 v2 2/3] dm/push_backup: report expires_in as 0 for an expired session
2026-11-18 13:57 ` [Devel] [PATCH hci-8.2 v2 2/3] dm/push_backup: report expires_in as 0 for an expired session Vasileios Almpanis
@ 2026-11-18 14:00 ` no-reply
0 siblings, 0 replies; 10+ messages in thread
From: no-reply @ 2026-11-18 14:00 UTC (permalink / raw)
To: Vasileios Almpanis, Konstantin Khorenko; +Cc: Den Lunev, devel
> When the deadline timer expires a backup session, push_backup_statistics
> keeps computing expires_in from the deadline that has already passed. So
> an expired session reports a negative expires_in that keeps decreasing,
> for example -30 half a minute after the expiry.
>
> The time until the deadline means nothing once the session has expired.
> Report expires_in as 0 for an expired session instead.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-153891
>
> Feature: dm-backup: push backup target driver
> Fixes: 162123bc62c7 ("dm: Add push backup driver")
> Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261118-vstor-153891-v2-0-e91753150b91@virtuozzo.com?part=2
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Devel] [PATCH hci-8.2 v2 3/3] dm/push_backup: stop the backup when the process that started it exits
2026-11-18 13:57 ` [Devel] [PATCH hci-8.2 v2 3/3] dm/push_backup: stop the backup when the process that started it exits Vasileios Almpanis
@ 2026-11-18 14:04 ` no-reply
0 siblings, 0 replies; 10+ messages in thread
From: no-reply @ 2026-11-18 14:04 UTC (permalink / raw)
To: Vasileios Almpanis, Konstantin Khorenko; +Cc: Den Lunev, devel
> When ploop-backup dies, the push_backup target does not notice it. The
> writes that wait for a backup stay postponed until the deadline timer
> fires. The timeout is a required argument of push_backup_start, and
> ploop-backup passes 60 seconds by default. During that time every
> writer to the device blocks, and so does every sync() on the host,
> because writeback waits for the postponed requests. We cannot simply
> lower the timeout, because a live ploop-backup can legitimately stall
> on IO for tens of seconds.
>
> Add an optional argument to push_backup_start:
>
> push_backup_start <timeout> <mask|0> fail_on_process_exit
>
> With this argument the target watches the process that sent the
> message. To do that we add our own entry to the pid->wait_pidfd wait
> [ ... ]
>
> Feature: dm-backup: push backup target driver
> Suggested-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
> Reviewed-by: Denis V. Lunev <den@openvz.org>
> Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261118-vstor-153891-v2-0-e91753150b91@virtuozzo.com?part=3
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Devel] [PATCH hci-8.2 v2 0/3] dm/push_backup: stop the backup when the process that started it exits
2026-11-18 13:57 [Devel] [PATCH hci-8.2 v2 0/3] dm/push_backup: stop the backup when the process that started it exits Vasileios Almpanis
` (2 preceding siblings ...)
2026-11-18 13:57 ` [Devel] [PATCH hci-8.2 v2 3/3] dm/push_backup: stop the backup when the process that started it exits Vasileios Almpanis
@ 2026-11-18 14:05 ` Andrey Zhadchenko
2026-11-18 15:20 ` Konstantin Khorenko
2026-11-18 15:20 ` Konstantin Khorenko
5 siblings, 0 replies; 10+ messages in thread
From: Andrey Zhadchenko @ 2026-11-18 14:05 UTC (permalink / raw)
To: Vasileios Almpanis, Konstantin Khorenko; +Cc: devel
Reviewed-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
On 11/18/26 14:57, Vasileios Almpanis wrote:
> When ploop-backup dies, the writes to the device and every sync() on
> the host stay blocked until the push_backup deadline timer fires. The
> last patch adds the fail_on_process_exit argument to
> push_backup_start, so that the session expires as soon as the process
> that started it exits. As discussed with Andrey, we hook to
> pid->wait_pidfd instead of counting the open event fds as proposed in
> the ticket, because the fd is bound to the target and not to a backup
> session. ploop-backup needs a separate change to pass the new argument
> when the target version is 1.2.0 or later.
>
> The first patch is the fix for VSTOR-155761. Without it a malformed
> push_backup_start returns success without starting anything, and the
> last patch would add one more way to get there, a misspelled
> fail_on_process_exit. The second patch makes push_backup_statistics
> report expires_in as 0 for every expired session. Before it the value
> was computed from the deadline, which is negative after a timer expiry
> and positive or huge after a process exit.
>
> I tested it on a VHI 8.1 node, both with the module built for the stock
> 6.12.0-211.75.1.24.1.vz10 kernel and with a debug kernel with KASAN and
> lockdep. A small helper starts the backup, takes the event fd and forks
> a child that keeps a copy of it. After a SIGKILL of the helper the
> postponed write completed in less than 0.1 s instead of waiting for the
> timeout, the child got ESTALE on the fd and expires_in was 0. Without
> the argument the write still waited for the whole timeout. I also
> checked that the exit of the main thread alone does not expire the
> session, and that a clean stop followed by a new session, a restart of
> an expired session and dmsetup remove while the process is watched all
> work. Malformed start, read, write and get_fd messages now fail with
> EINVAL. 200 rounds of start, kill and stop left dmesg clean.
>
> A session whose backup has finished also expires if the process exits
> before push_backup_stop, and the fd then returns ESTALE instead of 0.
> This is intended: the backup tool died before it stopped the session,
> so we treat it as a failed backup.
>
> The target keeps its reference on the struct pid of the dead process
> until push_backup_stop, the next push_backup_start or the target
> destroy. This is the same as the rest of the expired session state,
> such as the backup bitmap, and an open pidfd also keeps the struct pid
> of a dead process. Dropping it earlier would need more synchronization
> between the wake callback, the worker and the control path, and it
> would only free one struct pid.
>
> The other older bugs that sashiko found in the driver have separate
> tickets:
>
> VSTOR-155790 restarting an expired session leaks the backup bitmaps
> VSTOR-155791 a cluster size of 0 divides by zero in the constructor
>
> https://virtuozzo.atlassian.net/browse/VSTOR-153891
>
> Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
> ---
> Changes in v2:
> - Add the fix for VSTOR-155761 as the first patch, so that an unknown
> fourth argument of push_backup_start returns -EINVAL.
> - Report expires_in as 0 for every expired session, also when writes
> were postponed and the deadline is still in the future. This is now
> a separate patch.
> - Commit message: say that the message has to come from the backup
> process, fix the reason for watching the process and not the fd, say
> that 60 seconds is the ploop-backup default and split the paragraph
> about the mechanism.
> - Link to v1: http://lore.virtuozzo.com/20261118-vstor-153891-v1-1-f31daea66355@virtuozzo.com
>
> ---
> Vasileios Almpanis (3):
> dm/push_backup: return -EINVAL for malformed target messages
> dm/push_backup: report expires_in as 0 for an expired session
> dm/push_backup: stop the backup when the process that started it exits
>
> drivers/md/dm-push-backup.c | 64 ++++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 60 insertions(+), 4 deletions(-)
> ---
> base-commit: 5c8ade0760b8aba04b51b69556b629f77e72261e
> change-id: 20261118-vstor-153891-2b6ada96728a
>
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Devel] [PATCH hci-8.2 v2 0/3] dm/push_backup: stop the backup when the process that started it exits
2026-11-18 13:57 [Devel] [PATCH hci-8.2 v2 0/3] dm/push_backup: stop the backup when the process that started it exits Vasileios Almpanis
` (3 preceding siblings ...)
2026-11-18 14:05 ` [Devel] [PATCH hci-8.2 v2 0/3] " Andrey Zhadchenko
@ 2026-11-18 15:20 ` Konstantin Khorenko
2026-11-18 15:20 ` Konstantin Khorenko
5 siblings, 0 replies; 10+ messages in thread
From: Konstantin Khorenko @ 2026-11-18 15:20 UTC (permalink / raw)
To: Vasileios Almpanis; +Cc: devel, Den Lunev
Applying as is.
On Wed, 18 Nov 2026 13:57:26 +0000, Vasileios Almpanis wrote:
> A session whose backup has finished also expires if the process exits
> before push_backup_stop, and the fd then returns ESTALE instead of 0.
> This is intended: the backup tool died before it stopped the session,
> so we treat it as a failed backup.
Fine with me. All four v1 items are done: 1/3 makes every malformed
message fail with -EINVAL (every branch of pb_message() sets ret),
2/3 reports expires_in as 0 for an expired session, and the 3/3
message now says who has to send the message and why the process is
watched.
Thanks.
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Devel] [PATCH hci-8.2 v2 0/3] dm/push_backup: stop the backup when the process that started it exits
2026-11-18 13:57 [Devel] [PATCH hci-8.2 v2 0/3] dm/push_backup: stop the backup when the process that started it exits Vasileios Almpanis
` (4 preceding siblings ...)
2026-11-18 15:20 ` Konstantin Khorenko
@ 2026-11-18 15:20 ` Konstantin Khorenko
5 siblings, 0 replies; 10+ messages in thread
From: Konstantin Khorenko @ 2026-11-18 15:20 UTC (permalink / raw)
To: Vasileios Almpanis; +Cc: Den Lunev, devel
On Wed, 18 Nov 2026 13:57:26 +0000, Vasileios Almpanis wrote:
> dm/push_backup: stop the backup when the process that started it exits
>
> When ploop-backup dies, the writes to the device and every sync() on
> the host stay blocked until the push_backup deadline timer fires. The
> last patch adds the fail_on_process_exit argument to
> push_backup_start, so that the session expires as soon as the process
> that started it exits. As discussed with Andrey, we hook to
> pid->wait_pidfd instead of counting the open event fds as proposed in
> the ticket, because the fd is bound to the target and not to a backup
> session. ploop-backup needs a separate change to pass the new argument
> when the target version is 1.2.0 or later.
>
> [...]
Applied to branch-rh10-6.12.0-211.75.1.26.x.vz10-ovz, will be released in rh10-6.12.0-211.75.1.26.3.vz10, thanks!
[1/3] dm/push_backup: return -EINVAL for malformed target messages
https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/c0b8c84e0375
[2/3] dm/push_backup: report expires_in as 0 for an expired session
https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/f4fd0825035a
[3/3] dm/push_backup: stop the backup when the process that started it exits
https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/a7157e0fbf94
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-11-18 15:21 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 13:57 [Devel] [PATCH hci-8.2 v2 0/3] dm/push_backup: stop the backup when the process that started it exits Vasileios Almpanis
2026-11-18 13:57 ` [Devel] [PATCH hci-8.2 v2 1/3] dm/push_backup: return -EINVAL for malformed target messages Vasileios Almpanis
2026-11-18 14:00 ` no-reply
2026-11-18 13:57 ` [Devel] [PATCH hci-8.2 v2 2/3] dm/push_backup: report expires_in as 0 for an expired session Vasileios Almpanis
2026-11-18 14:00 ` no-reply
2026-11-18 13:57 ` [Devel] [PATCH hci-8.2 v2 3/3] dm/push_backup: stop the backup when the process that started it exits Vasileios Almpanis
2026-11-18 14:04 ` no-reply
2026-11-18 14:05 ` [Devel] [PATCH hci-8.2 v2 0/3] " Andrey Zhadchenko
2026-11-18 15:20 ` Konstantin Khorenko
2026-11-18 15:20 ` Konstantin Khorenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox