Skip to content

Commit e7e27ef

Browse files
committed
Misc iSCSI fixes/cleanups/attempts to get 'zfs rename' to work.
!! Doesn't - a 'zfs rename' works, but most often than not, the rename !! IOCTL hangs. Not every time and not always on the first dataset being !! renamed... Seems a little to random to me.
1 parent cfe9cde commit e7e27ef

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

lib/libzfs/libzfs_changelist.c

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -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 ? */

lib/libzfs/libzfs_dataset.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3961,6 +3961,14 @@ zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive,
39613961
(void) changelist_postfix(cl);
39623962
} else {
39633963
if (!recursive) {
3964+
/*
3965+
* XXX: This 'removes' the old ZVOL name from the
3966+
* list, making changelist_postfix() not
3967+
* removing the old share, which leaves
3968+
* TWO shares - the old and the new!
3969+
*
3970+
* But why does it work for NFS and SMB!?
3971+
*/
39643972
changelist_rename(cl, zfs_get_name(zhp), target);
39653973
ret = changelist_postfix(cl);
39663974
}

0 commit comments

Comments
 (0)