aboutsummaryrefslogtreecommitdiff
path: root/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
diff options
context:
space:
mode:
authorMariusz Zaborski <oshogbo@FreeBSD.org>2020-04-11 17:54:35 +0000
committerMariusz Zaborski <oshogbo@FreeBSD.org>2020-04-11 17:54:35 +0000
commit23ee238fe5e3971569b3bd2ed2a2930110550466 (patch)
treed86f4ab8d193d4922ae377273be7ba1132f83c12 /cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
parenteec362ef5816b61b79a98d28830c5ff1d757b3ae (diff)
downloadsrc-23ee238fe5e3971569b3bd2ed2a2930110550466.tar.gz
src-23ee238fe5e3971569b3bd2ed2a2930110550466.zip
zfs: Add option for forcible unmounting dataset while receiving snapshot.
Currently when the dataset is in use we can't receive snapshots. zfs send test/1@asd | zfs recv -FM test/2 cannot unmount '/test/2': Device busy This commits add option 'M' which attempts to forcibly unmount the dataset. Thanks to this we can enforce receiving snapshots in a single step. Note that this functionality is not supported on Linux because the VFS will prevent active mounted filesystems from being unmounted, even with the force option. This is the intended VFS behavior. Discussed-with: Pawel Jakub Dawidek <pjd@FreeBSD.org> Reviewed-by: Ryan Moeller <ryan@iXsystems.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Allan Jude <allanjude@freebsd.org> Differential Revision: https://reviews.freebsd.org/D22306 openzfs/zfs@a57d3d45d6efdff935421e2ef3f97e3dc089d93d
Notes
Notes: svn path=/head/; revision=359808
Diffstat (limited to 'cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c')
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
index e6f654b25b5f..71a951027b30 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
@@ -2913,7 +2913,8 @@ zfs_receive_package(libzfs_handle_t *hdl, int fd, const char *destname,
ZFS_TYPE_FILESYSTEM);
if (zhp != NULL) {
clp = changelist_gather(zhp,
- ZFS_PROP_MOUNTPOINT, 0, 0);
+ ZFS_PROP_MOUNTPOINT, 0,
+ flags->forceunmount ? MS_FORCE : 0);
zfs_close(zhp);
if (clp != NULL) {
softerr |=
@@ -3435,7 +3436,8 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
if (!flags->dryrun && zhp->zfs_type == ZFS_TYPE_FILESYSTEM &&
stream_wantsnewfs) {
/* We can't do online recv in this case */
- clp = changelist_gather(zhp, ZFS_PROP_NAME, 0, 0);
+ clp = changelist_gather(zhp, ZFS_PROP_NAME, 0,
+ flags->forceunmount ? MS_FORCE : 0);
if (clp == NULL) {
zfs_close(zhp);
zcmd_free_nvlists(&zc);
@@ -3881,6 +3883,7 @@ zfs_receive(libzfs_handle_t *hdl, const char *tosnap, nvlist_t *props,
int cleanup_fd;
uint64_t action_handle = 0;
char *originsnap = NULL;
+
if (props) {
err = nvlist_lookup_string(props, "origin", &originsnap);
if (err && err != ENOENT)
@@ -3902,7 +3905,8 @@ zfs_receive(libzfs_handle_t *hdl, const char *tosnap, nvlist_t *props,
zhp = zfs_open(hdl, top_zfs, ZFS_TYPE_FILESYSTEM);
if (zhp != NULL) {
clp = changelist_gather(zhp, ZFS_PROP_MOUNTPOINT,
- CL_GATHER_MOUNT_ALWAYS, 0);
+ CL_GATHER_MOUNT_ALWAYS,
+ flags->forceunmount ? MS_FORCE : 0);
zfs_close(zhp);
if (clp != NULL) {
/* mount and share received datasets */