X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fzpool%2Fzpool_vdev.c;h=8c4fadebd14cb9e7d3857dcec67abdbbe96881fd;hb=db49968e5ca7814bf833477f27c148208a835a7d;hp=fe6dd3bbd9ceb497352dcf718086c764d344eddf;hpb=d877ac6bfefaf09f0399888df1fc88bd4b4419d0;p=zfs.git diff --git a/cmd/zpool/zpool_vdev.c b/cmd/zpool/zpool_vdev.c index fe6dd3b..8c4fade 100644 --- a/cmd/zpool/zpool_vdev.c +++ b/cmd/zpool/zpool_vdev.c @@ -188,19 +188,10 @@ check_error(int err) static int check_slice(const char *path, blkid_cache cache, int force, boolean_t isspare) { - struct stat64 statbuf; int err; #ifdef HAVE_LIBBLKID char *value; -#endif /* HAVE_LIBBLKID */ - - if (stat64(path, &statbuf) != 0) { - vdev_error(gettext("cannot stat %s: %s\n"), - path, strerror(errno)); - return (-1); - } -#ifdef HAVE_LIBBLKID /* No valid type detected device is safe to use */ value = blkid_get_tag_value(cache, "TYPE", path); if (value == NULL) @@ -376,9 +367,9 @@ is_whole_disk(const char *path) /* * This may be a shorthand device path or it could be total gibberish. * Check to see if it's a known device in /dev/, /dev/disk/by-id, - * /dev/disk/by-label, /dev/disk/by-path, /dev/disk/by-uuid, or - * /dev/disk/zpool/. As part of this check, see if we've been given - * an entire disk (minus the slice number). + * /dev/disk/by-label, /dev/disk/by-path, /dev/disk/by-uuid, + * /dev/disk/by-vdev, or /dev/disk/zpool/. As part of this check, see + * if we've been given an entire disk (minus the slice number). */ static int is_shorthand_path(const char *arg, char *path, @@ -407,7 +398,7 @@ is_shorthand_path(const char *arg, char *path, * xxx Shorthand for /dev/disk/yyy/xxx */ static nvlist_t * -make_leaf_vdev(const char *arg, uint64_t is_log) +make_leaf_vdev(nvlist_t *props, const char *arg, uint64_t is_log) { char path[MAXPATHLEN]; struct stat64 statbuf; @@ -499,6 +490,19 @@ make_leaf_vdev(const char *arg, uint64_t is_log) verify(nvlist_add_uint64(vdev, ZPOOL_CONFIG_WHOLE_DISK, (uint64_t)wholedisk) == 0); + if (props != NULL) { + uint64_t ashift = 0; + char *value = NULL; + + if (nvlist_lookup_string(props, + zpool_prop_to_name(ZPOOL_PROP_ASHIFT), &value) == 0) + zfs_nicestrtonum(NULL, value, &ashift); + + if (ashift > 0) + verify(nvlist_add_uint64(vdev, ZPOOL_CONFIG_ASHIFT, + ashift) == 0); + } + return (vdev); } @@ -1195,7 +1199,7 @@ is_grouping(const char *type, int *mindev, int *maxdev) * because the program is just going to exit anyway. */ nvlist_t * -construct_spec(int argc, char **argv) +construct_spec(nvlist_t *props, int argc, char **argv) { nvlist_t *nvroot, *nv, **top, **spares, **l2cache; int t, toplevels, mindev, maxdev, nspares, nlogs, nl2cache; @@ -1284,7 +1288,7 @@ construct_spec(int argc, char **argv) children * sizeof (nvlist_t *)); if (child == NULL) zpool_no_memory(); - if ((nv = make_leaf_vdev(argv[c], B_FALSE)) + if ((nv = make_leaf_vdev(props, argv[c], B_FALSE)) == NULL) return (NULL); child[children - 1] = nv; @@ -1340,7 +1344,7 @@ construct_spec(int argc, char **argv) * We have a device. Pass off to make_leaf_vdev() to * construct the appropriate nvlist describing the vdev. */ - if ((nv = make_leaf_vdev(argv[0], is_log)) == NULL) + if ((nv = make_leaf_vdev(props, argv[0], is_log)) == NULL) return (NULL); if (is_log) nlogs++; @@ -1406,7 +1410,7 @@ split_mirror_vdev(zpool_handle_t *zhp, char *newname, nvlist_t *props, uint_t c, children; if (argc > 0) { - if ((newroot = construct_spec(argc, argv)) == NULL) { + if ((newroot = construct_spec(props, argc, argv)) == NULL) { (void) fprintf(stderr, gettext("Unable to build a " "pool from the specified devices\n")); return (NULL); @@ -1456,7 +1460,7 @@ split_mirror_vdev(zpool_handle_t *zhp, char *newname, nvlist_t *props, * added, even if they appear in use. */ nvlist_t * -make_root_vdev(zpool_handle_t *zhp, int force, int check_rep, +make_root_vdev(zpool_handle_t *zhp, nvlist_t *props, int force, int check_rep, boolean_t replacing, boolean_t dryrun, int argc, char **argv) { nvlist_t *newroot; @@ -1468,7 +1472,7 @@ make_root_vdev(zpool_handle_t *zhp, int force, int check_rep, * that we have a valid specification, and that all devices can be * opened. */ - if ((newroot = construct_spec(argc, argv)) == NULL) + if ((newroot = construct_spec(props, argc, argv)) == NULL) return (NULL); if (zhp && ((poolconfig = zpool_get_config(zhp, NULL)) == NULL))