Skip to content

Commit

Permalink
Misc iSCSI fixes/cleanups/attempts to get 'zfs rename' to work.
Browse files Browse the repository at this point in the history
!! 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.
  • Loading branch information
FransUrbo committed Oct 19, 2015
1 parent cfe9cde commit e7e27ef
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
44 changes: 20 additions & 24 deletions lib/libzfs/libzfs_changelist.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ changelist_prefix(prop_changelist_t *clp)
int ret = 0;

if (clp->cl_prop != ZFS_PROP_MOUNTPOINT &&
clp->cl_prop != ZFS_PROP_SHARESMB)
clp->cl_prop != ZFS_PROP_SHARESMB &&
clp->cl_prop != ZFS_PROP_SHAREISCSI)
return (0);

for (cn = uu_list_first(clp->cl_list); cn != NULL;
Expand Down Expand Up @@ -136,6 +137,17 @@ changelist_prefix(prop_changelist_t *clp)
default:
break;
}
} else if (ZFS_IS_VOLUME(cn->cn_handle) && cn->cn_shared &&
clp->cl_realprop == ZFS_PROP_NAME) {
/* If this was a rename, unshare the zvol */

/*
* XXX: Sometimes (quite often actually), the rename
* IOCTL that follows hangs (because of this?
* - works without it, but the old share won't
* get removed/unshared)...
*/
(void) zfs_unshare_iscsi(cn->cn_handle, NULL);
}
}

Expand Down Expand Up @@ -234,8 +246,8 @@ changelist_postfix(prop_changelist_t *clp)
mounted = zfs_is_mounted(cn->cn_handle, NULL);

if (!mounted && (cn->cn_mounted ||
((sharenfs || sharesmb || shareiscsi ||
clp->cl_waslegacy) && (zfs_prop_get_int(cn->cn_handle,
((sharenfs || sharesmb || clp->cl_waslegacy) &&
(zfs_prop_get_int(cn->cn_handle,
ZFS_PROP_CANMOUNT) == ZFS_CANMOUNT_ON)))) {
if (zfs_mount(cn->cn_handle, NULL, 0) != 0)
errors++;
Expand All @@ -248,26 +260,10 @@ changelist_postfix(prop_changelist_t *clp)
* if the filesystem is currently shared, so that we can
* adopt any new options.
*/
if (sharenfs && mounted)
errors += zfs_share_nfs(cn->cn_handle);
if (((sharenfs || sharesmb) && mounted) || shareiscsi)
errors += zfs_share(cn->cn_handle);
else if (cn->cn_shared || clp->cl_waslegacy)
errors += zfs_unshare_nfs(cn->cn_handle, NULL);
if (sharesmb && mounted)
errors += zfs_share_smb(cn->cn_handle);
else if (cn->cn_shared || clp->cl_waslegacy)
errors += zfs_unshare_smb(cn->cn_handle, NULL);

/*
* XXX: This is wrong somehow - needs to be fixed properly.
* In practice it works, it just looks wrong (considering
* above code...
*/
if (shareiscsi && !cn->cn_shared)
errors += zfs_share_iscsi(cn->cn_handle);
if (cn->cn_shared) {
errors += zfs_unshare_iscsi(cn->cn_handle, NULL);
errors += zfs_share_iscsi(cn->cn_handle);
}
errors += zfs_unshare(cn->cn_handle);
}

return (errors ? -1 : 0);
Expand Down Expand Up @@ -564,7 +560,7 @@ changelist_gather(zfs_handle_t *zhp, zfs_prop_t prop, int gather_flags,
*/
if (prop == ZFS_PROP_NAME || prop == ZFS_PROP_ZONED ||
prop == ZFS_PROP_MOUNTPOINT || prop == ZFS_PROP_SHARENFS ||
prop == ZFS_PROP_SHARESMB || prop == ZFS_PROP_SHAREISCSI) {
prop == ZFS_PROP_SHARESMB) {

if (zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT,
property, sizeof (property),
Expand Down Expand Up @@ -633,7 +629,7 @@ changelist_gather(zfs_handle_t *zhp, zfs_prop_t prop, int gather_flags,
return (clp);

/*
* If watching SHARENFS, SHARESMB then
* If watching SHARENFS or SHARESMB then
* also watch its companion property.
*/
/* TODO: add SHAREISCSI ? */
Expand Down
8 changes: 8 additions & 0 deletions lib/libzfs/libzfs_dataset.c
Original file line number Diff line number Diff line change
Expand Up @@ -3961,6 +3961,14 @@ zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive,
(void) changelist_postfix(cl);
} else {
if (!recursive) {
/*
* XXX: This 'removes' the old ZVOL name from the
* list, making changelist_postfix() not
* removing the old share, which leaves
* TWO shares - the old and the new!
*
* But why does it work for NFS and SMB!?
*/
changelist_rename(cl, zfs_get_name(zhp), target);
ret = changelist_postfix(cl);
}
Expand Down

0 comments on commit e7e27ef

Please sign in to comment.