Date: Tue, 14 Jun 2011 14:26:46 -0600 From: "Justin T. Gibbs" <gibbs@scsiguy.com> To: fs@FreeBSD.org Subject: [CFR][ZFS] Show removed devices by GUID in zpool output. Message-ID: <4DF7C406.1080903@scsiguy.com>
next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------060201040900000201070407 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit The current behavior of zpool_vdev_name() is to report the vdev path (e.g. /dev/da0) unless a vdev has the ZPOOL_CONFIG_NOT_PRESENT attribute set. This attribute is only set when a vdev is not found during import/mount of a pool. The attached patch also displays a vdev by GUID if it cannot be opened post import or is marked removed (e.g. via a GEOM orphan event). The main motivation for this change is that vdev paths are not unique to a physical leaf vdev. It is easy to get into a situation where you need to "detach /dev/da0" event though da0 is an active member of the same pool in which a "previous da0" was once removed. With zpool_vdev_name() reporting the GUID, the user is equipped to provide an unambiguous command that represents their desired action. -- Justin --------------060201040900000201070407 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0"; name="zpool.diffs" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="zpool.diffs" Index: libzfs_pool.c =================================================================== --- libzfs_pool.c (revision 223089) +++ libzfs_pool.c (working copy) @@ -3082,15 +3082,25 @@ char buf[64]; vdev_stat_t *vs; uint_t vsc; + int have_stats; + int have_path; - if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_NOT_PRESENT, - &value) == 0) { + have_stats = nvlist_lookup_uint64_array(nv, ZPOOL_CONFIG_VDEV_STATS, + (uint64_t **)&vs, &vsc) == 0; + have_path = nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path) == 0; + + /* + * If the device is not currently present, assume it will not + * come back at the same device path. Display the device by GUID. + */ + if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_NOT_PRESENT, &value) == 0 || + have_path && have_stats && vs->vs_state <= VDEV_STATE_CANT_OPEN) { verify(nvlist_lookup_uint64(nv, ZPOOL_CONFIG_GUID, &value) == 0); (void) snprintf(buf, sizeof (buf), "%llu", (u_longlong_t)value); path = buf; - } else if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path) == 0) { + } else if (have_path) { /* * If the device is dead (faulted, offline, etc) then don't @@ -3098,8 +3108,7 @@ * open a misbehaving device, which can have undesirable * effects. */ - if ((nvlist_lookup_uint64_array(nv, ZPOOL_CONFIG_VDEV_STATS, - (uint64_t **)&vs, &vsc) != 0 || + if ((have_stats == 0 || vs->vs_state >= VDEV_STATE_DEGRADED) && zhp != NULL && nvlist_lookup_string(nv, ZPOOL_CONFIG_DEVID, &devid) == 0) { --------------060201040900000201070407--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4DF7C406.1080903>