@@ -101,7 +101,8 @@ changelist_prefix(prop_changelist_t *clp)
101101 int ret = 0 ;
102102
103103 if (clp -> cl_prop != ZFS_PROP_MOUNTPOINT &&
104- clp -> cl_prop != ZFS_PROP_SHARESMB )
104+ clp -> cl_prop != ZFS_PROP_SHARESMB &&
105+ clp -> cl_prop != ZFS_PROP_SHAREISCSI )
105106 return (0 );
106107
107108 for (cn = uu_list_first (clp -> cl_list ); cn != NULL ;
@@ -139,6 +140,17 @@ changelist_prefix(prop_changelist_t *clp)
139140 default :
140141 break ;
141142 }
143+ } else if (ZFS_IS_VOLUME (cn -> cn_handle ) && cn -> cn_shared &&
144+ clp -> cl_realprop == ZFS_PROP_NAME ) {
145+ /* If this was a rename, unshare the zvol */
146+
147+ /*
148+ * XXX: Sometimes (quite often actually), the rename
149+ * IOCTL that follows hangs (because of this?
150+ * - works without it, but the old share won't
151+ * get removed/unshared)...
152+ */
153+ (void ) zfs_unshare_iscsi (cn -> cn_handle , NULL );
142154 }
143155 }
144156
@@ -240,9 +252,9 @@ changelist_postfix(prop_changelist_t *clp)
240252
241253 mounted = zfs_is_mounted (cn -> cn_handle , NULL );
242254
243- if (!mounted && (cn -> cn_mounted ||
244- ((sharenfs || sharesmb || shareiscsi ||
245- clp -> cl_waslegacy ) && (zfs_prop_get_int (cn -> cn_handle ,
255+ if (!mounted && ! needs_key && (cn -> cn_mounted ||
256+ ((sharenfs || sharesmb || clp -> cl_waslegacy ) &&
257+ (zfs_prop_get_int (cn -> cn_handle ,
246258 ZFS_PROP_CANMOUNT ) == ZFS_CANMOUNT_ON )))) {
247259 if (zfs_mount (cn -> cn_handle , NULL , 0 ) != 0 )
248260 errors ++ ;
@@ -255,26 +267,10 @@ changelist_postfix(prop_changelist_t *clp)
255267 * if the filesystem is currently shared, so that we can
256268 * adopt any new options.
257269 */
258- if (sharenfs && mounted )
259- errors += zfs_share_nfs (cn -> cn_handle );
270+ if ((( sharenfs || sharesmb ) && mounted ) || shareiscsi )
271+ errors += zfs_share (cn -> cn_handle );
260272 else if (cn -> cn_shared || clp -> cl_waslegacy )
261- errors += zfs_unshare_nfs (cn -> cn_handle , NULL );
262- if (sharesmb && mounted )
263- errors += zfs_share_smb (cn -> cn_handle );
264- else if (cn -> cn_shared || clp -> cl_waslegacy )
265- errors += zfs_unshare_smb (cn -> cn_handle , NULL );
266-
267- /*
268- * XXX: This is wrong somehow - needs to be fixed properly.
269- * In practice it works, it just looks wrong (considering
270- * above code...
271- */
272- if (shareiscsi && !cn -> cn_shared )
273- errors += zfs_share_iscsi (cn -> cn_handle );
274- if (cn -> cn_shared ) {
275- errors += zfs_unshare_iscsi (cn -> cn_handle , NULL );
276- errors += zfs_share_iscsi (cn -> cn_handle );
277- }
273+ errors += zfs_unshare (cn -> cn_handle );
278274 }
279275
280276 return (errors ? -1 : 0 );
@@ -572,7 +568,7 @@ changelist_gather(zfs_handle_t *zhp, zfs_prop_t prop, int gather_flags,
572568 */
573569 if (prop == ZFS_PROP_NAME || prop == ZFS_PROP_ZONED ||
574570 prop == ZFS_PROP_MOUNTPOINT || prop == ZFS_PROP_SHARENFS ||
575- prop == ZFS_PROP_SHARESMB || prop == ZFS_PROP_SHAREISCSI ) {
571+ prop == ZFS_PROP_SHARESMB ) {
576572
577573 if (zfs_prop_get (zhp , ZFS_PROP_MOUNTPOINT ,
578574 property , sizeof (property ),
@@ -641,7 +637,7 @@ changelist_gather(zfs_handle_t *zhp, zfs_prop_t prop, int gather_flags,
641637 return (clp );
642638
643639 /*
644- * If watching SHARENFS, SHARESMB then
640+ * If watching SHARENFS or SHARESMB then
645641 * also watch its companion property.
646642 */
647643 /* TODO: add SHAREISCSI ? */
0 commit comments