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 v2 0/3] dm/push_backup: stop the backup when the process that started it exits
Date: Wed, 18 Nov 2026 13:57:26 +0000 [thread overview]
Message-ID: <20261118-vstor-153891-v2-0-e91753150b91@virtuozzo.com> (raw)
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
next reply other threads:[~2026-11-18 13:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 13:57 Vasileios Almpanis [this message]
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
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=20261118-vstor-153891-v2-0-e91753150b91@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