aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2013-06-19 10:16:26 -0400
committerJosef Bacik <jbacik@fusionio.com>2013-07-02 11:50:40 -0400
commitf23b5a59955c0ea13c6da211fb06f39348e3c794 (patch)
treef30d37d643701406d095d4be39e1e14ec38e2669 /fs/btrfs/inode.c
parenta71754fc68f740b7ed46bb83123c63fbbc130611 (diff)
Btrfs: check for actual acls rather than just xattrs when caching no acl
We have an optimization that will go ahead and cache no acls on an inode if there are no xattrs on the inode. This saves us a lookup later to check the acls for writes or any other access. The problem is I use selinux so I always have an xattr on inodes, so make this test a little smarter and check for the actual acl hash on the key and if it isn't there then we still get to cache no acl which makes everybody who uses selinux a little happier. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index b7fa96f72ecd..8edcdf6910f7 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -41,6 +41,7 @@
41#include <linux/mount.h> 41#include <linux/mount.h>
42#include <linux/btrfs.h> 42#include <linux/btrfs.h>
43#include <linux/blkdev.h> 43#include <linux/blkdev.h>
44#include <linux/posix_acl_xattr.h>
44#include "compat.h" 45#include "compat.h"
45#include "ctree.h" 46#include "ctree.h"
46#include "disk-io.h" 47#include "disk-io.h"
@@ -56,6 +57,7 @@
56#include "free-space-cache.h" 57#include "free-space-cache.h"
57#include "inode-map.h" 58#include "inode-map.h"
58#include "backref.h" 59#include "backref.h"
60#include "hash.h"
59 61
60struct btrfs_iget_args { 62struct btrfs_iget_args {
61 u64 ino; 63 u64 ino;
@@ -3300,8 +3302,17 @@ static noinline int acls_after_inode_item(struct extent_buffer *leaf,
3300{ 3302{
3301 u32 nritems = btrfs_header_nritems(leaf); 3303 u32 nritems = btrfs_header_nritems(leaf);
3302 struct btrfs_key found_key; 3304 struct btrfs_key found_key;
3305 static u64 xattr_access = 0;
3306 static u64 xattr_default = 0;
3303 int scanned = 0; 3307 int scanned = 0;
3304 3308
3309 if (!xattr_access) {
3310 xattr_access = btrfs_name_hash(POSIX_ACL_XATTR_ACCESS,
3311 strlen(POSIX_ACL_XATTR_ACCESS));
3312 xattr_default = btrfs_name_hash(POSIX_ACL_XATTR_DEFAULT,
3313 strlen(POSIX_ACL_XATTR_DEFAULT));
3314 }
3315
3305 slot++; 3316 slot++;
3306 while (slot < nritems) { 3317 while (slot < nritems) {
3307 btrfs_item_key_to_cpu(leaf, &found_key, slot); 3318 btrfs_item_key_to_cpu(leaf, &found_key, slot);
@@ -3311,8 +3322,11 @@ static noinline int acls_after_inode_item(struct extent_buffer *leaf,
3311 return 0; 3322 return 0;
3312 3323
3313 /* we found an xattr, assume we've got an acl */ 3324 /* we found an xattr, assume we've got an acl */
3314 if (found_key.type == BTRFS_XATTR_ITEM_KEY) 3325 if (found_key.type == BTRFS_XATTR_ITEM_KEY) {
3315 return 1; 3326 if (found_key.offset == xattr_access ||
3327 found_key.offset == xattr_default)
3328 return 1;
3329 }
3316 3330
3317 /* 3331 /*
3318 * we found a key greater than an xattr key, there can't 3332 * we found a key greater than an xattr key, there can't