OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
* [Devel] [PATCH hci-8.2] dm/push_backup: stop the backup when the process that started it exits
@ 2026-11-18 12:21 Vasileios Almpanis
  2026-11-18 12:27 ` no-reply
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Vasileios Almpanis @ 2026-11-18 12:21 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, which is 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, so
the session expires in the same way. The postponed writes are
resubmitted immediately, the target reports the session as expired and
reads on the event fd return ESTALE. The exit of the main thread alone
does not expire the session while other threads of the process are still
running.

We watch the process and not the event fd, because the fd can end up
in another process, for example in a child of ploop-backup. That
process would then keep the session alive after ploop-backup dies.

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.

If no write was postponed when the session expired, there is no
deadline. push_backup_statistics now reports expires_in as 0 in that
case, instead of a value computed from the unset deadline.

https://virtuozzo.atlassian.net/browse/VSTOR-153891

Feature: dm-backup: push backup target driver
Suggested-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
---
When ploop-backup dies, the writes to the device and every sync() on
the host stay blocked until the push_backup deadline timer fires. This
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 a child of
ploop-backup can keep a copy of the fd. ploop-backup needs a separate
change to pass the new argument when the target version is 1.2.0 or
later.

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, and the child got ESTALE on the fd. 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. 200 rounds of
start, kill and stop left dmesg clean.

A sashiko review of an earlier draft found two problems in the patch,
which are fixed here. The statistics reported a huge expires_in when the
session expired with nothing postponed, and the wait queue entry stayed
on the queue after the expiry, so the reap of the process queued the
expiry work a second time. It also found older bugs in the same driver.
To keep this patch small I opened separate tickets for them:

  VSTOR-155761  malformed messages are rejected but return success
  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
---
 drivers/md/dm-push-backup.c | 65 ++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 61 insertions(+), 4 deletions(-)

diff --git a/drivers/md/dm-push-backup.c b/drivers/md/dm-push-backup.c
index 4f6dc1f3c130..fee2584d7cec 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);
@@ -678,7 +727,9 @@ 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;
+		if (pb->deadline_jiffies != S64_MAX)
+			expires = pb->deadline_jiffies - jiffies_64;
 	}
 	DMEMIT("nr_remaining_clus=%llu\n", pb->map_bits);
 	DMEMIT("nr_delayed_bios=%d\n", pb->nr_delayed);
@@ -724,14 +775,18 @@ static int pb_message(struct dm_target *ti, unsigned int argc, char **argv,
 		goto out;
 
 	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")) {
@@ -776,6 +831,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);
@@ -817,6 +873,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);
@@ -919,7 +976,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,

---
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] 4+ messages in thread

* Re: [Devel] [PATCH hci-8.2] dm/push_backup: stop the backup when the process that started it exits
  2026-11-18 12:21 [Devel] [PATCH hci-8.2] dm/push_backup: stop the backup when the process that started it exits Vasileios Almpanis
@ 2026-11-18 12:27 ` no-reply
  2026-11-18 12:30 ` Denis V. Lunev
  2026-11-18 12:47 ` Konstantin Khorenko
  2 siblings, 0 replies; 4+ messages in thread
From: no-reply @ 2026-11-18 12:27 UTC (permalink / raw)
  To: Vasileios Almpanis, Konstantin Khorenko; +Cc: Den Lunev, devel

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] dm-push-backup: bad fail_on_process_exit argument returns
  success
--

commit 3578882a0ee4244aebcea5a102bc0fcc5dc0eae8
Author: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>

dm/push_backup: stop the backup when the process that started it exits

This adds an optional fail_on_process_exit argument to push_backup_start. With it, the target adds a wait queue entry to the sender's pid->wait_pidfd. When the whole process exits, the session expires the same way as when the deadline timer fires.

> diff --git a/drivers/md/dm-push-backup.c b/drivers/md/dm-push-backup.c
> --- a/drivers/md/dm-push-backup.c
> +++ b/drivers/md/dm-push-backup.c

[ ... ]

