From cfea4862aa9adab7aafc28b0ee56bfe6ce823d40 Mon Sep 17 00:00:00 2001 From: mav Date: Sat, 10 May 2014 15:21:37 +0000 Subject: Comment out some pointless device open/close around reading device IDs. FreeBSD ZFS port unlike OpenSolaris does not use device IDs, and does not implement respective devid_*() fuctions. It is pointless to open devices just to close them back immediately. MFC after: 2 weeks Sponsored by: iXsystems, Inc. --- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c | 4 ++++ cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'cddl/contrib/opensolaris/lib/libzfs/common') diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c index e53a8cd..868961d 100644 --- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c +++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c @@ -94,6 +94,7 @@ typedef struct pool_list { static char * get_devid(const char *path) { +#ifdef have_devid int fd; ddi_devid_t devid; char *minor, *ret; @@ -113,6 +114,9 @@ get_devid(const char *path) (void) close(fd); return (ret); +#else + return (NULL); +#endif } diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c index 8dd24a7..02f0b96 100644 --- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c +++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c @@ -3324,6 +3324,7 @@ devid_to_path(char *devid_str) static char * path_to_devid(const char *path) { +#ifdef have_devid int fd; ddi_devid_t devid; char *minor, *ret; @@ -3343,6 +3344,9 @@ path_to_devid(const char *path) (void) close(fd); return (ret); +#else + return (NULL); +#endif } /* -- cgit v1.1 From 0d7d731791d57691c640cdbdae4769591b0f68eb Mon Sep 17 00:00:00 2001 From: delphij Date: Tue, 1 Jul 2014 07:29:42 +0000 Subject: MFV r267566: 4390 i/o errors when deleting filesystem/zvol can lead to space map corruption MFC after: 2 weeks --- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c | 1 + 1 file changed, 1 insertion(+) (limited to 'cddl/contrib/opensolaris/lib/libzfs/common') diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c index 02f0b96..c344c94 100644 --- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c +++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c @@ -303,6 +303,7 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len, case ZPOOL_PROP_ALLOCATED: case ZPOOL_PROP_FREE: case ZPOOL_PROP_FREEING: + case ZPOOL_PROP_LEAKED: case ZPOOL_PROP_EXPANDSZ: if (literal) { (void) snprintf(buf, len, "%llu", -- cgit v1.1 From be1d315a0495d0ceec39374f3f49a5674595bf93 Mon Sep 17 00:00:00 2001 From: delphij Date: Tue, 1 Jul 2014 20:57:39 +0000 Subject: - Fix handling of "new" style of ioctl in compatiblity mode [1]; - Reorganize code and reduce diff from upstream; - Improve forward compatibility shims for previous kernel; Reported by: sbruno [1] X-MFC-With: r268075 --- .../opensolaris/lib/libzfs/common/libzfs_compat.c | 27 ++++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'cddl/contrib/opensolaris/lib/libzfs/common') diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_compat.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_compat.c index 3c8119d..a3f6129 100644 --- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_compat.c +++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_compat.c @@ -72,16 +72,23 @@ zcmd_ioctl(int fd, int request, zfs_cmd_t *zc) if (zfs_ioctl_version == ZFS_IOCVER_UNDEF) zfs_ioctl_version = get_zfs_ioctl_version(); - if (zfs_ioctl_version == ZFS_IOCVER_LZC) - cflag = ZFS_CMD_COMPAT_LZC; - else if (zfs_ioctl_version == ZFS_IOCVER_DEADMAN) - cflag = ZFS_CMD_COMPAT_DEADMAN; - - /* - * If vfs.zfs.version.ioctl is not defined, assume we have v28 - * compatible binaries and use vfs.zfs.version.spa to test for v15 - */ - if (zfs_ioctl_version < ZFS_IOCVER_DEADMAN) { + if (zfs_ioctl_version >= ZFS_IOCVER_DEADMAN) { + switch (zfs_ioctl_version) { + case ZFS_IOCVER_ZCMD: + cflag = ZFS_CMD_COMPAT_ZCMD; + break; + case ZFS_IOCVER_LZC: + cflag = ZFS_CMD_COMPAT_LZC; + break; + case ZFS_IOCVER_DEADMAN: + cflag = ZFS_CMD_COMPAT_DEADMAN; + break; + } + } else { + /* + * If vfs.zfs.version.ioctl is not defined, assume we have v28 + * compatible binaries and use vfs.zfs.version.spa to test for v15 + */ cflag = ZFS_CMD_COMPAT_V28; if (zfs_spa_version < 0) -- cgit v1.1 From 6012f0ab3a6d68d680ff3f02df97deb938177c2c Mon Sep 17 00:00:00 2001 From: delphij Date: Tue, 1 Jul 2014 21:51:30 +0000 Subject: MFV r268119: 4914 zfs on-disk bookmark structure should be named *_phys_t illumos/illumos-gate@7802d7bf98dec568dadf72286893b1fe5abd8602 MFC after: 2 weeks --- .../opensolaris/lib/libzfs/common/libzfs_pool.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'cddl/contrib/opensolaris/lib/libzfs/common') diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c index c344c94..f6e84f8 100644 --- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c +++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c @@ -22,7 +22,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2011 Nexenta Systems, Inc. All rights reserved. - * Copyright (c) 2013 by Delphix. All rights reserved. + * Copyright (c) 2012, 2014 by Delphix. All rights reserved. * Copyright (c) 2013, Joyent, Inc. All rights reserved. */ @@ -3513,7 +3513,7 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv, static int zbookmark_compare(const void *a, const void *b) { - return (memcmp(a, b, sizeof (zbookmark_t))); + return (memcmp(a, b, sizeof (zbookmark_phys_t))); } /* @@ -3525,7 +3525,7 @@ zpool_get_errlog(zpool_handle_t *zhp, nvlist_t **nverrlistp) { zfs_cmd_t zc = { 0 }; uint64_t count; - zbookmark_t *zb = NULL; + zbookmark_phys_t *zb = NULL; int i; /* @@ -3538,7 +3538,7 @@ zpool_get_errlog(zpool_handle_t *zhp, nvlist_t **nverrlistp) if (count == 0) return (0); if ((zc.zc_nvlist_dst = (uintptr_t)zfs_alloc(zhp->zpool_hdl, - count * sizeof (zbookmark_t))) == (uintptr_t)NULL) + count * sizeof (zbookmark_phys_t))) == (uintptr_t)NULL) return (-1); zc.zc_nvlist_dst_size = count; (void) strcpy(zc.zc_name, zhp->zpool_name); @@ -3547,11 +3547,14 @@ zpool_get_errlog(zpool_handle_t *zhp, nvlist_t **nverrlistp) &zc) != 0) { free((void *)(uintptr_t)zc.zc_nvlist_dst); if (errno == ENOMEM) { + void *dst; + count = zc.zc_nvlist_dst_size; - if ((zc.zc_nvlist_dst = (uintptr_t) - zfs_alloc(zhp->zpool_hdl, count * - sizeof (zbookmark_t))) == (uintptr_t)NULL) + dst = zfs_alloc(zhp->zpool_hdl, count * + sizeof (zbookmark_phys_t)); + if (dst == NULL) return (-1); + zc.zc_nvlist_dst = (uintptr_t)dst; } else { return (-1); } @@ -3567,11 +3570,11 @@ zpool_get_errlog(zpool_handle_t *zhp, nvlist_t **nverrlistp) * _not_ copied as part of the process. So we point the start of our * array appropriate and decrement the total number of elements. */ - zb = ((zbookmark_t *)(uintptr_t)zc.zc_nvlist_dst) + + zb = ((zbookmark_phys_t *)(uintptr_t)zc.zc_nvlist_dst) + zc.zc_nvlist_dst_size; count -= zc.zc_nvlist_dst_size; - qsort(zb, count, sizeof (zbookmark_t), zbookmark_compare); + qsort(zb, count, sizeof (zbookmark_phys_t), zbookmark_compare); verify(nvlist_alloc(nverrlistp, 0, KM_SLEEP) == 0); -- cgit v1.1 From cb7e625917dd35e628dc02b563096d239afaba52 Mon Sep 17 00:00:00 2001 From: delphij Date: Wed, 9 Jul 2014 20:57:42 +0000 Subject: MFV r268453: Diff reduction against Illumos. MFC after: 2 weeks --- .../opensolaris/lib/libzfs/common/libzfs_dataset.c | 16 +++++++--------- .../opensolaris/lib/libzfs/common/libzfs_mount.c | 22 ++++++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) (limited to 'cddl/contrib/opensolaris/lib/libzfs/common') diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c index 11378a2..d7126bf 100644 --- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c +++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c @@ -22,7 +22,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, Joyent, Inc. All rights reserved. - * Copyright (c) 2013 by Delphix. All rights reserved. + * Copyright (c) 2011, 2014 by Delphix. All rights reserved. * Copyright (c) 2012 DEY Storage Systems, Inc. All rights reserved. * Copyright (c) 2011-2012 Pawel Jakub Dawidek . * All rights reserved. @@ -3873,7 +3873,6 @@ zfs_rename(zfs_handle_t *zhp, const char *source, const char *target, strcmp(property, "none") == 0)) { flags.nounmount = B_TRUE; } - if (flags.recurse) { parentname = zfs_strdup(zhp->zfs_hdl, zhp->zfs_name); @@ -3888,8 +3887,7 @@ zfs_rename(zfs_handle_t *zhp, const char *source, const char *target, ret = -1; goto error; } - - } else { + } else if (zhp->zfs_type != ZFS_TYPE_SNAPSHOT) { if ((cl = changelist_gather(zhp, ZFS_PROP_NAME, flags.nounmount ? CL_GATHER_DONT_UNMOUNT : 0, flags.forceunmount ? MS_FORCE : 0)) == NULL) { @@ -3941,23 +3939,23 @@ zfs_rename(zfs_handle_t *zhp, const char *source, const char *target, * On failure, we still want to remount any filesystems that * were previously mounted, so we don't alter the system state. */ - if (!flags.recurse) + if (cl != NULL) (void) changelist_postfix(cl); } else { - if (!flags.recurse) { + if (cl != NULL) { changelist_rename(cl, zfs_get_name(zhp), target); ret = changelist_postfix(cl); } } error: - if (parentname) { + if (parentname != NULL) { free(parentname); } - if (zhrp) { + if (zhrp != NULL) { zfs_close(zhrp); } - if (cl) { + if (cl != NULL) { changelist_free(cl); } return (ret); diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c index b2959dd..f8596ed 100644 --- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c +++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c @@ -21,6 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014 by Delphix. All rights reserved. */ /* @@ -736,16 +737,6 @@ zfs_share_proto(zfs_handle_t *zhp, zfs_share_proto_t *proto) if (!zfs_is_mountable(zhp, mountpoint, sizeof (mountpoint), NULL)) return (0); -#ifdef sun - if ((ret = zfs_init_libshare(hdl, SA_INIT_SHARE_API)) != SA_OK) { - (void) zfs_error_fmt(hdl, EZFS_SHARENFSFAILED, - dgettext(TEXT_DOMAIN, "cannot share '%s': %s"), - zfs_get_name(zhp), _sa_errorstr != NULL ? - _sa_errorstr(ret) : ""); - return (-1); - } -#endif - for (curr_proto = proto; *curr_proto != PROTO_END; curr_proto++) { /* * Return success if there are no share options. @@ -756,6 +747,17 @@ zfs_share_proto(zfs_handle_t *zhp, zfs_share_proto_t *proto) strcmp(shareopts, "off") == 0) continue; +#ifdef illumos + ret = zfs_init_libshare(hdl, SA_INIT_SHARE_API); + if (ret != SA_OK) { + (void) zfs_error_fmt(hdl, EZFS_SHARENFSFAILED, + dgettext(TEXT_DOMAIN, "cannot share '%s': %s"), + zfs_get_name(zhp), _sa_errorstr != NULL ? + _sa_errorstr(ret) : ""); + return (-1); + } +#endif + /* * If the 'zoned' property is set, then zfs_is_mountable() * will have already bailed out if we are in the global zone. -- cgit v1.1 From 0f4faf42cbb855fd26557197bdcea66a237af96c Mon Sep 17 00:00:00 2001 From: delphij Date: Sat, 26 Jul 2014 10:20:48 +0000 Subject: MFV r269010: Import Illumos changes to address the following Illumos issues: 4976 zfs should only avoid writing to a failing non-redundant top-level vdev 4978 ztest fails in get_metaslab_refcount() 4979 extend free space histogram to device and pool 4980 metaslabs should have a fragmentation metric 4981 remove fragmented ops vector from block allocator 4982 space_map object should proactively upgrade when feature is enabled 4984 device selection should use fragmentation metric MFC after: 2 weeks --- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'cddl/contrib/opensolaris/lib/libzfs/common') diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c index f6e84f8..30b2d87 100644 --- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c +++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c @@ -322,6 +322,14 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len, (u_longlong_t)intval); } break; + case ZPOOL_PROP_FRAGMENTATION: + if (intval == UINT64_MAX) { + (void) strlcpy(buf, "-", len); + } else { + (void) snprintf(buf, len, "%llu%%", + (u_longlong_t)intval); + } + break; case ZPOOL_PROP_DEDUPRATIO: (void) snprintf(buf, len, "%llu.%02llux", -- cgit v1.1