aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorYan <yanzheng@21cn.com>2008-01-08 15:54:37 -0500
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:03:59 -0400
commitb98b6767a0f6f9baa1d00eff64a43d58412ecdeb (patch)
treeb1c5346f462be12b268ff05049651bb3b880c7c9 /fs/btrfs/inode.c
parentc31f8830f0dfd31e7e196b85ca1b39aef8b77d57 (diff)
Btrfs: Add inode flags support
This patch adds NODATASUM & NODATACOW inode flags support. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 281757007ddb..fba0478a95f4 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -243,9 +243,9 @@ static int run_delalloc_range(struct inode *inode, u64 start, u64 end)
243 struct btrfs_root *root = BTRFS_I(inode)->root; 243 struct btrfs_root *root = BTRFS_I(inode)->root;
244 u64 num_bytes; 244 u64 num_bytes;
245 int ret; 245 int ret;
246
247 mutex_lock(&root->fs_info->fs_mutex); 246 mutex_lock(&root->fs_info->fs_mutex);
248 if (btrfs_test_opt(root, NODATACOW)) 247 if (btrfs_test_opt(root, NODATACOW) ||
248 btrfs_test_flag(inode, NODATACOW))
249 ret = run_delalloc_nocow(inode, start, end); 249 ret = run_delalloc_nocow(inode, start, end);
250 else 250 else
251 ret = cow_file_range(inode, start, end); 251 ret = cow_file_range(inode, start, end);
@@ -273,10 +273,9 @@ int btrfs_writepage_io_hook(struct page *page, u64 start, u64 end)
273 int ret = 0; 273 int ret = 0;
274 u64 page_start = (u64)page->index << PAGE_CACHE_SHIFT; 274 u64 page_start = (u64)page->index << PAGE_CACHE_SHIFT;
275 size_t offset = start - page_start; 275 size_t offset = start - page_start;
276 276 if (btrfs_test_opt(root, NODATASUM) ||
277 if (btrfs_test_opt(root, NODATASUM)) 277 btrfs_test_flag(inode, NODATASUM))
278 return 0; 278 return 0;
279
280 mutex_lock(&root->fs_info->fs_mutex); 279 mutex_lock(&root->fs_info->fs_mutex);
281 trans = btrfs_start_transaction(root, 1); 280 trans = btrfs_start_transaction(root, 1);
282 btrfs_set_trans_block_group(trans, inode); 281 btrfs_set_trans_block_group(trans, inode);
@@ -299,10 +298,9 @@ int btrfs_readpage_io_hook(struct page *page, u64 start, u64 end)
299 struct btrfs_csum_item *item; 298 struct btrfs_csum_item *item;
300 struct btrfs_path *path = NULL; 299 struct btrfs_path *path = NULL;
301 u32 csum; 300 u32 csum;
302 301 if (btrfs_test_opt(root, NODATASUM) ||
303 if (btrfs_test_opt(root, NODATASUM)) 302 btrfs_test_flag(inode, NODATASUM))
304 return 0; 303 return 0;
305
306 mutex_lock(&root->fs_info->fs_mutex); 304 mutex_lock(&root->fs_info->fs_mutex);
307 path = btrfs_alloc_path(); 305 path = btrfs_alloc_path();
308 item = btrfs_lookup_csum(NULL, root, path, inode->i_ino, start, 0); 306 item = btrfs_lookup_csum(NULL, root, path, inode->i_ino, start, 0);
@@ -335,10 +333,9 @@ int btrfs_readpage_end_io_hook(struct page *page, u64 start, u64 end)
335 struct btrfs_root *root = BTRFS_I(inode)->root; 333 struct btrfs_root *root = BTRFS_I(inode)->root;
336 u32 csum = ~(u32)0; 334 u32 csum = ~(u32)0;
337 unsigned long flags; 335 unsigned long flags;
338 336 if (btrfs_test_opt(root, NODATASUM) ||
339 if (btrfs_test_opt(root, NODATASUM)) 337 btrfs_test_flag(inode, NODATASUM))
340 return 0; 338 return 0;
341
342 ret = get_state_private(em_tree, start, &private); 339 ret = get_state_private(em_tree, start, &private);
343 local_irq_save(flags); 340 local_irq_save(flags);
344 kaddr = kmap_atomic(page, KM_IRQ0); 341 kaddr = kmap_atomic(page, KM_IRQ0);
@@ -415,7 +412,7 @@ void btrfs_read_locked_inode(struct inode *inode)
415 alloc_group_block = btrfs_inode_block_group(leaf, inode_item); 412 alloc_group_block = btrfs_inode_block_group(leaf, inode_item);
416 BTRFS_I(inode)->block_group = btrfs_lookup_block_group(root->fs_info, 413 BTRFS_I(inode)->block_group = btrfs_lookup_block_group(root->fs_info,
417 alloc_group_block); 414 alloc_group_block);
418 415 BTRFS_I(inode)->flags = btrfs_inode_flags(leaf, inode_item);
419 if (!BTRFS_I(inode)->block_group) { 416 if (!BTRFS_I(inode)->block_group) {
420 BTRFS_I(inode)->block_group = btrfs_find_block_group(root, 417 BTRFS_I(inode)->block_group = btrfs_find_block_group(root,
421 NULL, 0, 0, 0); 418 NULL, 0, 0, 0);
@@ -484,6 +481,7 @@ static void fill_inode_item(struct extent_buffer *leaf,
484 btrfs_set_inode_nblocks(leaf, item, inode->i_blocks); 481 btrfs_set_inode_nblocks(leaf, item, inode->i_blocks);
485 btrfs_set_inode_generation(leaf, item, inode->i_generation); 482 btrfs_set_inode_generation(leaf, item, inode->i_generation);
486 btrfs_set_inode_rdev(leaf, item, inode->i_rdev); 483 btrfs_set_inode_rdev(leaf, item, inode->i_rdev);
484 btrfs_set_inode_flags(leaf, item, BTRFS_I(inode)->flags);
487 btrfs_set_inode_block_group(leaf, item, 485 btrfs_set_inode_block_group(leaf, item,
488 BTRFS_I(inode)->block_group->key.objectid); 486 BTRFS_I(inode)->block_group->key.objectid);
489} 487}
@@ -1454,7 +1452,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
1454 owner = 1; 1452 owner = 1;
1455 group = btrfs_find_block_group(root, group, 0, 0, owner); 1453 group = btrfs_find_block_group(root, group, 0, 0, owner);
1456 BTRFS_I(inode)->block_group = group; 1454 BTRFS_I(inode)->block_group = group;
1457 1455 BTRFS_I(inode)->flags = 0;
1458 ret = btrfs_insert_empty_inode(trans, root, path, objectid); 1456 ret = btrfs_insert_empty_inode(trans, root, path, objectid);
1459 if (ret) 1457 if (ret)
1460 goto fail; 1458 goto fail;