Skip to content

Commit ba7a10c

Browse files
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. Signed-off-by: Chunwei Chen <[email protected]>
1 parent 45a7bae commit ba7a10c

39 files changed

+1061
-127
lines changed

cmd/zdb/zdb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ dump_zap(objset_t *os, uint64_t object, void *data, size_t size)
10861086
{
10871087
(void) data, (void) size;
10881088
zap_cursor_t zc;
1089-
zap_attribute_t *attrp = zap_attribute_alloc();
1089+
zap_attribute_t *attrp = zap_attribute_long_alloc();
10901090
void *prop;
10911091
unsigned i;
10921092

@@ -1313,7 +1313,7 @@ dump_zpldir(objset_t *os, uint64_t object, void *data, size_t size)
13131313
{
13141314
(void) data, (void) size;
13151315
zap_cursor_t zc;
1316-
zap_attribute_t *attrp = zap_attribute_alloc();
1316+
zap_attribute_t *attrp = zap_attribute_long_alloc();
13171317
const char *typenames[] = {
13181318
/* 0 */ "not specified",
13191319
/* 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/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
@@ -193,6 +194,7 @@ typedef enum {
193194
ZFS_PROP_SNAPSHOTS_CHANGED,
194195
ZFS_PROP_PREFETCH,
195196
ZFS_PROP_VOLTHREADING,
197+
ZFS_PROP_LONGNAME,
196198
ZFS_NUM_PROPS
197199
} zfs_prop_t;
198200

include/sys/zap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ int zap_count(objset_t *ds, uint64_t zapobj, uint64_t *count);
306306
* match must be exact (ie, same as mask=-1ULL).
307307
*/
308308
int zap_value_search(objset_t *os, uint64_t zapobj,
309-
uint64_t value, uint64_t mask, char *name);
309+
uint64_t value, uint64_t mask, char *name, uint64_t namelen);
310310

311311
/*
312312
* Transfer all the entries from fromobj into intoobj. Only works on
@@ -378,6 +378,7 @@ void zap_fini(void);
378378
* Alloc and free zap_attribute_t.
379379
*/
380380
zap_attribute_t *zap_attribute_alloc(void);
381+
zap_attribute_t *zap_attribute_long_alloc(void);
381382
void zap_attribute_free(zap_attribute_t *attrp);
382383

383384
/*

include/sys/zfs_ioctl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ typedef enum drr_headertype {
124124
* default use of "zfs send" won't encounter the bug mentioned above.
125125
*/
126126
#define DMU_BACKUP_FEATURE_SWITCH_TO_LARGE_BLOCKS (1 << 27)
127-
/* flag #28 is reserved for a Nutanix feature */
127+
#define DMU_BACKUP_FEATURE_LONGNAME (1 << 28)
128128
/*
129129
* flag #29 is the last unused bit. It is reserved to indicate a to-be-designed
130130
* extension to the stream format which will accomodate more feature flags.
@@ -141,7 +141,7 @@ typedef enum drr_headertype {
141141
DMU_BACKUP_FEATURE_COMPRESSED | DMU_BACKUP_FEATURE_LARGE_DNODE | \
142142
DMU_BACKUP_FEATURE_RAW | DMU_BACKUP_FEATURE_HOLDS | \
143143
DMU_BACKUP_FEATURE_REDACTED | DMU_BACKUP_FEATURE_SWITCH_TO_LARGE_BLOCKS | \
144-
DMU_BACKUP_FEATURE_ZSTD)
144+
DMU_BACKUP_FEATURE_ZSTD | DMU_BACKUP_FEATURE_LONGNAME)
145145

146146
/* Are all features in the given flag word currently supported? */
147147
#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
@@ -82,6 +82,7 @@ typedef enum spa_feature {
8282
SPA_FEATURE_AVZ_V2,
8383
SPA_FEATURE_REDACTION_LIST_SPILL,
8484
SPA_FEATURE_RAIDZ_EXPANSION,
85+
SPA_FEATURE_LONGNAME,
8586
SPA_FEATURES
8687
} spa_feature_t;
8788

lib/libnvpair/libnvpair.abi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,11 @@
11561156
<parameter type-id='80f4b756'/>
11571157
<return type-id='95e97e5e'/>
11581158
</function-decl>
1159+
<function-decl name='strchr' visibility='default' binding='global' size-in-bits='64'>
1160+
<parameter type-id='80f4b756'/>
1161+
<parameter type-id='95e97e5e'/>
1162+
<return type-id='26a90f95'/>
1163+
</function-decl>
11591164
<function-decl name='strcspn' visibility='default' binding='global' size-in-bits='64'>
11601165
<parameter type-id='80f4b756'/>
11611166
<parameter type-id='80f4b756'/>
@@ -2536,11 +2541,6 @@
25362541
<parameter type-id='b59d7dce'/>
25372542
<return type-id='95e97e5e'/>
25382543
</function-decl>
2539-
<function-decl name='strchr' visibility='default' binding='global' size-in-bits='64'>
2540-
<parameter type-id='80f4b756'/>
2541-
<parameter type-id='95e97e5e'/>
2542-
<return type-id='26a90f95'/>
2543-
</function-decl>
25442544
<function-decl name='strlen' visibility='default' binding='global' size-in-bits='64'>
25452545
<parameter type-id='80f4b756'/>
25462546
<return type-id='b59d7dce'/>

lib/libuutil/libuutil.abi

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -596,14 +596,11 @@
596596
<var-decl name='prev' type-id='b03eadb4' visibility='default'/>
597597
</data-member>
598598
</class-decl>
599-
<class-decl name='list' size-in-bits='256' is-struct='yes' visibility='default' id='e824dae9'>
599+
<class-decl name='list' size-in-bits='192' is-struct='yes' visibility='default' id='e824dae9'>
600600
<data-member access='public' layout-offset-in-bits='0'>
601-
<var-decl name='list_size' type-id='b59d7dce' visibility='default'/>
602-
</data-member>
603-
<data-member access='public' layout-offset-in-bits='64'>
604601
<var-decl name='list_offset' type-id='b59d7dce' visibility='default'/>
605602
</data-member>
606-
<data-member access='public' layout-offset-in-bits='128'>
603+
<data-member access='public' layout-offset-in-bits='64'>
607604
<var-decl name='list_head' type-id='b0b5e45e' visibility='default'/>
608605
</data-member>
609606
</class-decl>
@@ -800,9 +797,16 @@
800797
<type-decl name='unsigned long int' size-in-bits='64' id='7359adad'/>
801798
</abi-instr>
802799
<abi-instr address-size='64' path='lib/libspl/os/linux/getmntany.c' language='LANG_C99'>
800+
<array-type-def dimensions='1' type-id='38b51b3c' size-in-bits='832' id='02b72c00'>
801+
<subrange length='13' type-id='7359adad' id='487fded1'/>
802+
</array-type-def>
803803
<array-type-def dimensions='1' type-id='03085adc' size-in-bits='192' id='083f8d58'>
804804
<subrange length='3' type-id='7359adad' id='56f209d2'/>
805805
</array-type-def>
806+
<class-decl name='__locale_data' is-struct='yes' visibility='default' is-declaration-only='yes' id='23de8b96'/>
807+
<array-type-def dimensions='1' type-id='80f4b756' size-in-bits='832' id='39e6f84a'>
808+
<subrange length='13' type-id='7359adad' id='487fded1'/>
809+
</array-type-def>
806810
<class-decl name='mnttab' size-in-bits='256' is-struct='yes' visibility='default' id='1b055409'>
807811
<data-member access='public' layout-offset-in-bits='0'>
808812
<var-decl name='mnt_special' type-id='26a90f95' visibility='default'/>
@@ -912,6 +916,25 @@
912916
<typedef-decl name='__blksize_t' type-id='bd54fe1a' id='d3f10a7f'/>
913917
<typedef-decl name='__blkcnt64_t' type-id='bd54fe1a' id='4e711bf1'/>
914918
<typedef-decl name='__syscall_slong_t' type-id='bd54fe1a' id='03085adc'/>
919+
<class-decl name='__locale_struct' size-in-bits='1856' is-struct='yes' visibility='default' id='90cc1ce3'>
920+
<data-member access='public' layout-offset-in-bits='0'>
921+
<var-decl name='__locales' type-id='02b72c00' visibility='default'/>
922+
</data-member>
923+
<data-member access='public' layout-offset-in-bits='832'>
924+
<var-decl name='__ctype_b' type-id='31347b7a' visibility='default'/>
925+
</data-member>
926+
<data-member access='public' layout-offset-in-bits='896'>
927+
<var-decl name='__ctype_tolower' type-id='6d60f45d' visibility='default'/>
928+
</data-member>
929+
<data-member access='public' layout-offset-in-bits='960'>
930+
<var-decl name='__ctype_toupper' type-id='6d60f45d' visibility='default'/>
931+
</data-member>
932+
<data-member access='public' layout-offset-in-bits='1024'>
933+
<var-decl name='__names' type-id='39e6f84a' visibility='default'/>
934+
</data-member>
935+
</class-decl>
936+
<typedef-decl name='__locale_t' type-id='f01e1813' id='b7ac9b5f'/>
937+
<typedef-decl name='locale_t' type-id='b7ac9b5f' id='973a4f8d'/>
915938
<class-decl name='timespec' size-in-bits='128' is-struct='yes' visibility='default' id='a9c79a1f'>
916939
<data-member access='public' layout-offset-in-bits='0'>
917940
<var-decl name='tv_sec' type-id='65eda9c0' visibility='default'/>
@@ -920,12 +943,23 @@
920943
<var-decl name='tv_nsec' type-id='03085adc' visibility='default'/>
921944
</data-member>
922945
</class-decl>
946+
<pointer-type-def type-id='23de8b96' size-in-bits='64' id='38b51b3c'/>
947+
<pointer-type-def type-id='90cc1ce3' size-in-bits='64' id='f01e1813'/>
948+
<qualified-type-def type-id='95e97e5e' const='yes' id='2448a865'/>
949+
<pointer-type-def type-id='2448a865' size-in-bits='64' id='6d60f45d'/>
950+
<qualified-type-def type-id='8efea9e5' const='yes' id='3beb2af4'/>
951+
<pointer-type-def type-id='3beb2af4' size-in-bits='64' id='31347b7a'/>
923952
<pointer-type-def type-id='0c544dc0' size-in-bits='64' id='394fc496'/>
924953
<pointer-type-def type-id='56fe4a37' size-in-bits='64' id='b6b61d2f'/>
925954
<qualified-type-def type-id='b6b61d2f' restrict='yes' id='3cad23cd'/>
926955
<pointer-type-def type-id='1b055409' size-in-bits='64' id='9d424d31'/>
927956
<pointer-type-def type-id='0bbec9cd' size-in-bits='64' id='62f7a03d'/>
928957
<qualified-type-def type-id='62f7a03d' restrict='yes' id='f1cadedf'/>
958+
<class-decl name='__locale_data' is-struct='yes' visibility='default' is-declaration-only='yes' id='23de8b96'/>
959+
<function-decl name='uselocale' visibility='default' binding='global' size-in-bits='64'>
960+
<parameter type-id='973a4f8d'/>
961+
<return type-id='973a4f8d'/>
962+
</function-decl>
929963
<function-decl name='getmntent_r' visibility='default' binding='global' size-in-bits='64'>
930964
<parameter type-id='e75a27e9'/>
931965
<parameter type-id='3cad23cd'/>
@@ -937,8 +971,9 @@
937971
<parameter type-id='822cd80b'/>
938972
<return type-id='95e97e5e'/>
939973
</function-decl>
940-
<function-decl name='strerror' visibility='default' binding='global' size-in-bits='64'>
974+
<function-decl name='strerror_l' visibility='default' binding='global' size-in-bits='64'>
941975
<parameter type-id='95e97e5e'/>
976+
<parameter type-id='973a4f8d'/>
942977
<return type-id='26a90f95'/>
943978
</function-decl>
944979
<function-decl name='__fprintf_chk' visibility='default' binding='global' size-in-bits='64'>

0 commit comments

Comments
 (0)