mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
Check ashift validity in 'zpool add'
df83110 added the ability to specify a custom "ashift" value from the command
line in 'zpool add' and 'zpool attach'. This commit adds additional checks to
the provided ashift to prevent invalid values from being used, which could
result in disastrous consequences for the whole pool.
Additionally provide ASHIFT_MAX and ASHIFT_MIN definitions in spa.h.
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
Closes #5878
This commit is contained in:
@@ -732,7 +732,8 @@ typedef enum vdev_aux {
|
||||
VDEV_AUX_IO_FAILURE, /* experienced I/O failure */
|
||||
VDEV_AUX_BAD_LOG, /* cannot read log chain(s) */
|
||||
VDEV_AUX_EXTERNAL, /* external diagnosis */
|
||||
VDEV_AUX_SPLIT_POOL /* vdev was split off into another pool */
|
||||
VDEV_AUX_SPLIT_POOL, /* vdev was split off into another pool */
|
||||
VDEV_AUX_BAD_ASHIFT /* vdev ashift is invalid */
|
||||
} vdev_aux_t;
|
||||
|
||||
/*
|
||||
|
||||
@@ -121,6 +121,17 @@ _NOTE(CONSTCOND) } while (0)
|
||||
#define SPA_OLD_MAXBLOCKSIZE (1ULL << SPA_OLD_MAXBLOCKSHIFT)
|
||||
#define SPA_MAXBLOCKSIZE (1ULL << SPA_MAXBLOCKSHIFT)
|
||||
|
||||
/*
|
||||
* Alignment Shift (ashift) is an immutable, internal top-level vdev property
|
||||
* which can only be set at vdev creation time. Physical writes are always done
|
||||
* according to it, which makes 2^ashift the smallest possible IO on a vdev.
|
||||
*
|
||||
* We currently allow values ranging from 512 bytes (2^9 = 512) to 8 KiB
|
||||
* (2^13 = 8,192).
|
||||
*/
|
||||
#define ASHIFT_MIN 9
|
||||
#define ASHIFT_MAX 13
|
||||
|
||||
/*
|
||||
* Size of block to hold the configuration data (a packed nvlist)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user