Mercurial > illumos > illumos-gate
changeset 884:662fba6e367d
6345875 The zfs "sharenfs" option fails after an alternate-root mount, until reboot
author | lling |
---|---|
date | Thu, 10 Nov 2005 17:51:31 -0800 |
parents | 0456757ec785 |
children | d925b21dba78 |
files | usr/src/cmd/zpool/zpool_dataset.c usr/src/cmd/zpool/zpool_main.c usr/src/cmd/zpool/zpool_util.h |
diffstat | 3 files changed, 21 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/zpool/zpool_dataset.c Thu Nov 10 16:25:29 2005 -0800 +++ b/usr/src/cmd/zpool/zpool_dataset.c Thu Nov 10 17:51:31 2005 -0800 @@ -26,17 +26,22 @@ #pragma ident "%Z%%M% %I% %E% SMI" +/* + * For export and destroy, we have to support iterating over all datasets and + * unmounting and/or destroying them. + * + * For import, we need to iterate over all datasets, mounting and sharing + * them as indicated by the mountpoint and sharenfs properties. + * + * This file contains the routines to support this. + */ + #include <libintl.h> #include <libzfs.h> #include <sys/mount.h> #include "zpool_util.h" -/* - * For export and destroy, we have to support iterating over all datasets and - * unmounting and/or destroying them. This file contains the routines to - * support this. - */ typedef struct cbdata { int cb_force; int cb_failed; @@ -95,10 +100,10 @@ } /* - * Mount a single dataset + * Mount and share a single dataset */ static int -do_mount(zfs_handle_t *zfsp, void *data) +do_mount_share(zfs_handle_t *zfsp, void *data) { cbdata_t *cbp = data; int ret; @@ -108,22 +113,25 @@ if (zfs_mount(zfsp, cbp->cb_mntopts, 0) != 0) cbp->cb_failed = 1; + else if (zfs_share(zfsp) != 0) + cbp->cb_failed = 1; - ret = zfs_iter_children(zfsp, do_mount, data); + ret = zfs_iter_children(zfsp, do_mount_share, data); return (ret); } - /* * Go through and mount all datasets within a pool. We need to mount all * datasets in order, so that we mount parents before any children. A complete * fix would gather all mountpoints, sort them, and mount them in lexical order. * There are many more problems if you start to have nested filesystems - we * just want to get inherited filesystems right. + * + * Perform share as needed when mounting a dataset is successful. */ int -mount_datasets(zpool_handle_t *zhp, const char *options) +mount_share_datasets(zpool_handle_t *zhp, const char *options) { cbdata_t cb = { 0 }; zfs_handle_t *zfsp; @@ -137,7 +145,7 @@ if ((zfsp = zfs_open(zpool_get_name(zhp), ZFS_TYPE_FILESYSTEM)) == NULL) return (-1); - if (do_mount(zfsp, &cb) != 0 || cb.cb_failed != 0) { + if (do_mount_share(zfsp, &cb) != 0 || cb.cb_failed != 0) { zfs_close(zfsp); return (-1); }
--- a/usr/src/cmd/zpool/zpool_main.c Thu Nov 10 16:25:29 2005 -0800 +++ b/usr/src/cmd/zpool/zpool_main.c Thu Nov 10 17:51:31 2005 -0800 @@ -911,7 +911,7 @@ verify((zhp = zpool_open(name)) != NULL); - if (mount_datasets(zhp, mntopts) != 0) { + if (mount_share_datasets(zhp, mntopts) != 0) { zpool_close(zhp); return (1); }
--- a/usr/src/cmd/zpool/zpool_util.h Thu Nov 10 16:25:29 2005 -0800 +++ b/usr/src/cmd/zpool/zpool_util.h Thu Nov 10 17:51:31 2005 -0800 @@ -69,7 +69,7 @@ * Dataset functions */ int unmount_datasets(zpool_handle_t *, int); -int mount_datasets(zpool_handle_t *, const char *); +int mount_share_datasets(zpool_handle_t *, const char *); #ifdef __cplusplus }