diff options
author | Andreas Gruenbacher <agruenba@redhat.com> | 2016-04-22 16:36:44 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2016-05-17 19:17:09 -0400 |
commit | e0d46f5c6e0ba3a79e64cd60e62b7b7191ed93f3 (patch) | |
tree | cd90dbd2f6a4454db626ce24d8600544d8ae493f | |
parent | 2b88fc21cae91e925bc5e361e6ea67467b471da5 (diff) |
btrfs: Switch to generic xattr handlers
The btrfs_{set,remove}xattr inode operations check for a read-only root
(btrfs_root_readonly) before calling into generic_{set,remove}xattr. If
this check is moved into __btrfs_setxattr, we can get rid of
btrfs_{set,remove}xattr.
This patch applies to mainline, I would like to keep it together with
the other xattr cleanups if possible, though. Could you please review?
Thanks,
Andreas
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/btrfs/inode.c | 16 | ||||
-rw-r--r-- | fs/btrfs/xattr.c | 22 | ||||
-rw-r--r-- | fs/btrfs/xattr.h | 3 |
3 files changed, 11 insertions, 30 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 41a5688ffdfe..0077b3b49e5e 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -10160,10 +10160,10 @@ static const struct inode_operations btrfs_dir_inode_operations = { | |||
10160 | .symlink = btrfs_symlink, | 10160 | .symlink = btrfs_symlink, |
10161 | .setattr = btrfs_setattr, | 10161 | .setattr = btrfs_setattr, |
10162 | .mknod = btrfs_mknod, | 10162 | .mknod = btrfs_mknod, |
10163 | .setxattr = btrfs_setxattr, | 10163 | .setxattr = generic_setxattr, |
10164 | .getxattr = generic_getxattr, | 10164 | .getxattr = generic_getxattr, |
10165 | .listxattr = btrfs_listxattr, | 10165 | .listxattr = btrfs_listxattr, |
10166 | .removexattr = btrfs_removexattr, | 10166 | .removexattr = generic_removexattr, |
10167 | .permission = btrfs_permission, | 10167 | .permission = btrfs_permission, |
10168 | .get_acl = btrfs_get_acl, | 10168 | .get_acl = btrfs_get_acl, |
10169 | .set_acl = btrfs_set_acl, | 10169 | .set_acl = btrfs_set_acl, |
@@ -10237,10 +10237,10 @@ static const struct address_space_operations btrfs_symlink_aops = { | |||
10237 | static const struct inode_operations btrfs_file_inode_operations = { | 10237 | static const struct inode_operations btrfs_file_inode_operations = { |
10238 | .getattr = btrfs_getattr, | 10238 | .getattr = btrfs_getattr, |
10239 | .setattr = btrfs_setattr, | 10239 | .setattr = btrfs_setattr, |
10240 | .setxattr = btrfs_setxattr, | 10240 | .setxattr = generic_setxattr, |
10241 | .getxattr = generic_getxattr, | 10241 | .getxattr = generic_getxattr, |
10242 | .listxattr = btrfs_listxattr, | 10242 | .listxattr = btrfs_listxattr, |
10243 | .removexattr = btrfs_removexattr, | 10243 | .removexattr = generic_removexattr, |
10244 | .permission = btrfs_permission, | 10244 | .permission = btrfs_permission, |
10245 | .fiemap = btrfs_fiemap, | 10245 | .fiemap = btrfs_fiemap, |
10246 | .get_acl = btrfs_get_acl, | 10246 | .get_acl = btrfs_get_acl, |
@@ -10251,10 +10251,10 @@ static const struct inode_operations btrfs_special_inode_operations = { | |||
10251 | .getattr = btrfs_getattr, | 10251 | .getattr = btrfs_getattr, |
10252 | .setattr = btrfs_setattr, | 10252 | .setattr = btrfs_setattr, |
10253 | .permission = btrfs_permission, | 10253 | .permission = btrfs_permission, |
10254 | .setxattr = btrfs_setxattr, | 10254 | .setxattr = generic_setxattr, |
10255 | .getxattr = generic_getxattr, | 10255 | .getxattr = generic_getxattr, |
10256 | .listxattr = btrfs_listxattr, | 10256 | .listxattr = btrfs_listxattr, |
10257 | .removexattr = btrfs_removexattr, | 10257 | .removexattr = generic_removexattr, |
10258 | .get_acl = btrfs_get_acl, | 10258 | .get_acl = btrfs_get_acl, |
10259 | .set_acl = btrfs_set_acl, | 10259 | .set_acl = btrfs_set_acl, |
10260 | .update_time = btrfs_update_time, | 10260 | .update_time = btrfs_update_time, |
@@ -10265,10 +10265,10 @@ static const struct inode_operations btrfs_symlink_inode_operations = { | |||
10265 | .getattr = btrfs_getattr, | 10265 | .getattr = btrfs_getattr, |
10266 | .setattr = btrfs_setattr, | 10266 | .setattr = btrfs_setattr, |
10267 | .permission = btrfs_permission, | 10267 | .permission = btrfs_permission, |
10268 | .setxattr = btrfs_setxattr, | 10268 | .setxattr = generic_setxattr, |
10269 | .getxattr = generic_getxattr, | 10269 | .getxattr = generic_getxattr, |
10270 | .listxattr = btrfs_listxattr, | 10270 | .listxattr = btrfs_listxattr, |
10271 | .removexattr = btrfs_removexattr, | 10271 | .removexattr = generic_removexattr, |
10272 | .update_time = btrfs_update_time, | 10272 | .update_time = btrfs_update_time, |
10273 | }; | 10273 | }; |
10274 | 10274 | ||
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c index 03224b00ea70..3bfb252206c7 100644 --- a/fs/btrfs/xattr.c +++ b/fs/btrfs/xattr.c | |||
@@ -237,6 +237,9 @@ int __btrfs_setxattr(struct btrfs_trans_handle *trans, | |||
237 | struct btrfs_root *root = BTRFS_I(inode)->root; | 237 | struct btrfs_root *root = BTRFS_I(inode)->root; |
238 | int ret; | 238 | int ret; |
239 | 239 | ||
240 | if (btrfs_root_readonly(root)) | ||
241 | return -EROFS; | ||
242 | |||
240 | if (trans) | 243 | if (trans) |
241 | return do_setxattr(trans, inode, name, value, size, flags); | 244 | return do_setxattr(trans, inode, name, value, size, flags); |
242 | 245 | ||
@@ -432,25 +435,6 @@ const struct xattr_handler *btrfs_xattr_handlers[] = { | |||
432 | NULL, | 435 | NULL, |
433 | }; | 436 | }; |
434 | 437 | ||
435 | int btrfs_setxattr(struct dentry *dentry, const char *name, const void *value, | ||
436 | size_t size, int flags) | ||
437 | { | ||
438 | struct btrfs_root *root = BTRFS_I(d_inode(dentry))->root; | ||
439 | |||
440 | if (btrfs_root_readonly(root)) | ||
441 | return -EROFS; | ||
442 | return generic_setxattr(dentry, name, value, size, flags); | ||
443 | } | ||
444 | |||
445 | int btrfs_removexattr(struct dentry *dentry, const char *name) | ||
446 | { | ||
447 | struct btrfs_root *root = BTRFS_I(d_inode(dentry))->root; | ||
448 | |||
449 | if (btrfs_root_readonly(root)) | ||
450 | return -EROFS; | ||
451 | return generic_removexattr(dentry, name); | ||
452 | } | ||
453 | |||
454 | static int btrfs_initxattrs(struct inode *inode, | 438 | static int btrfs_initxattrs(struct inode *inode, |
455 | const struct xattr *xattr_array, void *fs_info) | 439 | const struct xattr *xattr_array, void *fs_info) |
456 | { | 440 | { |
diff --git a/fs/btrfs/xattr.h b/fs/btrfs/xattr.h index 96807b3d22f5..15fc4743dc70 100644 --- a/fs/btrfs/xattr.h +++ b/fs/btrfs/xattr.h | |||
@@ -28,9 +28,6 @@ extern ssize_t __btrfs_getxattr(struct inode *inode, const char *name, | |||
28 | extern int __btrfs_setxattr(struct btrfs_trans_handle *trans, | 28 | extern int __btrfs_setxattr(struct btrfs_trans_handle *trans, |
29 | struct inode *inode, const char *name, | 29 | struct inode *inode, const char *name, |
30 | const void *value, size_t size, int flags); | 30 | const void *value, size_t size, int flags); |
31 | extern int btrfs_setxattr(struct dentry *dentry, const char *name, | ||
32 | const void *value, size_t size, int flags); | ||
33 | extern int btrfs_removexattr(struct dentry *dentry, const char *name); | ||
34 | 31 | ||
35 | extern int btrfs_xattr_security_init(struct btrfs_trans_handle *trans, | 32 | extern int btrfs_xattr_security_init(struct btrfs_trans_handle *trans, |
36 | struct inode *inode, struct inode *dir, | 33 | struct inode *inode, struct inode *dir, |