aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2009-04-17 04:37:41 -0400
committerChris Mason <chris.mason@oracle.com>2009-06-10 11:29:52 -0400
commit6cbff00f4632c8060b06bfc9585805217f11e12e (patch)
tree1886c4c855662172b84be2bfbd2aa5ac6a5c429d /fs/btrfs/inode.c
parentc289811cc096c57ff35550ee8132793a4f9b5b59 (diff)
Btrfs: implement FS_IOC_GETFLAGS/SETFLAGS/GETVERSION
Add support for the standard attributes set via chattr and read via lsattr. Currently we store the attributes in the flags value in the btrfs inode, but I wonder whether we should split it into two so that we don't have to keep converting between the two formats. Remove the btrfs_clear_flag/btrfs_set_flag/btrfs_test_flag macros as they were confusing the existing code and got in the way of the new additions. Also add the FS_IOC_GETVERSION ioctl for getting i_generation as it's trivial. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 917bf10597c6..5b68330f8585 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -368,7 +368,7 @@ again:
368 * inode has not been flagged as nocompress. This flag can 368 * inode has not been flagged as nocompress. This flag can
369 * change at any time if we discover bad compression ratios. 369 * change at any time if we discover bad compression ratios.
370 */ 370 */
371 if (!btrfs_test_flag(inode, NOCOMPRESS) && 371 if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NOCOMPRESS) &&
372 btrfs_test_opt(root, COMPRESS)) { 372 btrfs_test_opt(root, COMPRESS)) {
373 WARN_ON(pages); 373 WARN_ON(pages);
374 pages = kzalloc(sizeof(struct page *) * nr_pages, GFP_NOFS); 374 pages = kzalloc(sizeof(struct page *) * nr_pages, GFP_NOFS);
@@ -469,7 +469,7 @@ again:
469 nr_pages_ret = 0; 469 nr_pages_ret = 0;
470 470
471 /* flag the file so we don't compress in the future */ 471 /* flag the file so we don't compress in the future */
472 btrfs_set_flag(inode, NOCOMPRESS); 472 BTRFS_I(inode)->flags |= BTRFS_INODE_NOCOMPRESS;
473 } 473 }
474 if (will_compress) { 474 if (will_compress) {
475 *num_added += 1; 475 *num_added += 1;
@@ -862,7 +862,7 @@ static int cow_file_range_async(struct inode *inode, struct page *locked_page,
862 async_cow->locked_page = locked_page; 862 async_cow->locked_page = locked_page;
863 async_cow->start = start; 863 async_cow->start = start;
864 864
865 if (btrfs_test_flag(inode, NOCOMPRESS)) 865 if (BTRFS_I(inode)->flags & BTRFS_INODE_NOCOMPRESS)
866 cur_end = end; 866 cur_end = end;
867 else 867 else
868 cur_end = min(end, start + 512 * 1024 - 1); 868 cur_end = min(end, start + 512 * 1024 - 1);
@@ -1133,10 +1133,10 @@ static int run_delalloc_range(struct inode *inode, struct page *locked_page,
1133 int ret; 1133 int ret;
1134 struct btrfs_root *root = BTRFS_I(inode)->root; 1134 struct btrfs_root *root = BTRFS_I(inode)->root;
1135 1135
1136 if (btrfs_test_flag(inode, NODATACOW)) 1136 if (BTRFS_I(inode)->flags & BTRFS_INODE_NODATACOW)
1137 ret = run_delalloc_nocow(inode, locked_page, start, end, 1137 ret = run_delalloc_nocow(inode, locked_page, start, end,
1138 page_started, 1, nr_written); 1138 page_started, 1, nr_written);
1139 else if (btrfs_test_flag(inode, PREALLOC)) 1139 else if (BTRFS_I(inode)->flags & BTRFS_INODE_PREALLOC)
1140 ret = run_delalloc_nocow(inode, locked_page, start, end, 1140 ret = run_delalloc_nocow(inode, locked_page, start, end,
1141 page_started, 0, nr_written); 1141 page_started, 0, nr_written);
1142 else if (!btrfs_test_opt(root, COMPRESS)) 1142 else if (!btrfs_test_opt(root, COMPRESS))
@@ -1290,7 +1290,7 @@ static int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
1290 int ret = 0; 1290 int ret = 0;
1291 int skip_sum; 1291 int skip_sum;
1292 1292
1293 skip_sum = btrfs_test_flag(inode, NODATASUM); 1293 skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;
1294 1294
1295 ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0); 1295 ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0);
1296 BUG_ON(ret); 1296 BUG_ON(ret);
@@ -1790,7 +1790,8 @@ static int btrfs_readpage_end_io_hook(struct page *page, u64 start, u64 end,
1790 ClearPageChecked(page); 1790 ClearPageChecked(page);
1791 goto good; 1791 goto good;
1792 } 1792 }
1793 if (btrfs_test_flag(inode, NODATASUM)) 1793
1794 if (BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)
1794 return 0; 1795 return 0;
1795 1796
1796 if (root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID && 1797 if (root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID &&
@@ -2156,6 +2157,8 @@ static void btrfs_read_locked_inode(struct inode *inode)
2156 init_special_inode(inode, inode->i_mode, rdev); 2157 init_special_inode(inode, inode->i_mode, rdev);
2157 break; 2158 break;
2158 } 2159 }
2160
2161 btrfs_update_iflags(inode);
2159 return; 2162 return;
2160 2163
2161make_bad: 2164make_bad:
@@ -3586,9 +3589,9 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
3586 btrfs_find_block_group(root, 0, alloc_hint, owner); 3589 btrfs_find_block_group(root, 0, alloc_hint, owner);
3587 if ((mode & S_IFREG)) { 3590 if ((mode & S_IFREG)) {
3588 if (btrfs_test_opt(root, NODATASUM)) 3591 if (btrfs_test_opt(root, NODATASUM))
3589 btrfs_set_flag(inode, NODATASUM); 3592 BTRFS_I(inode)->flags |= BTRFS_INODE_NODATASUM;
3590 if (btrfs_test_opt(root, NODATACOW)) 3593 if (btrfs_test_opt(root, NODATACOW))
3591 btrfs_set_flag(inode, NODATACOW); 3594 BTRFS_I(inode)->flags |= BTRFS_INODE_NODATACOW;
3592 } 3595 }
3593 3596
3594 key[0].objectid = objectid; 3597 key[0].objectid = objectid;
@@ -3642,6 +3645,8 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
3642 location->offset = 0; 3645 location->offset = 0;
3643 btrfs_set_key_type(location, BTRFS_INODE_ITEM_KEY); 3646 btrfs_set_key_type(location, BTRFS_INODE_ITEM_KEY);
3644 3647
3648 btrfs_inherit_iflags(inode, dir);
3649
3645 insert_inode_hash(inode); 3650 insert_inode_hash(inode);
3646 inode_tree_add(inode); 3651 inode_tree_add(inode);
3647 return inode; 3652 return inode;
@@ -5075,7 +5080,7 @@ static int prealloc_file_range(struct btrfs_trans_handle *trans,
5075out: 5080out:
5076 if (cur_offset > start) { 5081 if (cur_offset > start) {
5077 inode->i_ctime = CURRENT_TIME; 5082 inode->i_ctime = CURRENT_TIME;
5078 btrfs_set_flag(inode, PREALLOC); 5083 BTRFS_I(inode)->flags |= BTRFS_INODE_PREALLOC;
5079 if (!(mode & FALLOC_FL_KEEP_SIZE) && 5084 if (!(mode & FALLOC_FL_KEEP_SIZE) &&
5080 cur_offset > i_size_read(inode)) 5085 cur_offset > i_size_read(inode))
5081 btrfs_i_size_write(inode, cur_offset); 5086 btrfs_i_size_write(inode, cur_offset);
@@ -5196,7 +5201,7 @@ static int btrfs_set_page_dirty(struct page *page)
5196 5201
5197static int btrfs_permission(struct inode *inode, int mask) 5202static int btrfs_permission(struct inode *inode, int mask)
5198{ 5203{
5199 if (btrfs_test_flag(inode, READONLY) && (mask & MAY_WRITE)) 5204 if ((BTRFS_I(inode)->flags & BTRFS_INODE_READONLY) && (mask & MAY_WRITE))
5200 return -EACCES; 5205 return -EACCES;
5201 return generic_permission(inode, mask, btrfs_check_acl); 5206 return generic_permission(inode, mask, btrfs_check_acl);
5202} 5207}