Skip to content

Commit

Permalink
Use the right device path when relabeling.
Browse files Browse the repository at this point in the history
Currently, zpool_vdev_online() calls zpool_relabel_disk() with a short
partition device name, which is obviously wrong because (1)
zpool_relabel_disk() expects a full, absolute path to use with open()
and (2) efi_write() must be called on an opened disk device, not a
partition device.

With this patch, zpool_relabel_disk() gets called with a full disk
device path. The path is determined using the same algorithm as
zpool_find_vdev().

Signed-off-by: Brian Behlendorf <[email protected]>
Issue #808
  • Loading branch information
dechamps authored and behlendorf committed Jul 12, 2012
1 parent 8adf486 commit 7608bd0
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions lib/libzfs/libzfs_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -2143,13 +2143,10 @@ zpool_vdev_online(zpool_handle_t *zhp, const char *path, int flags,

if (flags & ZFS_ONLINE_EXPAND ||
zpool_get_prop_int(zhp, ZPOOL_PROP_AUTOEXPAND, NULL)) {
char *pathname = NULL;
uint64_t wholedisk = 0;

(void) nvlist_lookup_uint64(tgt, ZPOOL_CONFIG_WHOLE_DISK,
&wholedisk);
verify(nvlist_lookup_string(tgt, ZPOOL_CONFIG_PATH,
&pathname) == 0);

/*
* XXX - L2ARC 1.0 devices can't support expansion.
Expand All @@ -2161,8 +2158,20 @@ zpool_vdev_online(zpool_handle_t *zhp, const char *path, int flags,
}

if (wholedisk) {
pathname += strlen(DISK_ROOT) + 1;
error = zpool_relabel_disk(hdl, pathname, msg);
const char *fullpath = path;
char buf[MAXPATHLEN];

if (path[0] != '/') {
error = zfs_resolve_shortname(path, buf,
sizeof(buf));
if (error != 0)
return (zfs_error(hdl, EZFS_NODEVICE,
msg));

fullpath = buf;
}

error = zpool_relabel_disk(hdl, fullpath, msg);
if (error != 0)
return (error);
}
Expand Down

0 comments on commit 7608bd0

Please sign in to comment.