aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@redhat.com>2008-07-24 12:16:36 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:05 -0400
commit33268eaf0b3db5e2bd12c0ada81a8e8f87a46d68 (patch)
tree93b6d00a73402b59c2ea7ae7434138feecefc085 /fs/btrfs/inode.c
parent6099afe88fe64b2f47c43a8a71c13be3a416bbf7 (diff)
Btrfs: Add ACL support
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 8d371d6fe551..2d8853543a71 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -36,6 +36,7 @@
36#include <linux/bit_spinlock.h> 36#include <linux/bit_spinlock.h>
37#include <linux/version.h> 37#include <linux/version.h>
38#include <linux/xattr.h> 38#include <linux/xattr.h>
39#include <linux/posix_acl.h>
39#include "ctree.h" 40#include "ctree.h"
40#include "disk-io.h" 41#include "disk-io.h"
41#include "transaction.h" 42#include "transaction.h"
@@ -1478,6 +1479,9 @@ static int btrfs_setattr(struct dentry *dentry, struct iattr *attr)
1478 } 1479 }
1479out: 1480out:
1480 err = inode_setattr(inode, attr); 1481 err = inode_setattr(inode, attr);
1482
1483 if (!err && ((attr->ia_valid & ATTR_MODE)))
1484 err = btrfs_acl_chmod(inode);
1481fail: 1485fail:
1482 return err; 1486 return err;
1483} 1487}
@@ -2184,6 +2188,12 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry,
2184 if (IS_ERR(inode)) 2188 if (IS_ERR(inode))
2185 goto out_unlock; 2189 goto out_unlock;
2186 2190
2191 err = btrfs_init_acl(inode, dir);
2192 if (err) {
2193 drop_inode = 1;
2194 goto out_unlock;
2195 }
2196
2187 btrfs_set_trans_block_group(trans, inode); 2197 btrfs_set_trans_block_group(trans, inode);
2188 err = btrfs_add_nondir(trans, dentry, inode, 0); 2198 err = btrfs_add_nondir(trans, dentry, inode, 0);
2189 if (err) 2199 if (err)
@@ -2239,6 +2249,12 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
2239 if (IS_ERR(inode)) 2249 if (IS_ERR(inode))
2240 goto out_unlock; 2250 goto out_unlock;
2241 2251
2252 err = btrfs_init_acl(inode, dir);
2253 if (err) {
2254 drop_inode = 1;
2255 goto out_unlock;
2256 }
2257
2242 btrfs_set_trans_block_group(trans, inode); 2258 btrfs_set_trans_block_group(trans, inode);
2243 err = btrfs_add_nondir(trans, dentry, inode, 0); 2259 err = btrfs_add_nondir(trans, dentry, inode, 0);
2244 if (err) 2260 if (err)
@@ -2366,6 +2382,11 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
2366 } 2382 }
2367 2383
2368 drop_on_err = 1; 2384 drop_on_err = 1;
2385
2386 err = btrfs_init_acl(inode, dir);
2387 if (err)
2388 goto out_fail;
2389
2369 inode->i_op = &btrfs_dir_inode_operations; 2390 inode->i_op = &btrfs_dir_inode_operations;
2370 inode->i_fop = &btrfs_dir_file_operations; 2391 inode->i_fop = &btrfs_dir_file_operations;
2371 btrfs_set_trans_block_group(trans, inode); 2392 btrfs_set_trans_block_group(trans, inode);
@@ -3023,6 +3044,8 @@ struct inode *btrfs_alloc_inode(struct super_block *sb)
3023 return NULL; 3044 return NULL;
3024 ei->last_trans = 0; 3045 ei->last_trans = 0;
3025 btrfs_ordered_inode_tree_init(&ei->ordered_tree); 3046 btrfs_ordered_inode_tree_init(&ei->ordered_tree);
3047 ei->i_acl = BTRFS_ACL_NOT_CACHED;
3048 ei->i_default_acl = BTRFS_ACL_NOT_CACHED;
3026 return &ei->vfs_inode; 3049 return &ei->vfs_inode;
3027} 3050}
3028 3051
@@ -3032,6 +3055,13 @@ void btrfs_destroy_inode(struct inode *inode)
3032 WARN_ON(!list_empty(&inode->i_dentry)); 3055 WARN_ON(!list_empty(&inode->i_dentry));
3033 WARN_ON(inode->i_data.nrpages); 3056 WARN_ON(inode->i_data.nrpages);
3034 3057
3058 if (BTRFS_I(inode)->i_acl &&
3059 BTRFS_I(inode)->i_acl != BTRFS_ACL_NOT_CACHED)
3060 posix_acl_release(BTRFS_I(inode)->i_acl);
3061 if (BTRFS_I(inode)->i_default_acl &&
3062 BTRFS_I(inode)->i_default_acl != BTRFS_ACL_NOT_CACHED)
3063 posix_acl_release(BTRFS_I(inode)->i_default_acl);
3064
3035 while(1) { 3065 while(1) {
3036 ordered = btrfs_lookup_first_ordered_extent(inode, (u64)-1); 3066 ordered = btrfs_lookup_first_ordered_extent(inode, (u64)-1);
3037 if (!ordered) 3067 if (!ordered)
@@ -3230,6 +3260,12 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry,
3230 if (IS_ERR(inode)) 3260 if (IS_ERR(inode))
3231 goto out_unlock; 3261 goto out_unlock;
3232 3262
3263 err = btrfs_init_acl(inode, dir);
3264 if (err) {
3265 drop_inode = 1;
3266 goto out_unlock;
3267 }
3268
3233 btrfs_set_trans_block_group(trans, inode); 3269 btrfs_set_trans_block_group(trans, inode);
3234 err = btrfs_add_nondir(trans, dentry, inode, 0); 3270 err = btrfs_add_nondir(trans, dentry, inode, 0);
3235 if (err) 3271 if (err)
@@ -3310,7 +3346,7 @@ static int btrfs_permission(struct inode *inode, int mask,
3310{ 3346{
3311 if (btrfs_test_flag(inode, READONLY) && (mask & MAY_WRITE)) 3347 if (btrfs_test_flag(inode, READONLY) && (mask & MAY_WRITE))
3312 return -EACCES; 3348 return -EACCES;
3313 return generic_permission(inode, mask, NULL); 3349 return generic_permission(inode, mask, btrfs_check_acl);
3314} 3350}
3315 3351
3316static struct inode_operations btrfs_dir_inode_operations = { 3352static struct inode_operations btrfs_dir_inode_operations = {
@@ -3392,6 +3428,10 @@ static struct inode_operations btrfs_special_inode_operations = {
3392 .getattr = btrfs_getattr, 3428 .getattr = btrfs_getattr,
3393 .setattr = btrfs_setattr, 3429 .setattr = btrfs_setattr,
3394 .permission = btrfs_permission, 3430 .permission = btrfs_permission,
3431 .setxattr = generic_setxattr,
3432 .getxattr = generic_getxattr,
3433 .listxattr = btrfs_listxattr,
3434 .removexattr = generic_removexattr,
3395}; 3435};
3396static struct inode_operations btrfs_symlink_inode_operations = { 3436static struct inode_operations btrfs_symlink_inode_operations = {
3397 .readlink = generic_readlink, 3437 .readlink = generic_readlink,