Skip to content

Commit

Permalink
refine
Browse files Browse the repository at this point in the history
Signed-off-by: Umer Saleem <[email protected]>
  • Loading branch information
usaleem-ix committed Sep 19, 2023
1 parent 37785aa commit 9acb2c9
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions lib/libzfs/libzfs_changelist.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ changelist_prefix(prop_changelist_t *clp)
clp->cl_prop != ZFS_PROP_SHARESMB)
return (0);

if (clp->cl_gflags & CL_GATHER_DONT_UNMOUNT)
return (0);

if ((walk = uu_avl_walk_start(clp->cl_tree, UU_WALK_ROBUST)) == NULL)
return (-1);

Expand All @@ -129,17 +132,13 @@ changelist_prefix(prop_changelist_t *clp)
*/
switch (clp->cl_prop) {
case ZFS_PROP_MOUNTPOINT:
if (clp->cl_gflags & CL_GATHER_DONT_UNMOUNT)
break;
if (zfs_unmount(cn->cn_handle, NULL,
clp->cl_mflags) != 0) {
ret = -1;
cn->cn_needpost = B_FALSE;
}
break;
case ZFS_PROP_SHARESMB:
if (clp->cl_gflags & CL_GATHER_DONT_UNMOUNT)
break;
(void) zfs_unshare(cn->cn_handle, NULL,
smb);
commit_smb_shares = B_TRUE;
Expand Down Expand Up @@ -178,6 +177,9 @@ changelist_postfix(prop_changelist_t *clp)
boolean_t commit_smb_shares = B_FALSE;
boolean_t commit_nfs_shares = B_FALSE;

if (clp->cl_gflags & CL_GATHER_DONT_UNMOUNT)
return (0);

/*
* If we're changing the mountpoint, attempt to destroy the underlying
* mountpoint. All other datasets will have inherited from this dataset
Expand Down Expand Up @@ -206,7 +208,6 @@ changelist_postfix(prop_changelist_t *clp)
boolean_t sharenfs;
boolean_t sharesmb;
boolean_t mounted;
boolean_t nounmount;
boolean_t needs_key;

/*
Expand Down Expand Up @@ -243,9 +244,7 @@ changelist_postfix(prop_changelist_t *clp)

mounted = zfs_is_mounted(cn->cn_handle, NULL);

nounmount = (clp->cl_gflags & CL_GATHER_DONT_UNMOUNT) != 0;

if (!mounted && !nounmount && !needs_key && (cn->cn_mounted ||
if (!mounted && !needs_key && (cn->cn_mounted ||
(((clp->cl_prop == ZFS_PROP_MOUNTPOINT &&
clp->cl_prop == clp->cl_realprop) ||
sharenfs || sharesmb || clp->cl_waslegacy) &&
Expand All @@ -263,19 +262,19 @@ changelist_postfix(prop_changelist_t *clp)
*/
const enum sa_protocol nfs[] =
{SA_PROTOCOL_NFS, SA_NO_PROTOCOL};
if (sharenfs && mounted && !nounmount) {
if (sharenfs && mounted) {
zfs_share(cn->cn_handle, nfs);
commit_nfs_shares = B_TRUE;
} else if ((cn->cn_shared || clp->cl_waslegacy) && !nounmount) {
} else if ((cn->cn_shared || clp->cl_waslegacy)) {
zfs_unshare(cn->cn_handle, NULL, nfs);
commit_nfs_shares = B_TRUE;
}
const enum sa_protocol smb[] =
{SA_PROTOCOL_SMB, SA_NO_PROTOCOL};
if (sharesmb && mounted && !nounmount) {
if (sharesmb && mounted) {
zfs_share(cn->cn_handle, smb);
commit_smb_shares = B_TRUE;
} else if ((cn->cn_shared || clp->cl_waslegacy) && !nounmount) {
} else if ((cn->cn_shared || clp->cl_waslegacy)) {
zfs_unshare(cn->cn_handle, NULL, smb);
commit_smb_shares = B_TRUE;
}
Expand Down

0 comments on commit 9acb2c9

Please sign in to comment.