mirror of
				https://git.proxmox.com/git/mirror_zfs.git
				synced 2025-10-26 18:05:04 +03:00 
			
		
		
		
	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
0282c4137e. 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 <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3787
			
			
This commit is contained in:
		
							parent
							
								
									66aad10ce8
								
							
						
					
					
						commit
						3af56fd95f
					
				| @ -88,6 +88,8 @@ | |||||||
| #define	MNTOPT_LOUD	"loud"		/* verbose mount */ | #define	MNTOPT_LOUD	"loud"		/* verbose mount */ | ||||||
| #define	MNTOPT_BIND	"bind"		/* remount part of a tree */ | #define	MNTOPT_BIND	"bind"		/* remount part of a tree */ | ||||||
| #define	MNTOPT_RBIND	"rbind"		/* include subtrees */ | #define	MNTOPT_RBIND	"rbind"		/* include subtrees */ | ||||||
|  | #define	MNTOPT_DIRXATTR	"dirxattr"	/* enable directory xattrs */ | ||||||
|  | #define	MNTOPT_SAXATTR	"saxattr"	/* enable system-attribute xattrs */ | ||||||
| #define	MNTOPT_XATTR	"xattr"		/* enable extended attributes */ | #define	MNTOPT_XATTR	"xattr"		/* enable extended attributes */ | ||||||
| #define	MNTOPT_NOXATTR	"noxattr"	/* disable extended attributes */ | #define	MNTOPT_NOXATTR	"noxattr"	/* disable extended attributes */ | ||||||
| #define	MNTOPT_COMMENT	"comment"	/* comment */ | #define	MNTOPT_COMMENT	"comment"	/* comment */ | ||||||
|  | |||||||
| @ -44,6 +44,7 @@ struct znode; | |||||||
| typedef struct zfs_mntopts { | typedef struct zfs_mntopts { | ||||||
| 	char		*z_osname;	/* Objset name */ | 	char		*z_osname;	/* Objset name */ | ||||||
| 	char		*z_mntpoint;	/* Primary mount point */ | 	char		*z_mntpoint;	/* Primary mount point */ | ||||||
|  | 	uint64_t	z_xattr; | ||||||
| 	boolean_t	z_readonly; | 	boolean_t	z_readonly; | ||||||
| 	boolean_t	z_do_readonly; | 	boolean_t	z_do_readonly; | ||||||
| 	boolean_t	z_setuid; | 	boolean_t	z_setuid; | ||||||
| @ -52,7 +53,6 @@ typedef struct zfs_mntopts { | |||||||
| 	boolean_t	z_do_exec; | 	boolean_t	z_do_exec; | ||||||
| 	boolean_t	z_devices; | 	boolean_t	z_devices; | ||||||
| 	boolean_t	z_do_devices; | 	boolean_t	z_do_devices; | ||||||
| 	boolean_t	z_xattr; |  | ||||||
| 	boolean_t	z_do_xattr; | 	boolean_t	z_do_xattr; | ||||||
| 	boolean_t	z_atime; | 	boolean_t	z_atime; | ||||||
| 	boolean_t	z_do_atime; | 	boolean_t	z_do_atime; | ||||||
|  | |||||||
| @ -371,8 +371,6 @@ zfs_add_options(zfs_handle_t *zhp, char *options, int len) | |||||||
| 	    ZFS_PROP_READONLY, MNTOPT_RO, MNTOPT_RW); | 	    ZFS_PROP_READONLY, MNTOPT_RO, MNTOPT_RW); | ||||||
| 	error = error ? error : zfs_add_option(zhp, options, len, | 	error = error ? error : zfs_add_option(zhp, options, len, | ||||||
| 	    ZFS_PROP_SETUID, MNTOPT_SETUID, MNTOPT_NOSETUID); | 	    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, | 	error = error ? error : zfs_add_option(zhp, options, len, | ||||||
| 	    ZFS_PROP_NBMAND, MNTOPT_NBMAND, MNTOPT_NONBMAND); | 	    ZFS_PROP_NBMAND, MNTOPT_NBMAND, MNTOPT_NONBMAND); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -83,7 +83,7 @@ under that mountpoint. | |||||||
| This flag sets the SELinux context for the filesytem being mounted. | This flag sets the SELinux context for the filesytem being mounted. | ||||||
| .TP | .TP | ||||||
| .BI "\-o defcontext" | .BI "\-o defcontext" | ||||||
| This flag sets the SELinux context for unlabled files. | This flag sets the SELinux context for unlabeled files. | ||||||
| .TP | .TP | ||||||
| .BI "\-o rootcontext" | .BI "\-o rootcontext" | ||||||
| This flag sets the SELinux context for the root inode of the filesystem. | 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. | |||||||
| This private flag disables extended attributes. | This private flag disables extended attributes. | ||||||
| .TP | .TP | ||||||
| .BI "\-o xattr | .BI "\-o xattr | ||||||
| This private flag enables extended attributes and, if appropriate, | This private flag enables directory-based extended attributes and, if | ||||||
| adds a ZFS context to the selinux system policy. | appropriate, adds a ZFS context to the selinux system policy. | ||||||
|  | .TP | ||||||
|  | .BI "\-o saxattr | ||||||
|  | This private flag enables system attributed-based extended attributes and, if | ||||||
|  | appropriate, adds a ZFS context to the selinux system policy. | ||||||
|  | .TP | ||||||
|  | .BI "\-o dirxattr | ||||||
|  | Equivalent to | ||||||
|  | .BR xattr . | ||||||
| .TP | .TP | ||||||
| .BI "\-o zfsutil" | .BI "\-o zfsutil" | ||||||
| This private flag indicates that | This private flag indicates that | ||||||
|  | |||||||
| @ -193,6 +193,8 @@ enum { | |||||||
| 	TOKEN_NOEXEC, | 	TOKEN_NOEXEC, | ||||||
| 	TOKEN_DEVICES, | 	TOKEN_DEVICES, | ||||||
| 	TOKEN_NODEVICES, | 	TOKEN_NODEVICES, | ||||||
|  | 	TOKEN_DIRXATTR, | ||||||
|  | 	TOKEN_SAXATTR, | ||||||
| 	TOKEN_XATTR, | 	TOKEN_XATTR, | ||||||
| 	TOKEN_NOXATTR, | 	TOKEN_NOXATTR, | ||||||
| 	TOKEN_ATIME, | 	TOKEN_ATIME, | ||||||
| @ -214,6 +216,8 @@ static const match_table_t zpl_tokens = { | |||||||
| 	{ TOKEN_NOEXEC,		MNTOPT_NOEXEC }, | 	{ TOKEN_NOEXEC,		MNTOPT_NOEXEC }, | ||||||
| 	{ TOKEN_DEVICES,	MNTOPT_DEVICES }, | 	{ TOKEN_DEVICES,	MNTOPT_DEVICES }, | ||||||
| 	{ TOKEN_NODEVICES,	MNTOPT_NODEVICES }, | 	{ TOKEN_NODEVICES,	MNTOPT_NODEVICES }, | ||||||
|  | 	{ TOKEN_DIRXATTR,	MNTOPT_DIRXATTR }, | ||||||
|  | 	{ TOKEN_SAXATTR,	MNTOPT_SAXATTR }, | ||||||
| 	{ TOKEN_XATTR,		MNTOPT_XATTR }, | 	{ TOKEN_XATTR,		MNTOPT_XATTR }, | ||||||
| 	{ TOKEN_NOXATTR,	MNTOPT_NOXATTR }, | 	{ TOKEN_NOXATTR,	MNTOPT_NOXATTR }, | ||||||
| 	{ TOKEN_ATIME,		MNTOPT_ATIME }, | 	{ TOKEN_ATIME,		MNTOPT_ATIME }, | ||||||
| @ -262,12 +266,20 @@ zpl_parse_option(char *option, int token, substring_t *args, zfs_mntopts_t *zmo) | |||||||
| 		zmo->z_devices = B_FALSE; | 		zmo->z_devices = B_FALSE; | ||||||
| 		zmo->z_do_devices = B_TRUE; | 		zmo->z_do_devices = B_TRUE; | ||||||
| 		break; | 		break; | ||||||
|  | 	case TOKEN_DIRXATTR: | ||||||
|  | 		zmo->z_xattr = ZFS_XATTR_DIR; | ||||||
|  | 		zmo->z_do_xattr = B_TRUE; | ||||||
|  | 		break; | ||||||
|  | 	case TOKEN_SAXATTR: | ||||||
|  | 		zmo->z_xattr = ZFS_XATTR_SA; | ||||||
|  | 		zmo->z_do_xattr = B_TRUE; | ||||||
|  | 		break; | ||||||
| 	case TOKEN_XATTR: | 	case TOKEN_XATTR: | ||||||
| 		zmo->z_xattr = B_TRUE; | 		zmo->z_xattr = ZFS_XATTR_DIR; | ||||||
| 		zmo->z_do_xattr = B_TRUE; | 		zmo->z_do_xattr = B_TRUE; | ||||||
| 		break; | 		break; | ||||||
| 	case TOKEN_NOXATTR: | 	case TOKEN_NOXATTR: | ||||||
| 		zmo->z_xattr = B_FALSE; | 		zmo->z_xattr = ZFS_XATTR_OFF; | ||||||
| 		zmo->z_do_xattr = B_TRUE; | 		zmo->z_do_xattr = B_TRUE; | ||||||
| 		break; | 		break; | ||||||
| 	case TOKEN_ATIME: | 	case TOKEN_ATIME: | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Ned Bass
						Ned Bass