> @@ -724,14 +775,18 @@ static int pb_message(struct dm_target *ti, unsigned int argc, char **argv,
>  		goto out;
>  
>  	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;

[Severity: Low]
Does this new check return success for a misspelled fourth argument? By this point ret holds 0 from the successful down_write_killable(), so the goto unlock returns 0 to userspace. No session is started and no process watch is installed, yet the caller sees success. It would then assume fail-on-exit protection is active, and writes could still stall until the deadline timer fires. Should ret be set to -EINVAL before this goto?

The older argument checks in this block have the same problem, which the cover text says is tracked separately. This check is a new instance of it.

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261118-vstor-153891-v1-1-f31daea66355@virtuozzo.com?part=1

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Devel] [PATCH hci-8.2] dm/push_backup: stop the backup when the process that started it exits
  2026-11-18 12:21 [Devel] [PATCH hci-8.2] dm/push_backup: stop the backup when the process that started it exits Vasileios Almpanis
  2026-11-18 12:27 ` no-reply
@ 2026-11-18 12:30 ` Denis V. Lunev
  2026-11-18 12:47 ` Konstantin Khorenko
  2 siblings, 0 replies; 4+ messages in thread
From: Denis V. Lunev @ 2026-11-18 12:30 UTC (permalink / raw)
  To: Vasileios Almpanis, Konstantin Khorenko; +Cc: devel

On 11/18/26 13:21, Vasileios Almpanis wrote:
> 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, which is 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, so
> the session expires in the same way. The postponed writes are
> resubmitted immediately, the target reports the session as expired and
> reads on the event fd return ESTALE. The exit of the main thread alone
> does not expire the session while other threads of the process are still
> running.
>
> We watch the process and not the event fd, because the fd can end up
> in another process, for example in a child of ploop-backup. That
> process would then keep the session alive after ploop-backup dies.
>
> 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.
>
> If no write was postponed when the session expired, there is no
> deadline. push_backup_statistics now reports expires_in as 0 in that
> case, instead of a value computed from the unset deadline.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-153891
>
> Feature: dm-backup: push backup target driver
> Suggested-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
> Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
> ---
> When ploop-backup dies, the writes to the device and every sync() on
> the host stay blocked until the push_backup deadline timer fires. This
> 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 a child of
> ploop-backup can keep a copy of the fd. ploop-backup needs a separate
> change to pass the new argument when the target version is 1.2.0 or
> later.
>
> 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, and the child got ESTALE on the fd. 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. 200 rounds of
> start, kill and stop left dmesg clean.
>
> A sashiko review of an earlier draft found two problems in the patch,
> which are fixed here. The statistics reported a huge expires_in when the
> session expired with nothing postponed, and the wait queue entry stayed
> on the queue after the expiry, so the reap of the process queued the
> expiry work a second time. It also found older bugs in the same driver.
> To keep this patch small I opened separate tickets for them:
>
>   VSTOR-155761  malformed messages are rejected but return success
>   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
> ---
>  drivers/md/dm-push-backup.c | 65 ++++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 61 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/md/dm-push-backup.c b/drivers/md/dm-push-backup.c
> index 4f6dc1f3c130..fee2584d7cec 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);
> @@ -678,7 +727,9 @@ 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;
> +		if (pb->deadline_jiffies != S64_MAX)
> +			expires = pb->deadline_jiffies - jiffies_64;
>  	}
>  	DMEMIT("nr_remaining_clus=%llu\n", pb->map_bits);
>  	DMEMIT("nr_delayed_bios=%d\n", pb->nr_delayed);
> @@ -724,14 +775,18 @@ static int pb_message(struct dm_target *ti, unsigned int argc, char **argv,
>  		goto out;
>  
>  	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")) {
> @@ -776,6 +831,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);
> @@ -817,6 +873,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);
> @@ -919,7 +976,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,
>
> ---
> base-commit: 5c8ade0760b8aba04b51b69556b629f77e72261e
> change-id: 20261118-vstor-153891-2b6ada96728a
>
  1. Misspelled fail_on_process_exit returns success without starting:
medium on
     paper, low in practice.
     - The worst case is bad: userspace believes a backup session is running
       while writes go through unprotected, so the backup is silently
       inconsistent.
     - Reaching it needs a caller that sends a wrong token. The only
caller is
       ploop-backup, which will hardcode the string, so it would be
caught the
       first time it's tested.
     - It's not new. Every malformed push_backup_start already behaves
this way
       (VSTOR-155761); the patch only adds one more path into it.
     - Fixing VSTOR-155761 properly closes this too. I'd want that fix
in before
       or together with this patch, but I wouldn't block the patch on this
       alone.
     - The same bug on old kernels is the real operational risk. If the
       ploop-backup version check is missing or wrong, the flag on an
old kernel
       gives a silently dead backup. That deserves the same scrutiny in the
       ploop-backup review.
  2. expires_in positive for an expired session: low, cosmetic. 
     - No consumer reads it: not ploop-backup, libploop or vzctl.
     - The status line already says "expired", and that is what vzctl
checks.
     - It's a one-line fix if he respins anyway.
  3. Commit message rationale about the fd in a child: trivial.
     - Only the stated reason is wrong; the decision itself is right.
     - Worth a one-line rewording if he respins anyway; not worth a
round trip
       on its own.

in general

Reviewed-by: Denis V. Lunev <den@openvz.org>
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Devel] [PATCH hci-8.2] dm/push_backup: stop the backup when the process that started it exits
  2026-11-18 12:21 [Devel] [PATCH hci-8.2] dm/push_backup: stop the backup when the process that started it exits Vasileios Almpanis
  2026-11-18 12:27 ` no-reply
  2026-11-18 12:30 ` Denis V. Lunev
@ 2026-11-18 12:47 ` Konstantin Khorenko
  2 siblings, 0 replies; 4+ messages in thread
