Increase allowed 'special_small_blocks' maximum value

There may be circumstances where it's desirable that all blocks
in a specified dataset be stored on the special device.  Relax
the artificial 128K limit and allow the special_small_blocks
property to be set up to 1M.  When blocks >1MB have been enabled
via the zfs_max_recordsize module option, this limit is increased
accordingly.

Reviewed-by: Don Brady <don.brady@delphix.com>
Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9131
Closes #9355
This commit is contained in:
Brian Behlendorf 2019-12-03 09:58:03 -08:00 committed by Tony Hutter
parent 85204e30dd
commit 9cf46ddedc
4 changed files with 17 additions and 7 deletions

View File

@ -1230,12 +1230,19 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,
} }
case ZFS_PROP_SPECIAL_SMALL_BLOCKS: case ZFS_PROP_SPECIAL_SMALL_BLOCKS:
{
int maxbs = SPA_OLD_MAXBLOCKSIZE;
char buf[64];
if (zpool_hdl != NULL) { if (zpool_hdl != NULL) {
char state[64] = ""; char state[64] = "";
maxbs = zpool_get_prop_int(zpool_hdl,
ZPOOL_PROP_MAXBLOCKSIZE, NULL);
/* /*
* Issue a warning but do not fail so that * Issue a warning but do not fail so that
* tests for setable properties succeed. * tests for settable properties succeed.
*/ */
if (zpool_prop_get_feature(zpool_hdl, if (zpool_prop_get_feature(zpool_hdl,
"feature@allocation_classes", state, "feature@allocation_classes", state,
@ -1248,15 +1255,17 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,
} }
if (intval != 0 && if (intval != 0 &&
(intval < SPA_MINBLOCKSIZE || (intval < SPA_MINBLOCKSIZE ||
intval > SPA_OLD_MAXBLOCKSIZE || !ISP2(intval))) { intval > maxbs || !ISP2(intval))) {
zfs_nicebytes(maxbs, buf, sizeof (buf));
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"invalid '%s=%d' property: must be zero or " "invalid '%s=%d' property: must be zero or "
"a power of 2 from 512B to 128K"), propname, "a power of 2 from 512B to %s"), propname,
intval); intval, buf);
(void) zfs_error(hdl, EZFS_BADPROP, errbuf); (void) zfs_error(hdl, EZFS_BADPROP, errbuf);
goto error; goto error;
} }
break; break;
}
case ZFS_PROP_MLSLABEL: case ZFS_PROP_MLSLABEL:
{ {

View File

@ -1545,7 +1545,7 @@ This value represents the threshold block size for including small file
blocks into the special allocation class. Blocks smaller than or equal to this blocks into the special allocation class. Blocks smaller than or equal to this
value will be assigned to the special allocation class while greater blocks value will be assigned to the special allocation class while greater blocks
will be assigned to the regular class. Valid values are zero or a power of two will be assigned to the regular class. Valid values are zero or a power of two
from 512B up to 128K. The default size is 0 which means no small file blocks from 512B up to 1M. The default size is 0 which means no small file blocks
will be allocated in the special class. will be allocated in the special class.
.Pp .Pp
Before setting this property, a special class vdev must be added to the Before setting this property, a special class vdev must be added to the

View File

@ -540,7 +540,7 @@ zfs_prop_init(void)
ZFS_TYPE_FILESYSTEM, "512 to 1M, power of 2", "RECSIZE"); ZFS_TYPE_FILESYSTEM, "512 to 1M, power of 2", "RECSIZE");
zprop_register_number(ZFS_PROP_SPECIAL_SMALL_BLOCKS, zprop_register_number(ZFS_PROP_SPECIAL_SMALL_BLOCKS,
"special_small_blocks", 0, PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "special_small_blocks", 0, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
"zero or 512 to 128K, power of 2", "SPECIAL_SMALL_BLOCKS"); "zero or 512 to 1M, power of 2", "SPECIAL_SMALL_BLOCKS");
/* hidden properties */ /* hidden properties */
zprop_register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER, zprop_register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER,

View File

@ -21,6 +21,7 @@
# #
# DESCRIPTION: # DESCRIPTION:
# Setting the special_small_blocks property to invalid values fails. # Setting the special_small_blocks property to invalid values fails.
# Powers of two from 512 to 1M are allowed.
# #
verify_runnable "global" verify_runnable "global"
@ -34,7 +35,7 @@ log_must disk_setup
log_must zpool create $TESTPOOL raidz $ZPOOL_DISKS special mirror \ log_must zpool create $TESTPOOL raidz $ZPOOL_DISKS special mirror \
$CLASS_DISK0 $CLASS_DISK1 $CLASS_DISK0 $CLASS_DISK1
for value in 256 1025 262144 for value in 256 1025 2097152
do do
log_mustnot zfs set special_small_blocks=$value $TESTPOOL log_mustnot zfs set special_small_blocks=$value $TESTPOOL
done done