Skip to content

Commit 321c1b6

Browse files
authored
Disable normalization implicitly when setting "utf8only=off"
When a parent dataset has normalization set to any value other than "none", and a file system is created with the property "utf8only=off", implicitly also set "normalization=none" instead of overriding the desire for a non-UTF8 enforcing file system. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Mike Swanson <mikeonthecomputer@gmail.com> Closes #11892 Closes #12038
1 parent 4d1a3ba commit 321c1b6

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/libzfs/libzfs_dataset.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,6 +1562,9 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,
15621562
*
15631563
* If normalization was chosen, but rejecting non-UTF8 names
15641564
* was explicitly not chosen, it is an error.
1565+
*
1566+
* If utf8only was turned off, but the parent has normalization,
1567+
* turn off normalization.
15651568
*/
15661569
if (chosen_normal > 0 && chosen_utf < 0) {
15671570
if (nvlist_add_uint64(ret,
@@ -1575,6 +1578,12 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,
15751578
zfs_prop_to_name(ZFS_PROP_UTF8ONLY));
15761579
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
15771580
goto error;
1581+
} else if (chosen_normal < 0 && chosen_utf == 0) {
1582+
if (nvlist_add_uint64(ret,
1583+
zfs_prop_to_name(ZFS_PROP_NORMALIZE), 0) != 0) {
1584+
(void) no_memory(hdl);
1585+
goto error;
1586+
}
15781587
}
15791588
return (ret);
15801589

tests/zfs-tests/tests/functional/casenorm/norm_all_values.ksh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,15 @@ for form in formC formD formKC formKD; do
5858
destroy_testfs
5959
done
6060

61+
for form in formC formD formKC formKD; do
62+
create_testfs "-o normalization=$form"
63+
log_must zfs create -o utf8only=off $TESTPOOL/$TESTFS/$TESTSUBFS
64+
normalization=$(zfs get -H -o value normalization $TESTPOOL/$TESTFS/$TESTSUBFS)
65+
if [[ $normalization != "none" ]]; then
66+
log_fail "Turning off utf8only didn't set normalization to none"
67+
fi
68+
log_must zfs destroy $TESTPOOL/$TESTFS/$TESTSUBFS
69+
destroy_testfs
70+
done
71+
6172
log_pass "Can create FS with all supported normalization forms"

0 commit comments

Comments
 (0)