diff options
| author | Denis V. Lunev <den@openvz.org> | 2026-11-06 19:14:59 +0100 |
|---|---|---|
| committer | Amir Goldstein <amir73il@gmail.com> | 2026-11-10 15:47:32 +0100 |
| commit | cb6c084182d4c69b7eeff0bd519dd7e018749602 (patch) | |
| tree | d7398b271846c0c41350bcb415a37200dc959a55 /scripts | |
| parent | 7031366be218f291592a7ad38bc34a7cd1459737 (diff) | |
ovl: release the upperdir/workdir in-use locks before the umount sync
The in-use locks on upperdir and workdir are released by ovl_free_fs()
from ->put_super(). generic_shutdown_super() calls sync_filesystem()
before that, and ovl_sync_fs() syncs the whole upper filesystem, so the
locks stay held across a journal commit and a cache flush of the upper
fs after the overlay is gone. With index=on a new overlay that uses the
same upperdir, or uses it as a lowerdir, fails to mount in that window:
overlayfs: upperdir is in-use as upperdir/workdir of another mount,
mount with '-o index=off' to override exclusive upperdir protection.
Userspace hits this when the last reference is not dropped by umount(2)
itself. Docker with the containerd snapshotter mounts a snapshot on a
thread with a private mount namespace for docker cp and for buildkit,
and the superblock dies when that thread exits, after the reply to the
client has gone out. The next request then gets EBUSY. The window grows
with the flush latency of the upper fs and is there even if nothing was
written through the overlay, as the mount itself dirties the upper.
->kill_sb() is called once s_active drops to zero, with no mount and no
open file left. Release the locks there, before generic_shutdown_super()
runs. What the dying superblock still does to the upper fs, the sync and
dropping its references to upper dentries and inodes, does not touch the
contents of upperdir or workdir. ovl_free_fs() still releases the locks
for a failed mount, so clear the *_locked flags to keep it from
unlocking a second time and dropping the lock of a newer mount.
This takes the sync out of the window but does not close it: the final
mntput of a dying mount namespace runs from task_work, after the exiting
thread may have reported completion. Userspace that needs the
directories free should umount(2) before saying the job is done.
Fixes: 2cac0c00a6cd ("ovl: get exclusive ownership on upper/work dirs")
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Amir Goldstein <amir73il@gmail.com>
Cc: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Diffstat (limited to 'scripts')
0 files changed, 0 insertions, 0 deletions
