diff options
-rw-r--r-- | fs/btrfs/btrfs_inode.h | 1 | ||||
-rw-r--r-- | fs/btrfs/ctree.h | 13 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 24 |
3 files changed, 24 insertions, 14 deletions
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h index f27e633f1742..9fc99883c70a 100644 --- a/fs/btrfs/btrfs_inode.h +++ b/fs/btrfs/btrfs_inode.h | |||
@@ -34,6 +34,7 @@ struct btrfs_inode { | |||
34 | * transid of the trans_handle that last modified this inode | 34 | * transid of the trans_handle that last modified this inode |
35 | */ | 35 | */ |
36 | u64 last_trans; | 36 | u64 last_trans; |
37 | u32 flags; | ||
37 | }; | 38 | }; |
38 | static inline struct btrfs_inode *BTRFS_I(struct inode *inode) | 39 | static inline struct btrfs_inode *BTRFS_I(struct inode *inode) |
39 | { | 40 | { |
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index f0fb1978553c..7eda51542d17 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -447,7 +447,18 @@ struct btrfs_root { | |||
447 | #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt) | 447 | #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt) |
448 | #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \ | 448 | #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \ |
449 | BTRFS_MOUNT_##opt) | 449 | BTRFS_MOUNT_##opt) |
450 | 450 | /* | |
451 | * Inode flags | ||
452 | */ | ||
453 | #define BTRFS_INODE_NODATASUM 0x1 | ||
454 | #define BTRFS_INODE_NODATACOW 0x2 | ||
455 | |||
456 | #define btrfs_clear_flag(inode, flag) (BTRFS_I(inode)->flags &= \ | ||
457 | ~BTRFS_INODE_##flag) | ||
458 | #define btrfs_set_flag(inode, flag) (BTRFS_I(inode)->flags |= \ | ||
459 | BTRFS_INODE_##flag) | ||
460 | #define btrfs_test_flag(inode, flag) (BTRFS_I(inode)->flags & \ | ||
461 | BTRFS_INODE_##flag) | ||
451 | /* some macros to generate set/get funcs for the struct fields. This | 462 | /* some macros to generate set/get funcs for the struct fields. This |
452 | * assumes there is a lefoo_to_cpu for every type, so lets make a simple | 463 | * assumes there is a lefoo_to_cpu for every type, so lets make a simple |
453 | * one for u8: | 464 | * one for u8: |
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; |