Detach busy container mounts lazily during snapshot retention
This commit is contained in:
parent
4e097e15e9
commit
87e437e8e2
2 changed files with 13 additions and 1 deletions
|
|
@ -30,7 +30,10 @@ unmount_view() {
|
|||
umount "$target" 2>/dev/null && return 0
|
||||
sleep 1
|
||||
done
|
||||
return 1
|
||||
# A reader can hold the retired view open; a lazy detach removes it from the
|
||||
# mount table (what ZFS checks) without waiting for that reader to finish.
|
||||
umount -l "$target" 2>/dev/null || true
|
||||
! mountpoint -q "$target"
|
||||
}
|
||||
# A mount shared by several processes disappears for all of them at once, so a
|
||||
# failed attempt is only an error when the entry is still present afterwards.
|
||||
|
|
@ -41,6 +44,12 @@ detach_snapshot_mounts() {
|
|||
[[ -n $target ]] || continue
|
||||
pid=${entry#/proc/}; pid=${pid%/mountinfo}
|
||||
nsenter -t "$pid" -m -- umount "$target" 2>/dev/null || true
|
||||
if grep -qF " - zfs $snap " "$entry" 2>/dev/null; then
|
||||
# A container keeps the propagated copy busy (cwd, open files) and
|
||||
# refuses a normal unmount. A lazy detach drops it from that mount
|
||||
# table without stopping the container; ZFS only needs the table.
|
||||
nsenter -t "$pid" -m -- umount -l "$target" 2>/dev/null || true
|
||||
fi
|
||||
if grep -qF " - zfs $snap " "$entry" 2>/dev/null; then
|
||||
echo "warning: $snap is still mounted at $target in the namespace of pid $pid ($(tr '\0' ' ' < /proc/"$pid"/cmdline 2>/dev/null | cut -c1-60))" >&2
|
||||
failed=1
|
||||
|
|
|
|||
|
|
@ -190,6 +190,9 @@ class Portal(unittest.TestCase):
|
|||
self.assertLess(script.index('detach_snapshot_mounts "$snap"'), destroy)
|
||||
self.assertIn('/proc/[0-9]*/mountinfo', script)
|
||||
self.assertIn('nsenter -t "$pid" -m -- umount', script)
|
||||
# A container can keep the propagated mount busy; retention must still be
|
||||
# able to detach it lazily instead of keeping a fourth snapshot.
|
||||
self.assertIn('nsenter -t "$pid" -m -- umount -l', script)
|
||||
self.assertIn('dataset is busy', script)
|
||||
self.assertIn('umount -l', script)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue