gfs2: fs format 1802 features
cover gfs2: fs format 1802 features
These patches add trusted.* xattr support and switch on rgrplvb by default when the sb_fs_format field is greater than 1801 (the current version). Filesystems with an 1802 fs format can currently be created with gfs2-utils.git/master using -o format=1802 but that will become the default once this has had some soak time.
I've tested the patches with several rounds of xfstests single-node, and in a clustered configuration with a lot of file operations happening on each node, including filling the fs to force resource group contention.
Andreas Gruenbacher (1):
gfs2: Add trusted xattr support
Andrew Price (1):
gfs2: Enable rgrplvb for sb_fs_format 1802
fs/gfs2/incore.h | 1 + fs/gfs2/ops_fstype.c | 27 +++++++++++++++--- fs/gfs2/super.h | 8 +++++- fs/gfs2/xattr.c | 48 +++++++++++++++++++++++++++++--- include/uapi/linux/gfs2_ondisk.h | 5 ++-- 5 files changed, 78 insertions(+), 11 deletions(-)
Signature · 1 line
2.29.2
PATCH 1/2 gfs2: Enable rgrplvb for sb_fs_format 1802
Turn on rgrplvb by default for sb_fs_format > 1801.
Mount options still have to override this so a new args field to differentiate between 'off' and 'not specified' is added, and the new default is applied only when it's not specified.
--- fs/gfs2/incore.h | 1 + fs/gfs2/ops_fstype.c | 13 ++++++++++--- fs/gfs2/super.h | 4 ++++ 3 files changed, 15 insertions(+), 3 deletions(-)
fs/gfs2/incore.h +1 -0
@@ -585,6 +585,7 @@ struct gfs2_args { unsigned int ar_errors:2; /* errors=withdraw | panic */ unsigned int ar_nobarrier:1; /* do not send barriers */ unsigned int ar_rgrplvb:1; /* use lvbs for rgrp info */ + unsigned int ar_got_rgrplvb:1; /* Was the rgrplvb opt given? */ unsigned int ar_loccookie:1; /* use location based readdircookies */ s32 ar_commit;/* Commit interval */
fs/gfs2/ops_fstype.c +10 -3
@@ -171,7 +171,8 @@ static int gfs2_check_sb(struct gfs2_sbd *sdp, int silent)return -EINVAL ; } -if (sb->sb_fs_format !=GFS2_FORMAT_FS || +if (sb->sb_fs_format <GFS2_FS_FORMAT_MIN || + sb->sb_fs_format >GFS2_FS_FORMAT_MAX || sb->sb_multihost_format !=GFS2_FORMAT_MULTI ) {fs_warn (sdp,"Unknown on-disk format, unable to mount\n" );return -EINVAL ;
@@ -1032,13 +1033,14 @@ static int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent) }if (lm->lm_mount ==NULL ) { -fs_info (sdp,"Now mounting FS...\n" ); +fs_info (sdp,"Now mounting FS (format %u)...\n" , sdp->sd_sb.sb_fs_format);complete_all (&sdp->sd_locking_init);return 0 ; } ret = lm->lm_mount (sdp, table);if (ret ==0 ) -fs_info (sdp,"Joined cluster. Now mounting FS...\n" ); +fs_info (sdp,"Joined cluster. Now mounting FS (format %u)...\n" , + sdp->sd_sb.sb_fs_format);complete_all (&sdp->sd_locking_init);return ret; }
@@ -1156,6 +1158,10 @@ static int gfs2_fill_super(struct super_block *sb, struct fs_context *fc)if (error) goto fail_locking; +/* Turn rgrplvb on by default if fs format is recent enough */ +if (!sdp->sd_args.ar_got_rgrplvb && sdp->sd_sb.sb_fs_format >1801 ) + sdp->sd_args.ar_rgrplvb =1 ; + error =wait_on_journal (sdp);if (error) goto fail_sb;
@@ -1456,6 +1462,7 @@ static int gfs2_parse_param(struct fs_context *fc, struct fs_parameter *param)break ;case Opt_rgrplvb: args->ar_rgrplvb = result.boolean; + args->ar_got_rgrplvb =1 ;break ;case Opt_loccookie: args->ar_loccookie = result.boolean;
fs/gfs2/super.h +4 -0
@@ -11,6 +11,10 @@#include <linux/dcache.h> #include "incore.h" +/* Supported fs format version range */ +#define GFS2_FS_FORMAT_MIN (1801) +#define GFS2_FS_FORMAT_MAX (1802) +extern void gfs2_lm_unmount (struct gfs2_sbd *sdp);static inline unsigned int gfs2_jindex_size (struct gfs2_sbd *sdp)
Signature · 1 line
2.29.2
PATCH 1/2 gfs2: Enable rgrplvb for sb_fs_format 1802
----- Original Message -----
Quoted 95 lines
Turn on rgrplvb by default for
sb_fs_format> 1801.Mount options still have to override this so a new args field to differentiate between 'off' and 'not specified' is added, and the new default is applied only when it's not specified.
Signed-off-by Andrew Price <[email protected]>--- fs/gfs2/incore.h | 1 + fs/gfs2/ops_fstype.c | 13 ++++++++++--- fs/gfs2/super.h | 4 ++++ 3 files changed, 15 insertions(+), 3 deletions(-)fs/gfs2/incore.h +1
-0@@ -585,6 +585,7 @@ struct gfs2_args { unsigned int ar_errors:2; /* errors=withdraw | panic */ unsigned int ar_nobarrier:1; /* do not send barriers */ unsigned int ar_rgrplvb:1; /* use lvbs for rgrp info */ + unsigned int ar_got_rgrplvb:1; /* Was the rgrplvb opt given? */ unsigned int ar_loccookie:1; /* use location based readdircookies */ s32 ar_commit;/* Commit interval */ fs/gfs2/ops_fstype.c +2
-1@@ -171,7 +171,8 @@ static int gfs2_check_sb(struct gfs2_sbd *sdp, int silent)return -EINVAL ; } -if (sb->sb_fs_format !=GFS2_FORMAT_FS || +if (sb->sb_fs_format <GFS2_FS_FORMAT_MIN || + sb->sb_fs_format >GFS2_FS_FORMAT_MAX || sb->sb_multihost_format !=GFS2_FORMAT_MULTI ) {fs_warn (sdp,"Unknown on-disk format, unable to mount\n" );fs/gfs2/ops_fstype.c +3
-2return -EINVAL ;@@ -1032,13 +1033,14 @@ static int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent) }if (lm->lm_mount ==NULL ) { -fs_info (sdp,"Now mounting FS...\n" ); +fs_info (sdp,"Now mounting FS (format %u)...\n" , sdp->sd_sb.sb_fs_format);complete_all (&sdp->sd_locking_init);return 0 ; } ret = lm->lm_mount (sdp, table);if (ret ==0 ) -fs_info (sdp,"Joined cluster. Now mounting FS...\n" ); +fs_info (sdp,"Joined cluster. Now mounting FS (format %u)...\n" , + sdp->sd_sb.sb_fs_format);complete_all (&sdp->sd_locking_init);return ret;}
fs/gfs2/ops_fstype.c +4
-0@@ -1156,6 +1158,10 @@ static int gfs2_fill_super(struct super_block *sb, struct fs_context *fc)if (error) goto fail_locking; +/* Turn rgrplvb on by default if fs format is recent enough */ +if (!sdp->sd_args.ar_got_rgrplvb && sdp->sd_sb.sb_fs_format >1801 ) + sdp->sd_args.ar_rgrplvb =1 ; + error =wait_on_journal (sdp);if (error)fs/gfs2/ops_fstype.c +1
-0goto fail_sb;@@ -1456,6 +1462,7 @@ static int gfs2_parse_param(struct fs_context *fc, struct fs_parameter *param) break;case Opt_rgrplvb: args->ar_rgrplvb = result.boolean; + args->ar_got_rgrplvb =1 ;break ;case Opt_loccookie:fs/gfs2/ops_fstype.c +0
-0args->ar_loccookie = result.boolean;fs/gfs2/super.h +4
-1@@ -11,6 +11,10 @@#include <linux/dcache.h> #include "incore.h" +/* Supported fs format version range */ +#define GFS2_FS_FORMAT_MIN (1801) +#define GFS2_FS_FORMAT_MAX (1802) +extern void gfs2_lm_unmount (struct gfs2_sbd *sdp);static inline unsigned int gfs2_jindex_size (struct gfs2_sbd *sdp) --
Quoted 3 lines
2.29.2
Looks good. Thanks, Andy!
Bob Peterson
PATCH 2/2 gfs2: Add trusted xattr support
In reply to Andrew PriceFrom: Andreas Gruenbacher <[email protected]>
Add support for an additional filesystem version (sb_fs_format = 1802). When a filesystem with the new version is mounted, the filesystem supports "trusted.*" xattrs.
In addition, version 1802 filesystems implement a form of forward compatibility for xattrs: when xattrs with an unknown prefix (ea_type) are found on a version 1802 filesystem, those attributes are not shown by listxattr, and they are not accessible by getxattr, setxattr, or removexattr.
This mechanism might turn out to be what we need in the future, but if not, we can always bump the filesystem version and break compatibility instead.
--- fs/gfs2/ops_fstype.c | 14 +++++++++- fs/gfs2/super.h | 4 ++- fs/gfs2/xattr.c | 48 +++++++++++++++++++++++++++++--- include/uapi/linux/gfs2_ondisk.h | 5 ++-- 4 files changed, 63 insertions(+), 8 deletions(-)
fs/gfs2/ops_fstype.c +13 -1
@@ -489,6 +489,19 @@ static int init_sb(struct gfs2_sbd *sdp, int silent) goto out; } +switch (sdp->sd_sb.sb_fs_format) { +case GFS2_FS_FORMAT_MAX : + sb->s_xattr = gfs2_xattr_handlers_max; +break ; + +case GFS2_FS_FORMAT_MIN : + sb->s_xattr = gfs2_xattr_handlers_min; +break ; + +default : +BUG (); + } +/* Set up the buffer cache and SB for real */ if (sdp->sd_sb.sb_bsize <bdev_logical_block_size (sb->s_bdev)) { ret = -EINVAL ;
@@ -1109,7 +1122,6 @@ static int gfs2_fill_super(struct super_block *sb, struct fs_context *fc) sb->s_op = &gfs2_super_ops; sb->s_d_op = &gfs2_dops; sb->s_export_op = &gfs2_export_ops; - sb->s_xattr = gfs2_xattr_handlers; sb->s_qcop = &gfs2_quotactl_ops; sb->s_quota_types =QTYPE_MASK_USR |QTYPE_MASK_GRP ;sb_dqopt (sb)->flags |=DQUOT_QUOTA_SYS_FILE ;
fs/gfs2/super.h +3 -1
@@ -58,7 +58,9 @@ extern struct file_system_type gfs2meta_fs_type;extern const struct export_operations gfs2_export_ops;extern const struct super_operations gfs2_super_ops;extern const struct dentry_operations gfs2_dops; -extern const struct xattr_handler *gfs2_xattr_handlers[]; + +extern const struct xattr_handler *gfs2_xattr_handlers_max[]; +extern const struct xattr_handler **gfs2_xattr_handlers_min;#endif /* __SUPER_DOT_H__ */
fs/gfs2/xattr.c +44 -4
95 lines not on this page · raw message
include/uapi/linux/gfs2_ondisk.h +3 -2
@@ -47,7 +47,7 @@#define GFS2_FORMAT_DE 1200#define GFS2_FORMAT_QU 1500/* These are part of the superblock */ -#define GFS2_FORMAT_FS 1801 +#define GFS2_FORMAT_FS 1802#define GFS2_FORMAT_MULTI 1900/*
@@ -389,8 +389,9 @@ struct gfs2_leaf {#define GFS2_EATYPE_USR 1#define GFS2_EATYPE_SYS 2#define GFS2_EATYPE_SECURITY 3 +#define GFS2_EATYPE_TRUSTED 4 -#define GFS2_EATYPE_LAST 3 +#define GFS2_EATYPE_LAST 4#define GFS2_EATYPE_VALID (x) ((x) <= GFS2_EATYPE_LAST)#define GFS2_EAFLAG_LAST 0x01/* last ea in block */
Signature · 1 line
2.29.2
PATCH 2/2 gfs2: Add trusted xattr support
Hi,
Comments below.
----- Original Message -----
Quoted 12 lines
From: Andreas Gruenbacher <[email protected]>
Add support for an additional filesystem version (
sb_fs_format= 1802). When a filesystem with the new version is mounted, the filesystem supports "trusted.*" xattrs.In addition, version 1802 filesystems implement a form of forward compatibility for xattrs: when xattrs with an unknown prefix (
ea_type) are found on a version 1802 filesystem, those attributes are not shown by listxattr, and they are not accessible by getxattr, setxattr, or removexattr.
Quoted 5 lines
This mechanism might turn out to be what we need in the future, but if not, we can always bump the filesystem version and break compatibility instead.
Signed-off-by Andrew Price <[email protected]>
If this is from Andreas, it should have his Signed-off-by:
Quoted 60 lines
--- fs/gfs2/ops_fstype.c | 14 +++++++++- fs/gfs2/super.h | 4 ++- fs/gfs2/xattr.c | 48 +++++++++++++++++++++++++++++--- include/uapi/linux/gfs2_ondisk.h | 5 ++-- 4 files changed, 63 insertions(+), 8 deletions(-)fs/gfs2/ops_fstype.c +13
-1@@ -489,6 +489,19 @@ static int init_sb(struct gfs2_sbd *sdp, int silent) goto out; } +switch (sdp->sd_sb.sb_fs_format) { +case GFS2_FS_FORMAT_MAX : + sb->s_xattr = gfs2_xattr_handlers_max; +break ; + +case GFS2_FS_FORMAT_MIN : + sb->s_xattr = gfs2_xattr_handlers_min; +break ; + +default : +BUG (); + } +/* Set up the buffer cache and SB for real */ if (sdp->sd_sb.sb_bsize <bdev_logical_block_size (sb->s_bdev)) { ret = -EINVAL ;@@ -1109,7 +1122,6 @@ static int gfs2_fill_super(struct super_block *sb, struct fs_context *fc) sb->s_op = &gfs2_super_ops; sb->s_d_op = &gfs2_dops; sb->s_export_op = &gfs2_export_ops; - sb->s_xattr = gfs2_xattr_handlers; sb->s_qcop = &gfs2_quotactl_ops; sb->s_quota_types =QTYPE_MASK_USR |QTYPE_MASK_GRP ;fs/gfs2/ops_fstype.c +0
-0sb_dqopt (sb)->flags |=DQUOT_QUOTA_SYS_FILE ;fs/gfs2/super.h +3
-1@@ -58,7 +58,9 @@ extern struct file_system_type gfs2meta_fs_type;extern const struct export_operations gfs2_export_ops;extern const struct super_operations gfs2_super_ops;extern const struct dentry_operations gfs2_dops; -extern const struct xattr_handler *gfs2_xattr_handlers[]; + +extern const struct xattr_handler *gfs2_xattr_handlers_max[]; +extern const struct xattr_handler **gfs2_xattr_handlers_min;#endif /* __SUPER_DOT_H__ */ fs/gfs2/xattr.c +0
-0
fs/gfs2/xattr.c static int ea_check_size(struct gfs2_sbd *sdp, unsigned · line 74
Quoted 5 lines
fs/gfs2/xattr.c +1
-0@@ -70,6 +70,20 @@ static int ea_check_size(struct gfs2_sbd *sdp, unsigned int nsize, size_t dsize) return 0; } +bool gfs2_eatype_valid (struct gfs2_sbd *sdp,u8 type)
This should be "static bool".
Quoted 120 lines
fs/gfs2/xattr.c +13
-0+{ +switch (sdp->sd_sb.sb_fs_format) { +case GFS2_FS_FORMAT_MAX : +return true; + +case GFS2_FS_FORMAT_MIN : +return type <=GFS2_EATYPE_SECURITY ; + +default : +return false; + } +} + typedef int (*ea_call_t) (struct gfs2_inode *ip, struct buffer_head *bh, struct gfs2_ea_header *ea,fs/gfs2/xattr.c +2
-2struct gfs2_ea_header *prev, void *private);@@ -77,6 +91,7 @@ typedef int (*ea_call_t) (struct gfs2_inode *ip, structbuffer_head *bh, static int ea_foreach_i(struct gfs2_inode *ip, struct buffer_head *bh, ea_call_t ea_call, void *data) { + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);struct gfs2_ea_header *ea, *prev =NULL ;int error =0 ;@@ -89,9 +104,8 @@ static int ea_foreach_i(struct gfs2_inode *ip, struct buffer_head *bh, if (!(bh->b_data <= (char *)ea && (char *)GFS2_EA2NEXT(ea) <= bh->b_data + bh->b_size)) goto fail; -if (!GFS2_EATYPE_VALID (ea->ea_type)) +if (!gfs2_eatype_valid (sdp, ea->ea_type)) goto fail; - error =ea_call (ip, bh, ea, prev, data);if (error)fs/gfs2/xattr.c +1
-0return error;@@ -344,6 +358,7 @@ static int ea_list_i(struct gfs2_inode *ip, structbuffer_head *bh, struct gfs2_ea_header *ea, struct gfs2_ea_header *prev, void *private) { + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);struct ea_list *ei = private;struct gfs2_ea_request *er = ei->ei_er;fs/gfs2/xattr.c +2
-0unsigned int ea_size;@@ -353,6 +368,8 @@ static int ea_list_i(struct gfs2_inode *ip, struct buffer_head *bh, if (ea->ea_type == GFS2_EATYPE_UNUSED)return 0 ; +BUG_ON (ea->ea_type >GFS2_EATYPE_SECURITY && + sdp->sd_sb.sb_fs_format ==GFS2_FS_FORMAT_MIN );switch (ea->ea_type) {case GFS2_EATYPE_USR :fs/gfs2/xattr.c +5
-1prefix ="user." ;@@ -366,8 +383,12 @@ static int ea_list_i(struct gfs2_inode *ip, structbuffer_head *bh, prefix ="security." ; l =9 ;break ; +case GFS2_EATYPE_TRUSTED : + prefix ="trusted." ; + l =8 ; +break ;default : -BUG (); +return 0 ; }fs/gfs2/xattr.c +19
-1ea_size = l + ea->ea_name_len +1 ;@@ -1463,7 +1484,25 @@ static const struct xattr_handler gfs2_xattr_security_handler = { .set = gfs2_xattr_set, }; -const struct xattr_handler *gfs2_xattr_handlers[] = { +static bool +gfs2_xattr_trusted_list (struct dentry *dentry) +{ +return capable (CAP_SYS_ADMIN ); +} + +static const struct xattr_handler gfs2_xattr_trusted_handler = { + .prefix =XATTR_TRUSTED_PREFIX , + .flags =GFS2_EATYPE_TRUSTED , + .list = gfs2_xattr_trusted_list, + .get = gfs2_xattr_get, + .set = gfs2_xattr_set, +}; + +const struct xattr_handler *gfs2_xattr_handlers_max[] = { +/* GFS2_FS_FORMAT_MAX */ + &gfs2_xattr_trusted_handler, + +/* GFS2_FS_FORMAT_MIN */ &gfs2_xattr_user_handler, &gfs2_xattr_security_handler,fs/gfs2/xattr.c +1
-0&posix_acl_access_xattr_handler,@@ -1471,3 +1510,4 @@ const struct xattr_handler *gfs2_xattr_handlers[] = { NULL, }; +const struct xattr_handler **gfs2_xattr_handlers_min =
gfs2_xattr_handlers_max+ 1;include/uapi/linux/gfs2_ondisk.h +1
-1@@ -47,7 +47,7 @@#define GFS2_FORMAT_DE 1200#define GFS2_FORMAT_QU 1500/* These are part of the superblock */ -#define GFS2_FORMAT_FS 1801 +#define GFS2_FORMAT_FS 1802#define GFS2_FORMAT_MULTI 1900/*
include/uapi/linux/gfs2_ondisk.h struct gfs2_leaf { · line 395
Quoted 8 lines
include/uapi/linux/gfs2_ondisk.h +2
-1@@ -389,8 +389,9 @@ struct gfs2_leaf {#define GFS2_EATYPE_USR 1#define GFS2_EATYPE_SYS 2#define GFS2_EATYPE_SECURITY 3 +#define GFS2_EATYPE_TRUSTED 4 -#define GFS2_EATYPE_LAST 3 +#define GFS2_EATYPE_LAST 4#define GFS2_EATYPE_VALID (x) ((x) <= GFS2_EATYPE_LAST)
GFS2_EATYPE_VALID was replaced by the function and isn't used elsewhere, so this line should be deleted.
And if we do that, we might as well eliminate GFS2_EATYPE_LAST, or, alternately, use it in the new function.
Bob
PATCH 2/2 gfs2: Add trusted xattr support
Quoted 17 lines · Bob Peterson
Hi,
Comments below.
----- Original Message -----
Quoted 12 lines
From: Andreas Gruenbacher <[email protected]>
Add support for an additional filesystem version (
sb_fs_format= 1802). When a filesystem with the new version is mounted, the filesystem supports "trusted.*" xattrs.In addition, version 1802 filesystems implement a form of forward compatibility for xattrs: when xattrs with an unknown prefix (
ea_type) are found on a version 1802 filesystem, those attributes are not shown by listxattr, and they are not accessible by getxattr, setxattr, or removexattr.
Quoted 7 lines
Quoted 5 lines
This mechanism might turn out to be what we need in the future, but if not, we can always bump the filesystem version and break compatibility instead.
Signed-off-by Andrew Price <[email protected]>If this is from Andreas, it should have his Signed-off-by:
Yes, it wasn't in the original patch (posted on bugzilla). With Andreas' permission I'll add it to the next version.
Quoted 65 lines
Quoted 65 lines
--- fs/gfs2/ops_fstype.c | 14 +++++++++- fs/gfs2/super.h | 4 ++- fs/gfs2/xattr.c | 48 +++++++++++++++++++++++++++++--- include/uapi/linux/gfs2_ondisk.h | 5 ++-- 4 files changed, 63 insertions(+), 8 deletions(-)fs/gfs2/ops_fstype.c +13
-1@@ -489,6 +489,19 @@ static int init_sb(struct gfs2_sbd *sdp, int silent) goto out; } +switch (sdp->sd_sb.sb_fs_format) { +case GFS2_FS_FORMAT_MAX : + sb->s_xattr = gfs2_xattr_handlers_max; +break ; + +case GFS2_FS_FORMAT_MIN : + sb->s_xattr = gfs2_xattr_handlers_min; +break ; + +default : +BUG (); + } +/* Set up the buffer cache and SB for real */ if (sdp->sd_sb.sb_bsize <bdev_logical_block_size (sb->s_bdev)) { ret = -EINVAL ;@@ -1109,7 +1122,6 @@ static int gfs2_fill_super(struct super_block *sb, struct fs_context *fc) sb->s_op = &gfs2_super_ops; sb->s_d_op = &gfs2_dops; sb->s_export_op = &gfs2_export_ops; - sb->s_xattr = gfs2_xattr_handlers; sb->s_qcop = &gfs2_quotactl_ops; sb->s_quota_types =QTYPE_MASK_USR |QTYPE_MASK_GRP ;sb_dqopt(sb)->flags |= DQUOT_QUOTA_SYS_FILE;fs/gfs2/super.h +3
-1@@ -58,7 +58,9 @@ extern struct file_system_type gfs2meta_fs_type;extern const struct export_operations gfs2_export_ops;extern const struct super_operations gfs2_super_ops;extern const struct dentry_operations gfs2_dops; -extern const struct xattr_handler *gfs2_xattr_handlers[]; + +extern const struct xattr_handler *gfs2_xattr_handlers_max[]; +extern const struct xattr_handler **gfs2_xattr_handlers_min;#endif /* __SUPER_DOT_H__ */ fs/gfs2/xattr.c +0
-0@@ -70,6 +70,20 @@ static int ea_check_size(struct gfs2_sbd *sdp, unsigned int nsize, size_t dsize) return 0; }
Quoted 3 lines
fs/gfs2/xattr.c static int ea_check_size(struct gfs2_sbd *sdp, unsigned int nsize, size_t dsize) · line 73
Quoted 1 line
fs/gfs2/xattr.c +1
-0+bool gfs2_eatype_valid (struct gfs2_sbd *sdp,u8 type)This should be "static bool".
Ok, I'll update that.
Quoted 126 lines
Quoted 126 lines
fs/gfs2/xattr.c +13
-0+{ +switch (sdp->sd_sb.sb_fs_format) { +case GFS2_FS_FORMAT_MAX : +return true; + +case GFS2_FS_FORMAT_MIN : +return type <=GFS2_EATYPE_SECURITY ; + +default : +return false; + } +} + typedef int (*ea_call_t) (struct gfs2_inode *ip, struct buffer_head *bh, struct gfs2_ea_header *ea,struct
gfs2_ea_header*prev, void *private);fs/gfs2/xattr.c +2
-2@@ -77,6 +91,7 @@ typedef int (*ea_call_t) (struct gfs2_inode *ip, structbuffer_head *bh, static int ea_foreach_i(struct gfs2_inode *ip, struct buffer_head *bh, ea_call_t ea_call, void *data) { + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);struct gfs2_ea_header *ea, *prev =NULL ;int error =0 ;@@ -89,9 +104,8 @@ static int ea_foreach_i(struct gfs2_inode *ip, struct buffer_head *bh, if (!(bh->b_data <= (char *)ea && (char *)GFS2_EA2NEXT(ea) <= bh->b_data + bh->b_size)) goto fail; -if (!GFS2_EATYPE_VALID (ea->ea_type)) +if (!gfs2_eatype_valid (sdp, ea->ea_type)) goto fail; - error =ea_call (ip, bh, ea, prev, data);if (error)return error;
fs/gfs2/xattr.c +1
-0@@ -344,6 +358,7 @@ static int ea_list_i(struct gfs2_inode *ip, structbuffer_head *bh, struct gfs2_ea_header *ea, struct gfs2_ea_header *prev, void *private) { + struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);struct ea_list *ei = private;struct gfs2_ea_request *er = ei->ei_er;unsigned int
ea_size;fs/gfs2/xattr.c +2
-0@@ -353,6 +368,8 @@ static int ea_list_i(struct gfs2_inode *ip, struct buffer_head *bh, if (ea->ea_type == GFS2_EATYPE_UNUSED)return 0 ; +BUG_ON (ea->ea_type >GFS2_EATYPE_SECURITY && + sdp->sd_sb.sb_fs_format ==GFS2_FS_FORMAT_MIN );switch (ea->ea_type) {case GFS2_EATYPE_USR :prefix = "user.";fs/gfs2/xattr.c +5
-1@@ -366,8 +383,12 @@ static int ea_list_i(struct gfs2_inode *ip, structbuffer_head *bh, prefix ="security." ; l =9 ;break ; +case GFS2_EATYPE_TRUSTED : + prefix ="trusted." ; + l =8 ; +break ;default : -BUG (); +return 0 ; }ea_size = l + ea->ea_name_len + 1;fs/gfs2/xattr.c +19
-1@@ -1463,7 +1484,25 @@ static const struct xattr_handler gfs2_xattr_security_handler = { .set = gfs2_xattr_set, }; -const struct xattr_handler *gfs2_xattr_handlers[] = { +static bool +gfs2_xattr_trusted_list (struct dentry *dentry) +{ +return capable (CAP_SYS_ADMIN ); +} + +static const struct xattr_handler gfs2_xattr_trusted_handler = { + .prefix =XATTR_TRUSTED_PREFIX , + .flags =GFS2_EATYPE_TRUSTED , + .list = gfs2_xattr_trusted_list, + .get = gfs2_xattr_get, + .set = gfs2_xattr_set, +}; + +const struct xattr_handler *gfs2_xattr_handlers_max[] = { +/* GFS2_FS_FORMAT_MAX */ + &gfs2_xattr_trusted_handler, + +/* GFS2_FS_FORMAT_MIN */ &gfs2_xattr_user_handler, &gfs2_xattr_security_handler,
&posix_acl_access_xattr_handler,fs/gfs2/xattr.c +1
-0@@ -1471,3 +1510,4 @@ const struct xattr_handler *gfs2_xattr_handlers[] = { NULL, }; +const struct xattr_handler **gfs2_xattr_handlers_min =
gfs2_xattr_handlers_max+ 1;include/uapi/linux/gfs2_ondisk.h +2
-1@@ -47,7 +47,7 @@#define GFS2_FORMAT_DE 1200#define GFS2_FORMAT_QU 1500/* These are part of the superblock */ -#define GFS2_FORMAT_FS 1801 +#define GFS2_FORMAT_FS 1802#define GFS2_FORMAT_MULTI 1900/* @@ -389,8 +389,9 @@ struct gfs2_leaf {#define GFS2_EATYPE_USR 1#define GFS2_EATYPE_SYS 2#define GFS2_EATYPE_SECURITY 3 +#define GFS2_EATYPE_TRUSTED 4
Quoted 8 lines
include/uapi/linux/gfs2_ondisk.h struct gfs2_leaf { · line 395
Quoted 3 lines
include/uapi/linux/gfs2_ondisk.h +1
-1-#define GFS2_EATYPE_LAST 3 +#define GFS2_EATYPE_LAST 4#define GFS2_EATYPE_VALID (x) ((x) <= GFS2_EATYPE_LAST)
GFS2_EATYPE_VALIDwas replaced by the function and isn't used elsewhere, so this line should be deleted.
And if we do that, we might as well eliminateGFS2_EATYPE_LAST, or, alternately, use it in the new function.
I don't think we should remove things from gfs2_ondisk.h once they're in there, as it's a uapi header. GFS2_EATYPE_VALID is actually used in fsck.gfs2, but even if that was removed then we'd still want older gfs2-utils versions to compile against the latest kernel headers for bisecting etc.
Thanks,
Andy