@@ -99,7 +99,8 @@ changelist_prefix(prop_changelist_t *clp)
9999 int ret = 0 ;
100100
101101 if (clp -> cl_prop != ZFS_PROP_MOUNTPOINT &&
102- clp -> cl_prop != ZFS_PROP_SHARESMB )
102+ clp -> cl_prop != ZFS_PROP_SHARESMB &&
103+ clp -> cl_prop != ZFS_PROP_SHAREISCSI )
103104 return (0 );
104105
105106 for (cn = uu_list_first (clp -> cl_list ); cn != NULL ;
@@ -136,6 +137,17 @@ changelist_prefix(prop_changelist_t *clp)
136137 default :
137138 break ;
138139 }
140+ } else if (ZFS_IS_VOLUME (cn -> cn_handle ) && cn -> cn_shared &&
141+ clp -> cl_realprop == ZFS_PROP_NAME ) {
142+ /* If this was a rename, unshare the zvol */
143+
144+ /*
145+ * XXX: Sometimes (quite often actually), the rename
146+ * IOCTL that follows hangs (because of this?
147+ * - works without it, but the old share won't
148+ * get removed/unshared)...
149+ */
150+ (void ) zfs_unshare_iscsi (cn -> cn_handle , NULL );
139151 }
140152 }
141153
@@ -234,8 +246,8 @@ changelist_postfix(prop_changelist_t *clp)
234246 mounted = zfs_is_mounted (cn -> cn_handle , NULL );
235247
236248 if (!mounted && (cn -> cn_mounted ||
237- ((sharenfs || sharesmb || shareiscsi ||
238- clp -> cl_waslegacy ) && (zfs_prop_get_int (cn -> cn_handle ,
249+ ((sharenfs || sharesmb || clp -> cl_waslegacy ) &&
250+ (zfs_prop_get_int (cn -> cn_handle ,
239251 ZFS_PROP_CANMOUNT ) == ZFS_CANMOUNT_ON )))) {
240252 if (zfs_mount (cn -> cn_handle , NULL , 0 ) != 0 )
241253 errors ++ ;
@@ -248,26 +260,10 @@ changelist_postfix(prop_changelist_t *clp)
248260 * if the filesystem is currently shared, so that we can
249261 * adopt any new options.
250262 */
251- if (sharenfs && mounted )
252- errors += zfs_share_nfs (cn -> cn_handle );
263+ if ((( sharenfs || sharesmb ) && mounted ) || shareiscsi )
264+ errors += zfs_share (cn -> cn_handle );
253265 else if (cn -> cn_shared || clp -> cl_waslegacy )
254- errors += zfs_unshare_nfs (cn -> cn_handle , NULL );
255- if (sharesmb && mounted )
256- errors += zfs_share_smb (cn -> cn_handle );
257- else if (cn -> cn_shared || clp -> cl_waslegacy )
258- errors += zfs_unshare_smb (cn -> cn_handle , NULL );
259-
260- /*
261- * XXX: This is wrong somehow - needs to be fixed properly.
262- * In practice it works, it just looks wrong (considering
263- * above code...
264- */
265- if (shareiscsi && !cn -> cn_shared )
266- errors += zfs_share_iscsi (cn -> cn_handle );
267- if (cn -> cn_shared ) {
268- errors += zfs_unshare_iscsi (cn -> cn_handle , NULL );
269- errors += zfs_share_iscsi (cn -> cn_handle );
270- }
266+ errors += zfs_unshare (cn -> cn_handle );
271267 }
272268
273269 return (errors ? -1 : 0 );
@@ -564,7 +560,7 @@ changelist_gather(zfs_handle_t *zhp, zfs_prop_t prop, int gather_flags,
564560 */
565561 if (prop == ZFS_PROP_NAME || prop == ZFS_PROP_ZONED ||
566562 prop == ZFS_PROP_MOUNTPOINT || prop == ZFS_PROP_SHARENFS ||
567- prop == ZFS_PROP_SHARESMB || prop == ZFS_PROP_SHAREISCSI ) {
563+ prop == ZFS_PROP_SHARESMB ) {
568564
569565 if (zfs_prop_get (zhp , ZFS_PROP_MOUNTPOINT ,
570566 property , sizeof (property ),
@@ -633,7 +629,7 @@ changelist_gather(zfs_handle_t *zhp, zfs_prop_t prop, int gather_flags,
633629 return (clp );
634630
635631 /*
636- * If watching SHARENFS, SHARESMB then
632+ * If watching SHARENFS or SHARESMB then
637633 * also watch its companion property.
638634 */
639635 /* TODO: add SHAREISCSI ? */
0 commit comments