]> git.openpandora.org Git - pandora-kernel.git/commitdiff
Btrfs: optimize btrget/set/removexattr
authorChristoph Hellwig <hch@lst.de>
Thu, 28 Aug 2008 10:21:17 +0000 (06:21 -0400)
committerChris Mason <chris.mason@oracle.com>
Thu, 25 Sep 2008 15:04:07 +0000 (11:04 -0400)
btrfs actually stores the whole xattr name, including the prefix ondisk,
so using the generic resolver that strips off the prefix is not very
helpful.  Instead do the real ondisk xattrs manually and only use the
generic resolver for synthetic xattrs like ACLs.

(Sorry Josef for guiding you towards the wrong direction here intially)

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/acl.c
fs/btrfs/inode.c
fs/btrfs/xattr.c
fs/btrfs/xattr.h

index 2f865311460c8ea977c9c12c478a04c3d4ffb910..867eaf1f8efb8a9abc3d442012c3ecef6121b7d4 100644 (file)
@@ -42,17 +42,18 @@ static void btrfs_update_cached_acl(struct inode *inode,
 
 static struct posix_acl *btrfs_get_acl(struct inode *inode, int type)
 {
-       int size, name_index;
+       int size;
+       const char *name;
        char *value = NULL;
        struct posix_acl *acl = NULL, **p_acl;
 
        switch (type) {
        case ACL_TYPE_ACCESS:
-               name_index = BTRFS_XATTR_INDEX_POSIX_ACL_ACCESS;
+               name = POSIX_ACL_XATTR_ACCESS;
                p_acl = &BTRFS_I(inode)->i_acl;
                break;
        case ACL_TYPE_DEFAULT:
-               name_index = BTRFS_XATTR_INDEX_POSIX_ACL_DEFAULT;
+               name = POSIX_ACL_XATTR_DEFAULT;
                p_acl = &BTRFS_I(inode)->i_default_acl;
                break;
        default:
@@ -68,12 +69,12 @@ static struct posix_acl *btrfs_get_acl(struct inode *inode, int type)
                return acl;
 
 
-       size = btrfs_xattr_get(inode, name_index, "", NULL, 0);
+       size = __btrfs_getxattr(inode, name, "", 0);
        if (size > 0) {
                value = kzalloc(size, GFP_NOFS);
                if (!value)
                        return ERR_PTR(-ENOMEM);
-               size = btrfs_xattr_get(inode, name_index, "", value, size);
+               size = __btrfs_getxattr(inode, name, value, size);
                if (size > 0) {
                        acl = posix_acl_from_xattr(value, size);
                        btrfs_update_cached_acl(inode, p_acl, acl);
@@ -110,7 +111,8 @@ static int btrfs_xattr_get_acl(struct inode *inode, int type,
  */
 static int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 {
-       int ret, name_index = 0, size = 0;
+       int ret, size = 0;
+       const char *name;
        struct posix_acl **p_acl;
        char *value = NULL;
        mode_t mode;
@@ -130,13 +132,13 @@ static int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
                        return ret;
                ret = 0;
                inode->i_mode = mode;
-               name_index = BTRFS_XATTR_INDEX_POSIX_ACL_ACCESS;
+               name = POSIX_ACL_XATTR_ACCESS;
                p_acl = &BTRFS_I(inode)->i_acl;
                break;
        case ACL_TYPE_DEFAULT:
                if (!S_ISDIR(inode->i_mode))
                        return acl ? -EINVAL : 0;
-               name_index = BTRFS_XATTR_INDEX_POSIX_ACL_DEFAULT;
+               name = POSIX_ACL_XATTR_DEFAULT;
                p_acl = &BTRFS_I(inode)->i_default_acl;
                break;
        default:
@@ -156,7 +158,7 @@ static int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
                        goto out;
        }
 
-       ret = btrfs_xattr_set(inode, name_index, "", value, size, 0);
+       ret = __btrfs_setxattr(inode, name, value, size, 0);
 
 out:
        if (value)
index 10f26f445328b40e442792e4347975bb3f2c0498..43d3f2649ca3877262464507d416a813f5306ea8 100644 (file)
@@ -45,6 +45,7 @@
 #include "print-tree.h"
 #include "volumes.h"
 #include "ordered-data.h"
+#include "xattr.h"
 
 struct btrfs_iget_args {
        u64 ino;
@@ -3667,10 +3668,10 @@ static struct inode_operations btrfs_dir_inode_operations = {
        .symlink        = btrfs_symlink,
        .setattr        = btrfs_setattr,
        .mknod          = btrfs_mknod,
-       .setxattr       = generic_setxattr,
-       .getxattr       = generic_getxattr,
+       .setxattr       = btrfs_setxattr,
+       .getxattr       = btrfs_getxattr,
        .listxattr      = btrfs_listxattr,
-       .removexattr    = generic_removexattr,
+       .removexattr    = btrfs_removexattr,
        .permission     = btrfs_permission,
 };
 static struct inode_operations btrfs_dir_ro_inode_operations = {
@@ -3728,20 +3729,20 @@ static struct inode_operations btrfs_file_inode_operations = {
        .truncate       = btrfs_truncate,
        .getattr        = btrfs_getattr,
        .setattr        = btrfs_setattr,
-       .setxattr       = generic_setxattr,
-       .getxattr       = generic_getxattr,
+       .setxattr       = btrfs_setxattr,
+       .getxattr       = btrfs_getxattr,
        .listxattr      = btrfs_listxattr,
-       .removexattr    = generic_removexattr,
+       .removexattr    = btrfs_removexattr,
        .permission     = btrfs_permission,
 };
 static struct inode_operations btrfs_special_inode_operations = {
        .getattr        = btrfs_getattr,
        .setattr        = btrfs_setattr,
        .permission     = btrfs_permission,
-       .setxattr       = generic_setxattr,
-       .getxattr       = generic_getxattr,
+       .setxattr       = btrfs_setxattr,
+       .getxattr       = btrfs_getxattr,
        .listxattr      = btrfs_listxattr,
-       .removexattr    = generic_removexattr,
+       .removexattr    = btrfs_removexattr,
 };
 static struct inode_operations btrfs_symlink_inode_operations = {
        .readlink       = generic_readlink,
Simple merge
Simple merge