Skip to content

Commit

Permalink
Honor xattr=sa dataset property
Browse files Browse the repository at this point in the history
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 with no value specified. Omitting the value implies xattr=on or
  directory-based xattrs, so the dataset is configured to use
  directory-based xattrs regardless of the xattr dataset property value.
  Address this by removing "xattr" from the list of default mount
  options.

* The option parser incorrectly treats the xattr mount option as a
  boolean value. Even if xattr=sa is specified, the parser translates
  that to xattr=on. Address this by treating the option as a scalar
  value.

Issue #3787

Signed-off-by: Ned Bass <bass6@llnl.gov>
  • Loading branch information
nedbass committed Sep 16, 2015
1 parent 7a27ad0 commit ab6899e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/sys/zfs_vfsops.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ struct znode;
typedef struct zfs_mntopts {
char *z_osname; /* Objset name */
char *z_mntpoint; /* Primary mount point */
uint64_t z_xattr;
boolean_t z_readonly;
boolean_t z_do_readonly;
boolean_t z_setuid;
Expand All @@ -52,7 +53,6 @@ typedef struct zfs_mntopts {
boolean_t z_do_exec;
boolean_t z_devices;
boolean_t z_do_devices;
boolean_t z_xattr;
boolean_t z_do_xattr;
boolean_t z_atime;
boolean_t z_do_atime;
Expand Down
2 changes: 0 additions & 2 deletions lib/libzfs/libzfs_mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,6 @@ zfs_add_options(zfs_handle_t *zhp, char *options, int len)
ZFS_PROP_READONLY, MNTOPT_RO, MNTOPT_RW);
error = error ? error : zfs_add_option(zhp, options, len,
ZFS_PROP_SETUID, MNTOPT_SETUID, MNTOPT_NOSETUID);
error = error ? error : zfs_add_option(zhp, options, len,
ZFS_PROP_XATTR, MNTOPT_XATTR, MNTOPT_NOXATTR);
error = error ? error : zfs_add_option(zhp, options, len,
ZFS_PROP_NBMAND, MNTOPT_NBMAND, MNTOPT_NONBMAND);

Expand Down
23 changes: 21 additions & 2 deletions module/zfs/zpl_super.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,30 @@ zpl_parse_option(char *option, int token, substring_t *args,
zmo->z_do_devices = B_TRUE;
break;
case TOKEN_XATTR:
zmo->z_xattr = B_TRUE;
{
char *xattr_val;
uint64_t index;

xattr_val = match_strdup(&args[0]);
if (xattr_val == NULL)
return (-ENOMEM);

if (strlen(xattr_val) == 0) {
index = ZFS_XATTR_DIR;
} else if (zfs_prop_string_to_index(ZFS_PROP_XATTR,
xattr_val, &index) != 0) {
strfree(xattr_val);
return (-EINVAL);
}

zmo->z_xattr = index;
zmo->z_do_xattr = B_TRUE;
strfree(xattr_val);

break;
}
case TOKEN_NOXATTR:
zmo->z_xattr = B_FALSE;
zmo->z_xattr = ZFS_XATTR_OFF;
zmo->z_do_xattr = B_TRUE;
break;
case TOKEN_ATIME:
Expand Down

0 comments on commit ab6899e

Please sign in to comment.