diff options
author | Yuri Pankov <[email protected]> | 2017-01-13 09:25:15 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2017-04-11 09:54:39 -0700 |
commit | dbb38f660509073f43284c6c745a4449ffd46385 (patch) | |
tree | a980a446a446b1e1d1291010653719f5b21fbf9c /cmd/zpool/zpool_vdev.c | |
parent | 047187c1bd4a893e7a89e8795fa8f4ecc3eb0732 (diff) |
OpenZFS 6865 - want zfs-tests cases for zpool labelclear command
Authored by: Yuri Pankov <[email protected]>
Reviewed by: Matthew Ahrens <[email protected]>
Reviewed by: John Kennedy <[email protected]>
Approved by: Robert Mustacchi <[email protected]>
Reviewed-by: loli10K <[email protected]>
Ported-by: Brian Behlendorf <[email protected]>
Porting Notes:
- Updated 'zpool labelclear' and 'zdb -l' such that they attempt
to find a vdev given solely its short name. This behavior is
consistent with the upstream OpenZFS code and the test cases
depend on it. The actual implementation differs slightly due
to device naming conventions on Linux.
- auto_online_001_pos, auto_replace_001_pos and add-o_ashift
test cases updated to expect failure when no label exists.
- read_efi_label() and zpool_label_disk_check() are read-only
operations and should use O_RDONLY at open time to enforce this.
- zpool_label_disk() and zpool_relabel_disk() write the partition
information using O_DIRECT an fsync() and page cache invalidation
to ensure a consistent view of the device.
- dump_label() in zdb should invalidate the page cache in order
to get the authoritative label from disk.
OpenZFS-issue: https://www.illumos.org/issues/6865
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/c95076c
Closes #5981
Diffstat (limited to 'cmd/zpool/zpool_vdev.c')
-rw-r--r-- | cmd/zpool/zpool_vdev.c | 33 |
1 files changed, 4 insertions, 29 deletions
diff --git a/cmd/zpool/zpool_vdev.c b/cmd/zpool/zpool_vdev.c index f1b27cb51..c96157eff 100644 --- a/cmd/zpool/zpool_vdev.c +++ b/cmd/zpool/zpool_vdev.c @@ -507,31 +507,6 @@ check_device(const char *path, boolean_t force, } /* - * By "whole disk" we mean an entire physical disk (something we can - * label, toggle the write cache on, etc.) as opposed to the full - * capacity of a pseudo-device such as lofi or did. We act as if we - * are labeling the disk, which should be a pretty good test of whether - * it's a viable device or not. Returns B_TRUE if it is and B_FALSE if - * it isn't. - */ -static boolean_t -is_whole_disk(const char *path) -{ - struct dk_gpt *label; - int fd; - - if ((fd = open(path, O_RDONLY|O_DIRECT)) < 0) - return (B_FALSE); - if (efi_alloc_and_init(fd, EFI_NUMPAR, &label) != 0) { - (void) close(fd); - return (B_FALSE); - } - efi_free(label); - (void) close(fd); - return (B_TRUE); -} - -/* * This may be a shorthand device path or it could be total gibberish. * Check to see if it is a known device available in zfs_vdev_paths. * As part of this check, see if we've been given an entire disk @@ -545,7 +520,7 @@ is_shorthand_path(const char *arg, char *path, size_t path_size, error = zfs_resolve_shortname(arg, path, path_size); if (error == 0) { - *wholedisk = is_whole_disk(path); + *wholedisk = zfs_dev_is_whole_disk(path); if (*wholedisk || (stat64(path, statbuf) == 0)) return (0); } @@ -640,7 +615,7 @@ make_leaf_vdev(nvlist_t *props, const char *arg, uint64_t is_log) /* * Complete device or file path. Exact type is determined by * examining the file descriptor afterwards. Symbolic links - * are resolved to their real paths for the is_whole_disk() + * are resolved to their real paths to determine whole disk * and S_ISBLK/S_ISREG type checks. However, we are careful * to store the given path as ZPOOL_CONFIG_PATH to ensure we * can leverage udev's persistent device labels. @@ -651,7 +626,7 @@ make_leaf_vdev(nvlist_t *props, const char *arg, uint64_t is_log) return (NULL); } - wholedisk = is_whole_disk(path); + wholedisk = zfs_dev_is_whole_disk(path); if (!wholedisk && (stat64(path, &statbuf) != 0)) { (void) fprintf(stderr, gettext("cannot open '%s': %s\n"), @@ -659,7 +634,7 @@ make_leaf_vdev(nvlist_t *props, const char *arg, uint64_t is_log) return (NULL); } - /* After is_whole_disk() check restore original passed path */ + /* After whole disk check restore original passed path */ strlcpy(path, arg, sizeof (path)); } else { err = is_shorthand_path(arg, path, sizeof (path), |