[Devel] [PATCH hci-8.2 v2 0/3] dm/push_backup: stop the backup when the process that started it exits
Andrey Zhadchenko
andrey.zhadchenko at virtuozzo.com
Wed Nov 18 17:05:36 MSK 2026
Reviewed-by: Andrey Zhadchenko <andrey.zhadchenko at 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 at 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
>
More information about the Devel
mailing list