Support for longnames for files/directories (Linux part)

This patch adds the ability for zfs to support file/dir name up to 1023
bytes. This number is chosen so we can support up to 255 4-byte
characters. This new feature is represented by the new feature flag
feature@longname.

A new dataset property "longname" is also introduced to toggle longname
support for each dataset individually. This property can be disabled,
even if it contains longname files. In such case, new file cannot be
created with longname but existing longname files can still be looked
up.

Note that, to my knowledge native Linux filesystems don't support name
longer than 255 bytes. So there might be programs not able to work with
longname.

Note that NFS server may needs to use exportfs_get_name to reconnect
dentries, and the buffer being passed is limit to NAME_MAX+1 (256). So
NFS may not work when longname is enabled.

Note, FreeBSD vfs layer imposes a limit of 255 name lengh, so even
though we add code to support it here, it won't actually work.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Chunwei Chen <david.chen@nutanix.com>
Closes #15921
This commit is contained in:
Sanjeev Bagewadi
2021-06-18 08:55:01 +00:00
committed by Brian Behlendorf
parent 3cf2bfa570
commit 20232ecfaa
41 changed files with 1239 additions and 406 deletions
+35
View File
@@ -2594,6 +2594,41 @@ zfs_prop_set_special(const char *dsname, zprop_source_t source,
}
break;
}
case ZFS_PROP_LONGNAME:
{
zfsvfs_t *zfsvfs;
/*
* Ignore the checks if the property is being applied as part of
* 'zfs receive'. Because, we already check if the local pool
* has SPA_FEATURE_LONGNAME enabled in dmu_recv_begin_check().
*/
if (source == ZPROP_SRC_RECEIVED) {
cmn_err(CE_NOTE, "Skipping ZFS_PROP_LONGNAME checks "
"for dsname=%s\n", dsname);
err = -1;
break;
}
if ((err = zfsvfs_hold(dsname, FTAG, &zfsvfs, B_FALSE)) != 0) {
cmn_err(CE_WARN, "%s:%d Failed to hold for dsname=%s "
"err=%d\n", __FILE__, __LINE__, dsname, err);
break;
}
if (!spa_feature_is_enabled(zfsvfs->z_os->os_spa,
SPA_FEATURE_LONGNAME)) {
err = ENOTSUP;
} else {
/*
* Set err to -1 to force the zfs_set_prop_nvlist code
* down the default path to set the value in the nvlist.
*/
err = -1;
}
zfsvfs_rele(zfsvfs, FTAG);
break;
}
default:
err = -1;
}