Skip to content

Commit 3af56fd

Browse files
nedbassbehlendorf
authored andcommitted
Honor xattr=sa dataset property
ZFS incorrectly uses directory-based extended attributes even when xattr=sa is specified as a dataset property or mount option. Support to honor temporary mount options including "xattr" was added in commit 0282c41. There are two issues with the mount option handling: * Libzfs has historically included "xattr" in its list of default mount options. This overrides the dataset property, so the dataset is always configured to use directory-based xattrs even when the xattr dataset property is set to off or sa. Address this by removing "xattr" from the set of default mount options in libzfs. * There was no way to enable system attribute-based extended attributes using temporary mount options. Add the mount options "saxattr" and "dirxattr" which enable the xattr behavior their names suggest. This approach has the advantages of mirroring the valid xattr dataset property values and following existing conventions for mount option names. Signed-off-by: Ned Bass <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #3787
1 parent 66aad10 commit 3af56fd

File tree

5 files changed

+28
-8
lines changed

5 files changed

+28
-8
lines changed

include/sys/mntent.h

+2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@
8888
#define MNTOPT_LOUD "loud" /* verbose mount */
8989
#define MNTOPT_BIND "bind" /* remount part of a tree */
9090
#define MNTOPT_RBIND "rbind" /* include subtrees */
91+
#define MNTOPT_DIRXATTR "dirxattr" /* enable directory xattrs */
92+
#define MNTOPT_SAXATTR "saxattr" /* enable system-attribute xattrs */
9193
#define MNTOPT_XATTR "xattr" /* enable extended attributes */
9294
#define MNTOPT_NOXATTR "noxattr" /* disable extended attributes */
9395
#define MNTOPT_COMMENT "comment" /* comment */

include/sys/zfs_vfsops.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ struct znode;
4444
typedef struct zfs_mntopts {
4545
char *z_osname; /* Objset name */
4646
char *z_mntpoint; /* Primary mount point */
47+
uint64_t z_xattr;
4748
boolean_t z_readonly;
4849
boolean_t z_do_readonly;
4950
boolean_t z_setuid;
@@ -52,7 +53,6 @@ typedef struct zfs_mntopts {
5253
boolean_t z_do_exec;
5354
boolean_t z_devices;
5455
boolean_t z_do_devices;
55-
boolean_t z_xattr;
5656
boolean_t z_do_xattr;
5757
boolean_t z_atime;
5858
boolean_t z_do_atime;

lib/libzfs/libzfs_mount.c

-2
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,6 @@ zfs_add_options(zfs_handle_t *zhp, char *options, int len)
371371
ZFS_PROP_READONLY, MNTOPT_RO, MNTOPT_RW);
372372
error = error ? error : zfs_add_option(zhp, options, len,
373373
ZFS_PROP_SETUID, MNTOPT_SETUID, MNTOPT_NOSETUID);
374-
error = error ? error : zfs_add_option(zhp, options, len,
375-
ZFS_PROP_XATTR, MNTOPT_XATTR, MNTOPT_NOXATTR);
376374
error = error ? error : zfs_add_option(zhp, options, len,
377375
ZFS_PROP_NBMAND, MNTOPT_NBMAND, MNTOPT_NONBMAND);
378376

man/man8/mount.zfs.8

+11-3
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ under that mountpoint.
8383
This flag sets the SELinux context for the filesytem being mounted.
8484
.TP
8585
.BI "\-o defcontext"
86-
This flag sets the SELinux context for unlabled files.
86+
This flag sets the SELinux context for unlabeled files.
8787
.TP
8888
.BI "\-o rootcontext"
8989
This flag sets the SELinux context for the root inode of the filesystem.
@@ -97,8 +97,16 @@ has an entry in the /etc/fstab file.
9797
This private flag disables extended attributes.
9898
.TP
9999
.BI "\-o xattr
100-
This private flag enables extended attributes and, if appropriate,
101-
adds a ZFS context to the selinux system policy.
100+
This private flag enables directory-based extended attributes and, if
101+
appropriate, adds a ZFS context to the selinux system policy.
102+
.TP
103+
.BI "\-o saxattr
104+
This private flag enables system attributed-based extended attributes and, if
105+
appropriate, adds a ZFS context to the selinux system policy.
106+
.TP
107+
.BI "\-o dirxattr
108+
Equivalent to
109+
.BR xattr .
102110
.TP
103111
.BI "\-o zfsutil"
104112
This private flag indicates that

module/zfs/zpl_super.c

+14-2
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ enum {
193193
TOKEN_NOEXEC,
194194
TOKEN_DEVICES,
195195
TOKEN_NODEVICES,
196+
TOKEN_DIRXATTR,
197+
TOKEN_SAXATTR,
196198
TOKEN_XATTR,
197199
TOKEN_NOXATTR,
198200
TOKEN_ATIME,
@@ -214,6 +216,8 @@ static const match_table_t zpl_tokens = {
214216
{ TOKEN_NOEXEC, MNTOPT_NOEXEC },
215217
{ TOKEN_DEVICES, MNTOPT_DEVICES },
216218
{ TOKEN_NODEVICES, MNTOPT_NODEVICES },
219+
{ TOKEN_DIRXATTR, MNTOPT_DIRXATTR },
220+
{ TOKEN_SAXATTR, MNTOPT_SAXATTR },
217221
{ TOKEN_XATTR, MNTOPT_XATTR },
218222
{ TOKEN_NOXATTR, MNTOPT_NOXATTR },
219223
{ TOKEN_ATIME, MNTOPT_ATIME },
@@ -262,12 +266,20 @@ zpl_parse_option(char *option, int token, substring_t *args, zfs_mntopts_t *zmo)
262266
zmo->z_devices = B_FALSE;
263267
zmo->z_do_devices = B_TRUE;
264268
break;
269+
case TOKEN_DIRXATTR:
270+
zmo->z_xattr = ZFS_XATTR_DIR;
271+
zmo->z_do_xattr = B_TRUE;
272+
break;
273+
case TOKEN_SAXATTR:
274+
zmo->z_xattr = ZFS_XATTR_SA;
275+
zmo->z_do_xattr = B_TRUE;
276+
break;
265277
case TOKEN_XATTR:
266-
zmo->z_xattr = B_TRUE;
278+
zmo->z_xattr = ZFS_XATTR_DIR;
267279
zmo->z_do_xattr = B_TRUE;
268280
break;
269281
case TOKEN_NOXATTR:
270-
zmo->z_xattr = B_FALSE;
282+
zmo->z_xattr = ZFS_XATTR_OFF;
271283
zmo->z_do_xattr = B_TRUE;
272284
break;
273285
case TOKEN_ATIME:

0 commit comments

Comments
 (0)