Skip to content

Commit 20232ec

Browse files
sanjeevbagewadinutanixbehlendorf
authored andcommitted
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 <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Signed-off-by: Chunwei Chen <[email protected]> Closes openzfs#15921
1 parent 3cf2bfa commit 20232ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1240
-407
lines changed

cmd/zdb/zdb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@ dump_zap(objset_t *os, uint64_t object, void *data, size_t size)
11171117
{
11181118
(void) data, (void) size;
11191119
zap_cursor_t zc;
1120-
zap_attribute_t *attrp = zap_attribute_alloc();
1120+
zap_attribute_t *attrp = zap_attribute_long_alloc();
11211121
void *prop;
11221122
unsigned i;
11231123

@@ -1365,7 +1365,7 @@ dump_zpldir(objset_t *os, uint64_t object, void *data, size_t size)
13651365
{
13661366
(void) data, (void) size;
13671367
zap_cursor_t zc;
1368-
zap_attribute_t *attrp = zap_attribute_alloc();
1368+
zap_attribute_t *attrp = zap_attribute_long_alloc();
13691369
const char *typenames[] = {
13701370
/* 0 */ "not specified",
13711371
/* 1 */ "FIFO",

cmd/zhack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ static void
203203
dump_obj(objset_t *os, uint64_t obj, const char *name)
204204
{
205205
zap_cursor_t zc;
206-
zap_attribute_t *za = zap_attribute_alloc();
206+
zap_attribute_t *za = zap_attribute_long_alloc();
207207

208208
(void) printf("%s_obj:\n", name);
209209

include/os/freebsd/zfs/sys/zfs_vfsops_os.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ struct zfsvfs {
8383
boolean_t z_use_sa; /* version allow system attributes */
8484
boolean_t z_xattr_sa; /* allow xattrs to be stores as SA */
8585
boolean_t z_use_namecache; /* make use of FreeBSD name cache */
86+
boolean_t z_longname; /* Dataset supports long names */
8687
uint8_t z_xattr; /* xattr type in use */
8788
uint64_t z_version; /* ZPL version */
8889
uint64_t z_shares_dir; /* hidden shares dir */

include/os/freebsd/zfs/sys/zfs_znode_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ extern void zfs_znode_free(struct znode *);
179179
extern zil_replay_func_t *const zfs_replay_vector[TX_MAX_TYPE];
180180

181181
extern int zfs_znode_parent_and_name(struct znode *zp, struct znode **dzpp,
182-
char *buf);
182+
char *buf, uint64_t buflen);
183183

184184
extern int zfs_rlimit_fsize(off_t fsize);
185185
#ifdef __cplusplus

include/os/linux/zfs/sys/zfs_vfsops_os.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ struct zfsvfs {
118118
boolean_t z_xattr_sa; /* allow xattrs to be stores as SA */
119119
boolean_t z_draining; /* is true when drain is active */
120120
boolean_t z_drain_cancel; /* signal the unlinked drain to stop */
121+
boolean_t z_longname; /* Dataset supports long names */
121122
uint64_t z_version; /* ZPL version */
122123
uint64_t z_shares_dir; /* hidden shares dir */
123124
dataset_kstats_t z_kstat; /* fs kstats */

include/os/linux/zfs/sys/zfs_vnops_os.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ extern int zfs_write_simple(znode_t *zp, const void *data, size_t len,
4444
loff_t pos, size_t *resid);
4545
extern int zfs_lookup(znode_t *dzp, char *nm, znode_t **zpp, int flags,
4646
cred_t *cr, int *direntflags, pathname_t *realpnp);
47+
extern int zfs_get_name(znode_t *dzp, char *name, znode_t *zp);
4748
extern int zfs_create(znode_t *dzp, char *name, vattr_t *vap, int excl,
4849
int mode, znode_t **zpp, cred_t *cr, int flag, vsecattr_t *vsecp,
4950
zidmap_t *mnt_ns);

include/sys/fs/zfs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ typedef enum dmu_objset_type {
8181
* All of these include the terminating NUL byte.
8282
*/
8383
#define ZAP_MAXNAMELEN 256
84+
#define ZAP_MAXNAMELEN_NEW 1024
8485
#define ZAP_MAXVALUELEN (1024 * 8)
8586
#define ZAP_OLDMAXVALUELEN 1024
8687
#define ZFS_MAX_DATASET_NAME_LEN 256
@@ -194,6 +195,7 @@ typedef enum {
194195
ZFS_PROP_PREFETCH,
195196
ZFS_PROP_VOLTHREADING,
196197
ZFS_PROP_DIRECT,
198+
ZFS_PROP_LONGNAME,
197199
ZFS_NUM_PROPS
198200
} zfs_prop_t;
199201

include/sys/zap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ int zap_count(objset_t *ds, uint64_t zapobj, uint64_t *count);
315315
* match must be exact (ie, same as mask=-1ULL).
316316
*/
317317
int zap_value_search(objset_t *os, uint64_t zapobj,
318-
uint64_t value, uint64_t mask, char *name);
318+
uint64_t value, uint64_t mask, char *name, uint64_t namelen);
319319

320320
/*
321321
* Transfer all the entries from fromobj into intoobj. Only works on
@@ -387,6 +387,7 @@ void zap_fini(void);
387387
* Alloc and free zap_attribute_t.
388388
*/
389389
zap_attribute_t *zap_attribute_alloc(void);
390+
zap_attribute_t *zap_attribute_long_alloc(void);
390391
void zap_attribute_free(zap_attribute_t *attrp);
391392

392393
/*

include/sys/zfs_ioctl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ typedef enum drr_headertype {
143143
* default use of "zfs send" won't encounter the bug mentioned above.
144144
*/
145145
#define DMU_BACKUP_FEATURE_SWITCH_TO_LARGE_BLOCKS (1 << 27)
146-
/* flag #28 is reserved for a Nutanix feature */
146+
#define DMU_BACKUP_FEATURE_LONGNAME (1 << 28)
147147

148148
/*
149149
* Mask of all supported backup features
@@ -154,7 +154,7 @@ typedef enum drr_headertype {
154154
DMU_BACKUP_FEATURE_COMPRESSED | DMU_BACKUP_FEATURE_LARGE_DNODE | \
155155
DMU_BACKUP_FEATURE_RAW | DMU_BACKUP_FEATURE_HOLDS | \
156156
DMU_BACKUP_FEATURE_REDACTED | DMU_BACKUP_FEATURE_SWITCH_TO_LARGE_BLOCKS | \
157-
DMU_BACKUP_FEATURE_ZSTD)
157+
DMU_BACKUP_FEATURE_ZSTD | DMU_BACKUP_FEATURE_LONGNAME)
158158

159159
/* Are all features in the given flag word currently supported? */
160160
#define DMU_STREAM_SUPPORTED(x) (!((x) & ~DMU_BACKUP_FEATURE_MASK))

include/zfeature_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ typedef enum spa_feature {
8383
SPA_FEATURE_REDACTION_LIST_SPILL,
8484
SPA_FEATURE_RAIDZ_EXPANSION,
8585
SPA_FEATURE_FAST_DEDUP,
86+
SPA_FEATURE_LONGNAME,
8687
SPA_FEATURES
8788
} spa_feature_t;
8889

0 commit comments

Comments
 (0)