Skip to content

Commit

Permalink
libzfs: FreeBSD doesn't resize partitions for you
Browse files Browse the repository at this point in the history
This code can be failure prone on FreeBSD, where zfsd will pass a guid
as the vdev path to online.  The guid causes zfs_resolve_shortname to
fail because it expects a path.  We can just skip the whole ordeal.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@ixsystems.com>
Closes openzfs#12083
  • Loading branch information
Ryan Moeller authored and andrewc12 committed Aug 30, 2022
1 parent e3e9e47 commit 3990f72
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/libzfs/libzfs_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -3137,11 +3137,9 @@ zpool_vdev_online(zpool_handle_t *zhp, const char *path, int flags,
{
zfs_cmd_t zc = {"\0"};
char msg[1024];
char *pathname;
nvlist_t *tgt;
boolean_t avail_spare, l2cache, islog;
libzfs_handle_t *hdl = zhp->zpool_hdl;
int error;

if (flags & ZFS_ONLINE_EXPAND) {
(void) snprintf(msg, sizeof (msg),
Expand All @@ -3161,6 +3159,8 @@ zpool_vdev_online(zpool_handle_t *zhp, const char *path, int flags,
if (avail_spare)
return (zfs_error(hdl, EZFS_ISSPARE, msg));

#ifndef __FreeBSD__
char *pathname;
if ((flags & ZFS_ONLINE_EXPAND ||
zpool_get_prop_int(zhp, ZPOOL_PROP_AUTOEXPAND, NULL)) &&
nvlist_lookup_string(tgt, ZPOOL_CONFIG_PATH, &pathname) == 0) {
Expand All @@ -3181,6 +3181,7 @@ zpool_vdev_online(zpool_handle_t *zhp, const char *path, int flags,
if (wholedisk) {
const char *fullpath = path;
char buf[MAXPATHLEN];
int error;

if (path[0] != '/') {
error = zfs_resolve_shortname(path, buf,
Expand All @@ -3197,6 +3198,7 @@ zpool_vdev_online(zpool_handle_t *zhp, const char *path, int flags,
return (error);
}
}
#endif

zc.zc_cookie = VDEV_STATE_ONLINE;
zc.zc_obj = flags;
Expand Down

0 comments on commit 3990f72

Please sign in to comment.