summaryrefslogtreecommitdiff
path: root/usr/src/lib/libzfs/common/libzfs_dataset.c
diff options
context:
space:
mode:
authoreschrock <none@none>2006-07-31 15:13:30 -0700
committereschrock <none@none>2006-07-31 15:13:30 -0700
commit3bb79bece53191f2cf27aa61a72ea1784a7ce700 (patch)
tree2ef162103e713655e9e6889a7ac7389d304f7c55 /usr/src/lib/libzfs/common/libzfs_dataset.c
parent79033acb8a0c499540c5c46e165cff4ccc2ebf59 (diff)
downloadillumos-gate-3bb79bece53191f2cf27aa61a72ea1784a7ce700.tar.gz
6368751 libzfs interface for mount/umounting all the file systems for a given pool
6385349 zpool import -d /dev hangs 6397052 unmounting datasets should process /etc/mnttab instead of traverse DSL 6403510 zfs remount,noatime option broken 6423412 Two spaces lines are unnecessary after 'zpool import -a' 6434054 'zfs destroy' core dumps if clone is namespace-parent of origin 6440515 namespace_reload() can leak memory on allocation faiure 6440592 nvlist_dup() should not fill in destination pointer on error 6446060 zfs get does not consistently report temporary properties 6448326 zfs(1) 'list' command crashes if hidden property createtxg is requested 6450653 get_dependents() has poor error semantics --HG-- rename : usr/src/cmd/zpool/zpool_dataset.c => deleted_files/usr/src/cmd/zpool/zpool_dataset.c
Diffstat (limited to 'usr/src/lib/libzfs/common/libzfs_dataset.c')
-rw-r--r--usr/src/lib/libzfs/common/libzfs_dataset.c59
1 files changed, 36 insertions, 23 deletions
diff --git a/usr/src/lib/libzfs/common/libzfs_dataset.c b/usr/src/lib/libzfs/common/libzfs_dataset.c
index 5b766f7818..4d150bbf79 100644
--- a/usr/src/lib/libzfs/common/libzfs_dataset.c
+++ b/usr/src/lib/libzfs/common/libzfs_dataset.c
@@ -1084,6 +1084,33 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zfs_source_t *src,
*source = NULL;
+ /*
+ * Because looking up the mount options is potentially expensive
+ * (iterating over all of /etc/mnttab), we defer its calculation until
+ * we're looking up a property which requires its presence.
+ */
+ if (!zhp->zfs_mntcheck &&
+ (prop == ZFS_PROP_ATIME ||
+ prop == ZFS_PROP_DEVICES ||
+ prop == ZFS_PROP_EXEC ||
+ prop == ZFS_PROP_READONLY ||
+ prop == ZFS_PROP_SETUID ||
+ prop == ZFS_PROP_MOUNTED)) {
+ struct mnttab search = { 0 }, entry;
+
+ search.mnt_special = (char *)zhp->zfs_name;
+ search.mnt_fstype = MNTTYPE_ZFS;
+ rewind(zhp->zfs_hdl->libzfs_mnttab);
+
+ if (getmntany(zhp->zfs_hdl->libzfs_mnttab, &entry,
+ &search) == 0 && (zhp->zfs_mntopts =
+ zfs_strdup(zhp->zfs_hdl,
+ entry.mnt_mntopts)) == NULL)
+ return (-1);
+
+ zhp->zfs_mntcheck = B_TRUE;
+ }
+
if (zhp->zfs_mntopts == NULL)
mnt.mnt_mntopts = "";
else
@@ -1229,26 +1256,6 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zfs_source_t *src,
break;
case ZFS_PROP_MOUNTED:
- /*
- * Unlike other properties, we defer calculation of 'MOUNTED'
- * until actually requested. This is because the getmntany()
- * call can be extremely expensive on systems with a large
- * number of filesystems, and the property isn't needed in
- * normal use cases.
- */
- if (zhp->zfs_mntopts == NULL) {
- struct mnttab search = { 0 }, entry;
-
- search.mnt_special = (char *)zhp->zfs_name;
- search.mnt_fstype = MNTTYPE_ZFS;
- rewind(zhp->zfs_hdl->libzfs_mnttab);
-
- if (getmntany(zhp->zfs_hdl->libzfs_mnttab, &entry,
- &search) == 0 && (zhp->zfs_mntopts =
- zfs_strdup(zhp->zfs_hdl,
- entry.mnt_mntopts)) == NULL)
- return (-1);
- }
*val = (zhp->zfs_mntopts != NULL);
break;
@@ -2729,7 +2736,9 @@ rollback_destroy(zfs_handle_t *zhp, void *data)
cbp->cb_create) {
cbp->cb_dependent = B_TRUE;
- (void) zfs_iter_dependents(zhp, rollback_destroy, cbp);
+ if (zfs_iter_dependents(zhp, B_FALSE, rollback_destroy,
+ cbp) != 0)
+ cbp->cb_error = 1;
cbp->cb_dependent = B_FALSE;
if (zfs_destroy(zhp) != 0)
@@ -2857,7 +2866,8 @@ out:
* libzfs_graph.c.
*/
int
-zfs_iter_dependents(zfs_handle_t *zhp, zfs_iter_f func, void *data)
+zfs_iter_dependents(zfs_handle_t *zhp, boolean_t allowrecursion,
+ zfs_iter_f func, void *data)
{
char **dependents;
size_t count;
@@ -2865,7 +2875,10 @@ zfs_iter_dependents(zfs_handle_t *zhp, zfs_iter_f func, void *data)
zfs_handle_t *child;
int ret = 0;
- dependents = get_dependents(zhp->zfs_hdl, zhp->zfs_name, &count);
+ if (get_dependents(zhp->zfs_hdl, allowrecursion, zhp->zfs_name,
+ &dependents, &count) != 0)
+ return (-1);
+
for (i = 0; i < count; i++) {
if ((child = make_dataset_handle(zhp->zfs_hdl,
dependents[i])) == NULL)