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:
+12
-2
@@ -1345,8 +1345,15 @@ vdev_open(vdev_t *vd)
|
||||
*/
|
||||
vd->vdev_asize = asize;
|
||||
vd->vdev_max_asize = max_asize;
|
||||
if (vd->vdev_ashift == 0)
|
||||
vd->vdev_ashift = ashift;
|
||||
if (vd->vdev_ashift == 0) {
|
||||
vd->vdev_ashift = ashift; /* use detected value */
|
||||
}
|
||||
if (vd->vdev_ashift != 0 && (vd->vdev_ashift < ASHIFT_MIN ||
|
||||
vd->vdev_ashift > ASHIFT_MAX)) {
|
||||
vdev_set_state(vd, B_TRUE, VDEV_STATE_CANT_OPEN,
|
||||
VDEV_AUX_BAD_ASHIFT);
|
||||
return (SET_ERROR(EDOM));
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Detect if the alignment requirement has increased.
|
||||
@@ -3487,6 +3494,9 @@ vdev_set_state(vdev_t *vd, boolean_t isopen, vdev_state_t state, vdev_aux_t aux)
|
||||
case VDEV_AUX_BAD_LABEL:
|
||||
class = FM_EREPORT_ZFS_DEVICE_BAD_LABEL;
|
||||
break;
|
||||
case VDEV_AUX_BAD_ASHIFT:
|
||||
class = FM_EREPORT_ZFS_DEVICE_BAD_ASHIFT;
|
||||
break;
|
||||
default:
|
||||
class = FM_EREPORT_ZFS_DEVICE_UNKNOWN;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user