Skip to content

Commit da211a4

Browse files
authored
Refine special_small_blocks property validation
When the special_small_blocks property is being set during a pool create it enforces a limit of 128KiB even if the pool's record size is larger. If the recordsize property is being set during a pool create, then use that value instead of the default SPA_OLD_MAXBLOCKSIZE value. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Don Brady <[email protected]> Closes #13815 Closes #14811
1 parent 5b3b6e9 commit da211a4

File tree

5 files changed

+93
-2
lines changed

5 files changed

+93
-2
lines changed

lib/libzfs/libzfs_dataset.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,7 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,
10341034
nvlist_t *ret;
10351035
int chosen_normal = -1;
10361036
int chosen_utf = -1;
1037+
int set_maxbs = 0;
10371038

10381039
if (nvlist_alloc(&ret, NV_UNIQUE_NAME, 0) != 0) {
10391040
(void) no_memory(hdl);
@@ -1252,12 +1253,17 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,
12521253
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
12531254
goto error;
12541255
}
1256+
/* save the ZFS_PROP_RECORDSIZE during create op */
1257+
if (zpool_hdl == NULL && prop == ZFS_PROP_RECORDSIZE) {
1258+
set_maxbs = intval;
1259+
}
12551260
break;
12561261
}
12571262

12581263
case ZFS_PROP_SPECIAL_SMALL_BLOCKS:
12591264
{
1260-
int maxbs = SPA_OLD_MAXBLOCKSIZE;
1265+
int maxbs =
1266+
set_maxbs == 0 ? SPA_OLD_MAXBLOCKSIZE : set_maxbs;
12611267
char buf[64];
12621268

12631269
if (zpool_hdl != NULL) {

tests/runfiles/common.run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ tests = ['alloc_class_001_pos', 'alloc_class_002_neg', 'alloc_class_003_pos',
3737
'alloc_class_004_pos', 'alloc_class_005_pos', 'alloc_class_006_pos',
3838
'alloc_class_007_pos', 'alloc_class_008_pos', 'alloc_class_009_pos',
3939
'alloc_class_010_pos', 'alloc_class_011_neg', 'alloc_class_012_pos',
40-
'alloc_class_013_pos']
40+
'alloc_class_013_pos', 'alloc_class_014_neg', 'alloc_class_015_pos']
4141
tags = ['functional', 'alloc_class']
4242

4343
[tests/functional/append]

tests/zfs-tests/tests/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,8 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
415415
functional/alloc_class/alloc_class_011_neg.ksh \
416416
functional/alloc_class/alloc_class_012_pos.ksh \
417417
functional/alloc_class/alloc_class_013_pos.ksh \
418+
functional/alloc_class/alloc_class_014_neg.ksh \
419+
functional/alloc_class/alloc_class_015_pos.ksh \
418420
functional/alloc_class/cleanup.ksh \
419421
functional/alloc_class/setup.ksh \
420422
functional/append/file_append.ksh \
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/ksh -p
2+
3+
#
4+
# This file and its contents are supplied under the terms of the
5+
# Common Development and Distribution License ("CDDL"), version 1.0.
6+
# You may only use this file in accordance with the terms of version
7+
# 1.0 of the CDDL.
8+
#
9+
# A full copy of the text of the CDDL should have accompanied this
10+
# source. A copy of the CDDL is also available via the Internet at
11+
# http://www.illumos.org/license/CDDL.
12+
#
13+
14+
. $STF_SUITE/tests/functional/alloc_class/alloc_class.kshlib
15+
16+
#
17+
# DESCRIPTION:
18+
# Setting the special_small_blocks property greater than recordsize fails.
19+
#
20+
21+
verify_runnable "global"
22+
23+
claim="Setting the special_small_blocks property greater than recordsize fails"
24+
25+
log_assert $claim
26+
log_onexit cleanup
27+
log_must disk_setup
28+
29+
for size in 512 4096 32768 131072 524288 1048576
30+
do
31+
let bigger=$size*2
32+
log_mustnot zpool create -O recordsize=$size \
33+
-O special_small_blocks=$bigger \
34+
$TESTPOOL raidz $ZPOOL_DISKS special mirror \
35+
$CLASS_DISK0 $CLASS_DISK1
36+
done
37+
38+
log_pass $claim
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/ksh -p
2+
3+
#
4+
# This file and its contents are supplied under the terms of the
5+
# Common Development and Distribution License ("CDDL"), version 1.0.
6+
# You may only use this file in accordance with the terms of version
7+
# 1.0 of the CDDL.
8+
#
9+
# A full copy of the text of the CDDL should have accompanied this
10+
# source. A copy of the CDDL is also available via the Internet at
11+
# http://www.illumos.org/license/CDDL.
12+
#
13+
14+
. $STF_SUITE/tests/functional/alloc_class/alloc_class.kshlib
15+
16+
#
17+
# DESCRIPTION:
18+
# Can set special_small_blocks property less than or equal to recordsize.
19+
#
20+
21+
verify_runnable "global"
22+
23+
claim="Can set special_small_blocks property less than or equal to recordsize"
24+
25+
log_assert $claim
26+
log_onexit cleanup
27+
log_must disk_setup
28+
29+
for size in 8192 32768 131072 524288 1048576
30+
do
31+
let smaller=$size/2
32+
log_must zpool create -O recordsize=$size \
33+
-O special_small_blocks=$smaller \
34+
$TESTPOOL raidz $ZPOOL_DISKS special mirror \
35+
$CLASS_DISK0 $CLASS_DISK1
36+
log_must zpool destroy -f "$TESTPOOL"
37+
38+
log_must zpool create -O recordsize=$size \
39+
-O special_small_blocks=$size \
40+
$TESTPOOL raidz $ZPOOL_DISKS special mirror \
41+
$CLASS_DISK0 $CLASS_DISK1
42+
log_must zpool destroy -f "$TESTPOOL"
43+
done
44+
45+
log_pass $claim

0 commit comments

Comments
 (0)