Page MenuHomeFreeBSD

zfs: add option for forcible unmounting dataset while receiving snapshot.
ClosedPublic

Authored by oshogbo on Nov 10 2019, 11:52 AM.

Details

Summary

zfs: add option for forcible unmounting dataset while receiving snapshot.

Currently when the dataset is in use we can't receive snapshot.
zfs send test/1@asd | zfs recv -FM test/2
cannot unmount '/test/2': Device busy

This commits add option 'M' which forcible unmounting the dataset.
Thanks to to that we can enforce receiving snapshot in single step.

Discussed with: pjd

If we think that this is a good idea I can submit pull request to
the OpenZFS as well.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Minor correction to the man page and (this is new to me) the code.

cddl/contrib/opensolaris/cmd/zfs/zfs.8
3005 ↗(On Diff #64149)

s/receiving snapshot/receiving a snapshot/

cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
4165 ↗(On Diff #64149)

This is debug output, right? ;)

cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
3831 ↗(On Diff #64149)

Another debug output here and below?

pjd added inline comments.
cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
2897 ↗(On Diff #64511)

flags->forceunmount?

3846 ↗(On Diff #64511)

I think mflags is never used.

cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
2897 ↗(On Diff #64511)

is this meant to be flags->force or flags->forceunmount ?

cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
2897 ↗(On Diff #64511)

flags->forceunmount. Fixed.

Like Matt suggested I checked the behavior on Linux as well.

oshogbo@u-wing:/test$ sudo sudo zfs send test/1@b | sudo zfs recv -F test/2
umount: /test/2: target is busy.
cannot unmount '/test/2': umount failed
oshogbo@u-wing:/test$ uname -a
Linux u-wing 4.18.0-25-generic #26-Ubuntu SMP Mon Jun 24 09:32:08 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
oshogbo@u-wing:/test$

After closing file descriptor in test/2:

oshogbo@u-wing:/test$ sudo sudo zfs send test/1@b | sudo zfs recv -F test/2
oshogbo@u-wing:/test$
This revision is now accepted and ready to land.Jan 14 2020, 5:59 PM