From 354d6d9e66fbb4e1e52b6a9e5835e19322b4a027 Mon Sep 17 00:00:00 2001 From: Turbo Fredriksson Date: Fri, 29 May 2015 16:08:09 +0200 Subject: [PATCH] Option to disable automatic EFI partitioning. Sometimes it is desired to not have 'zpool' setup partitioning on devices it uses for the pool. So allow '-o whole_disk={on,off}' option to 'add', 'attach', 'create', 'replace' and 'split' to disable or enable, respectivly, the automatic partitioning. Signed-off-by: Turbo Fredriksson turbo@bayour.com Closes #94 Closes #719 Closes #1162 Closes #3452 --- cmd/zpool/zpool_main.c | 6 ++++-- cmd/zpool/zpool_vdev.c | 34 ++++++++++++++++++++++++++++++++++ include/sys/fs/zfs.h | 1 + man/man8/zpool.8 | 13 +++++++++++++ module/zcommon/zpool_prop.c | 3 +++ 5 files changed, 55 insertions(+), 2 deletions(-) diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index 5c28e8bb13f7..b0442ea1c263 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -544,7 +544,8 @@ zpool_do_add(int argc, char **argv) *propval = '\0'; propval++; - if ((strcmp(optarg, ZPOOL_CONFIG_ASHIFT) != 0) || + if (((strcmp(optarg, ZPOOL_CONFIG_ASHIFT) != 0) && + (strcmp(optarg, ZPOOL_CONFIG_WHOLE_DISK) != 0))|| (add_prop_list(optarg, propval, &props, B_TRUE))) usage(B_FALSE); break; @@ -3334,7 +3335,8 @@ zpool_do_attach_or_replace(int argc, char **argv, int replacing) *propval = '\0'; propval++; - if ((strcmp(optarg, ZPOOL_CONFIG_ASHIFT) != 0) || + if (((strcmp(optarg, ZPOOL_CONFIG_ASHIFT) != 0) && + (strcmp(optarg, ZPOOL_CONFIG_WHOLE_DISK) != 0))|| (add_prop_list(optarg, propval, &props, B_TRUE))) usage(B_FALSE); break; diff --git a/cmd/zpool/zpool_vdev.c b/cmd/zpool/zpool_vdev.c index cae91142644b..37ca10b4e4dd 100644 --- a/cmd/zpool/zpool_vdev.c +++ b/cmd/zpool/zpool_vdev.c @@ -716,6 +716,40 @@ make_leaf_vdev(nvlist_t *props, const char *arg, uint64_t is_log) return (NULL); } + if (wholedisk && props != NULL) { + char *value = NULL; + + if (nvlist_lookup_string(props, ZPOOL_CONFIG_WHOLE_DISK, + &value) == 0) { + /* + * There's two meanings of 'whole_disk'. + * 1. ZFS/ZoL 'owns' the whole disk (it's not used + * by anyone else), so we is allowed to change the + * elevator, I/O scheduler etc. + * This is what we would get if whole_disk != on. + * + * 2. The litteral one, we want the whole disk, no + * partitions etc. + */ + if (strcmp(value, "on") == 0) { + /* + * This is somewhat counter-intuitive. + * We've asked for whole disk, but we're + * setting it to false. That's because when + * it's false, later checks won't partition + * the device, which is what we ACTUALLY + * wanted. + * + * In this case, we meant point two, hence + * changing the previously discovered true + * value to false instead to avoid the + * automatic partitioning. + */ + wholedisk = B_FALSE; + } + } + } + /* * Finally, we have the complete device or file, and we know that it is * acceptable to use. Construct the nvlist to describe this vdev. All diff --git a/include/sys/fs/zfs.h b/include/sys/fs/zfs.h index 4da144c724ab..7551289789a4 100644 --- a/include/sys/fs/zfs.h +++ b/include/sys/fs/zfs.h @@ -202,6 +202,7 @@ typedef enum { ZPOOL_PROP_LEAKED, ZPOOL_PROP_MAXBLOCKSIZE, ZPOOL_PROP_TNAME, + ZPOOL_PROP_WHOLE_DISK, ZPOOL_NUM_PROPS } zpool_prop_t; diff --git a/man/man8/zpool.8 b/man/man8/zpool.8 index 74d7461ce067..485addd5fb83 100644 --- a/man/man8/zpool.8 +++ b/man/man8/zpool.8 @@ -595,6 +595,19 @@ Information about unsupported features that are enabled on the pool. See Amount of storage space used within the pool. .RE +.sp +.ne 2 +.mk +.na +\fB\fBwhole_disk\fR\fR +.ad +.RS 20n +.rt +Do not partition the device(s) used to create the pool with. Normally, \fBzpool create\fR uses a GPT partition table on the device(s) and creates two partitions. One for the data and one small, about 9MB, which is used as a 'buffer' in case the device needs to be replaced and it's replaced with a smaller one. +.sp +Can only be set at pool creation time. +.RE + .sp .LP The space usage properties report actual physical space available to the storage pool. The physical space can be different from the total amount of space that any contained datasets can actually use. The amount of space used in a \fBraidz\fR configuration depends on the characteristics of the data being written. In addition, \fBZFS\fR reserves some space for internal accounting that the \fBzfs\fR(8) command takes into account, but the \fBzpool\fR command does not. For non-full pools of a reasonable size, these effects should be invisible. For small pools, or pools that are close to being completely full, these discrepancies may become more noticeable. diff --git a/module/zcommon/zpool_prop.c b/module/zcommon/zpool_prop.c index 910c56dcc2a9..d0ff993d0825 100644 --- a/module/zcommon/zpool_prop.c +++ b/module/zcommon/zpool_prop.c @@ -122,6 +122,9 @@ zpool_prop_init(void) PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "EXPAND", boolean_table); zprop_register_index(ZPOOL_PROP_READONLY, "readonly", 0, PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "RDONLY", boolean_table); + zprop_register_index(ZPOOL_PROP_WHOLE_DISK, "whole_disk", 1, + PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "WHOLEDISK", + boolean_table); /* default index properties */ zprop_register_index(ZPOOL_PROP_FAILUREMODE, "failmode",