aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Swanson <[email protected]>2021-10-29 16:59:18 -0700
committerGitHub <[email protected]>2021-10-29 16:59:18 -0700
commit321c1b6f3974ee46de75630824ace6cd205357c2 (patch)
tree03eeff4b4b27f0f08316676cbbefbe5bcfbbd390
parent4d1a3ba6eda1edf46e973c22d29f7abcaa751292 (diff)
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 <[email protected]> Signed-off-by: Mike Swanson <[email protected]> Closes #11892 Closes #12038
-rw-r--r--lib/libzfs/libzfs_dataset.c9
-rwxr-xr-xtests/zfs-tests/tests/functional/casenorm/norm_all_values.ksh11
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c
index fc7290314..5836587d2 100644
--- a/lib/libzfs/libzfs_dataset.c
+++ b/lib/libzfs/libzfs_dataset.c
@@ -1562,6 +1562,9 @@ badlabel:
*
* If normalization was chosen, but rejecting non-UTF8 names
* was explicitly not chosen, it is an error.
+ *
+ * If utf8only was turned off, but the parent has normalization,
+ * turn off normalization.
*/
if (chosen_normal > 0 && chosen_utf < 0) {
if (nvlist_add_uint64(ret,
@@ -1575,6 +1578,12 @@ badlabel:
zfs_prop_to_name(ZFS_PROP_UTF8ONLY));
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
goto error;
+ } else if (chosen_normal < 0 && chosen_utf == 0) {
+ if (nvlist_add_uint64(ret,
+ zfs_prop_to_name(ZFS_PROP_NORMALIZE), 0) != 0) {
+ (void) no_memory(hdl);
+ goto error;
+ }
}
return (ret);
diff --git a/tests/zfs-tests/tests/functional/casenorm/norm_all_values.ksh b/tests/zfs-tests/tests/functional/casenorm/norm_all_values.ksh
index 87779a710..cae15ebc4 100755
--- a/tests/zfs-tests/tests/functional/casenorm/norm_all_values.ksh
+++ b/tests/zfs-tests/tests/functional/casenorm/norm_all_values.ksh
@@ -58,4 +58,15 @@ for form in formC formD formKC formKD; do
destroy_testfs
done
+for form in formC formD formKC formKD; do
+ create_testfs "-o normalization=$form"
+ log_must zfs create -o utf8only=off $TESTPOOL/$TESTFS/$TESTSUBFS
+ normalization=$(zfs get -H -o value normalization $TESTPOOL/$TESTFS/$TESTSUBFS)
+ if [[ $normalization != "none" ]]; then
+ log_fail "Turning off utf8only didn't set normalization to none"
+ fi
+ log_must zfs destroy $TESTPOOL/$TESTFS/$TESTSUBFS
+ destroy_testfs
+done
+
log_pass "Can create FS with all supported normalization forms"