From: Konstantin Khorenko @ 2026-11-18 12:47 UTC (permalink / raw)
  To: Vasileios Almpanis; +Cc: devel, Den Lunev

I won't apply this version, please send v2 with the changes below.

1. Return -EINVAL for a fourth argument other than
   fail_on_process_exit: now ret is still 0 from
   down_write_killable(), nothing starts and the caller sees success.
   VSTOR-155761 covers the same for the rest of push_backup_start; fix
   it there first or set ret = -EINVAL before the argument checks
   here.
2. push_backup_statistics: report expires_in as 0 for every expired
   session. After the process exits with writes postponed,
   cleanup_backup() leaves deadline_jiffies in the future, so the
   statistics show a positive expires_in next to "expired".
3. Message: say that the message has to come from the backup process
   itself; sent through "dmsetup message" the session expires as soon
   as dmsetup exits.
4. Message: the reason for watching the process, see below; and the 60
   seconds are ploop-backup's default, the kernel has none, the timeout
   is a required argument. Split the "With this argument" paragraph,
   it has seven sentences: the mechanism, then what the user sees.

A question, no change needed if it is intended: a session whose backup
has finished (nr_remaining_clus=0) also expires when the process exits
before push_backup_stop, and the fd then returns ESTALE instead of 0.

On Wed, 18 Nov 2026 12:21:11 +0000, Vasileios Almpanis wrote:
> We watch the process and not the event fd, because the fd can end up
> in another process, for example in a child of ploop-backup. That
> process would then keep the session alive after ploop-backup dies.

4. The fd is O_CLOEXEC, so it reaches a child only through a fork
without exec. The stronger reasons: the fd is bound to the target,
not to a backup session (d723a1617e619), and a session driven by
push_backup_read/push_backup_write has no fd at all.

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] 4+ messages in thread

end of thread, other threads:[~2026-11-18 12:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 12:21 [Devel] [PATCH hci-8.2] dm/push_backup: stop the backup when the process that started it exits Vasileios Almpanis
2026-11-18 12:27 ` no-reply
2026-11-18 12:30 ` Denis V. Lunev
2026-11-18 12:47 ` Konstantin Khorenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox