bugfix: zpool online might fail when disk suffix start with "c[0-9]"

Peter Xu xzpeter at gmail.com
Fri Jan 16 03:52:32 UTC 2015


Hi, all,

Found one bug for libzfs that some disk could not be onlined using its
physical path. I met the problem once when I try to online disk:

gptid/c6cde092-504b-11e4-ba52-c45444453598

This is a partition of GPT disk, and zpool returned with the error that no
such device found.

I tried online it using VDEV ID, and it worked.

The problem is, libzfs hacked vdev_to_nvlist_iter() to take special care
for ZPOOL_CONFIG_PATH searches (also, it seems that vdev->wholedisk is used
for this matter). This should be for Solaris but not Freebsd. BSD should
not need these hacks at all. Fixing this bug by commenting out the hacking
code path.

diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
index df8317f..e16f5c6 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
@@ -1969,6 +1969,7 @@ vdev_to_nvlist_iter(nvlist_t *nv, nvlist_t *search,
boolean_t *avail_spare,
                if (nvlist_lookup_string(nv, srchkey, &val) != 0)
                        break;

+#ifdef sun
                /*
                 * Search for the requested value. Special cases:
                 *
@@ -2018,6 +2019,9 @@ vdev_to_nvlist_iter(nvlist_t *nv, nvlist_t *search,
boolean_t *avail_spare,
                                break;
                        }
                } else if (strcmp(srchkey, ZPOOL_CONFIG_TYPE) == 0 && val) {
+#else
+               if (strcmp(srchkey, ZPOOL_CONFIG_TYPE) == 0 && val) {
+#endif
                        char *type, *idx, *end, *p;
                        uint64_t id, vdev_id;

I am one of Freebsd user (also ZFS user). Just want to contribute something
back. Hope I am posting to the write place.

Peter


More information about the freebsd-fs mailing list