Skip to content

Commit

Permalink
Option to disable automatic EFI partitioning.
Browse files Browse the repository at this point in the history
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 [email protected]
Closes #94
Closes #719
Closes #1162
Closes #3452
  • Loading branch information
FransUrbo committed Sep 8, 2015
1 parent 3b36f83 commit aea9f90
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmd/zpool/zpool_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,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;
Expand Down Expand Up @@ -3352,7 +3353,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;
Expand Down
34 changes: 34 additions & 0 deletions cmd/zpool/zpool_vdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,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
Expand Down
1 change: 1 addition & 0 deletions include/sys/fs/zfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
13 changes: 13 additions & 0 deletions man/man8/zpool.8
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,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.
Expand Down
3 changes: 3 additions & 0 deletions module/zcommon/zpool_prop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit aea9f90

Please sign in to comment.