Project

General

Profile

Bug #12695

zpool_enable|disable_datasets() error handling regression

Added by Joyce McIntosh 2 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
zfs - Zettabyte File System
Start date:
Due date:
% Done:

0%

Estimated time:
Difficulty:
Bite-size
Tags:
Gerrit CR:

Description

Illumos 7955, and associated follow ons, introduce a small bug in the error handling in zpool_enable_datasets() and zpool_disable_datasets().
The calls to zfs_init_libshare_arg() are setting ret, even on success. In the case of zpool_enable_datasets() this means that any preceding error which set ret to -1 is lost. In the case of zpool_disable_datasets(), which sets ret to -1 by default, it means that any subsequent error is lost.

Suggested fix:

diff --git a/usr/src/lib/libzfs/common/libzfs_mount.c b/usr/src/lib/libzfs/common/libzfs_mount.c
index faa750f121..be700802c0 100644
--- a/usr/src/lib/libzfs/common/libzfs_mount.c
++ b/usr/src/lib/libzfs/common/libzfs_mount.c
@ -1551,9 +1551,11 @ zpool_enable_datasets(zpool_handle_t *zhp, const char *mntopts, int flags)
*/
sharearg.zhandle_arr = cb.cb_handles;
sharearg.zhandle_len = cb.cb_used;
- if ((ret = zfs_init_libshare_arg(zhp->zpool_hdl,
- SA_INIT_SHARE_API_SELECTIVE, &sharearg)) != 0)
if (zfs_init_libshare_arg(hdl, SA_INIT_SHARE_API_SELECTIVE, &sharearg)
+ != 0) {
+ ret = -1;
goto out;
+ }

ms.ms_mntstatus = 0;
zfs_foreach_mountpoint(zhp->zpool_hdl, cb.cb_handles, cb.cb_used,
@ -1676,10 +1678,10 @ zpool_disable_datasets(zpool_handle_t *zhp, boolean_t force)
*/
sharearg.zhandle_arr = datasets;
sharearg.zhandle_len = used;
- ret = zfs_init_libshare_arg(hdl, SA_INIT_SHARE_API_SELECTIVE,
- &sharearg);
- if (ret != 0)
+ if (zfs_init_libshare_arg(hdl, SA_INIT_SHARE_API_SELECTIVE, &sharearg)
+ != 0) {
goto out;
+ }
qsort(mountpoints, used, sizeof (char *), mountpoint_compare);

Also available in: Atom PDF