diff options
author | Chris Mason <chris.mason@oracle.com> | 2011-07-27 16:13:10 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2011-07-27 16:18:13 -0400 |
commit | ff95acb6733d41a8d45feb0e18b96df25e610e78 (patch) | |
tree | e20983c579c9095970aefa9cb176a9df0654d1e4 /fs/btrfs/inode.c | |
parent | 02f8c6aee8df3cdc935e9bdd4f2d020306035dbe (diff) | |
parent | 75c195a2cac2c3c8366c0b87de2d6814c4f4d638 (diff) |
Merge branch 'integration' into for-linus
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 90 |
1 files changed, 34 insertions, 56 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 3601f0aebddf..586cf6a43855 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -750,15 +750,6 @@ static u64 get_extent_allocation_hint(struct inode *inode, u64 start, | |||
750 | return alloc_hint; | 750 | return alloc_hint; |
751 | } | 751 | } |
752 | 752 | ||
753 | static inline bool is_free_space_inode(struct btrfs_root *root, | ||
754 | struct inode *inode) | ||
755 | { | ||
756 | if (root == root->fs_info->tree_root || | ||
757 | BTRFS_I(inode)->location.objectid == BTRFS_FREE_INO_OBJECTID) | ||
758 | return true; | ||
759 | return false; | ||
760 | } | ||
761 | |||
762 | /* | 753 | /* |
763 | * when extent_io.c finds a delayed allocation range in the file, | 754 | * when extent_io.c finds a delayed allocation range in the file, |
764 | * the call backs end up in this code. The basic idea is to | 755 | * the call backs end up in this code. The basic idea is to |
@@ -791,7 +782,7 @@ static noinline int cow_file_range(struct inode *inode, | |||
791 | struct extent_map_tree *em_tree = &BTRFS_I(inode)->extent_tree; | 782 | struct extent_map_tree *em_tree = &BTRFS_I(inode)->extent_tree; |
792 | int ret = 0; | 783 | int ret = 0; |
793 | 784 | ||
794 | BUG_ON(is_free_space_inode(root, inode)); | 785 | BUG_ON(btrfs_is_free_space_inode(root, inode)); |
795 | trans = btrfs_join_transaction(root); | 786 | trans = btrfs_join_transaction(root); |
796 | BUG_ON(IS_ERR(trans)); | 787 | BUG_ON(IS_ERR(trans)); |
797 | trans->block_rsv = &root->fs_info->delalloc_block_rsv; | 788 | trans->block_rsv = &root->fs_info->delalloc_block_rsv; |
@@ -1072,7 +1063,7 @@ static noinline int run_delalloc_nocow(struct inode *inode, | |||
1072 | path = btrfs_alloc_path(); | 1063 | path = btrfs_alloc_path(); |
1073 | BUG_ON(!path); | 1064 | BUG_ON(!path); |
1074 | 1065 | ||
1075 | nolock = is_free_space_inode(root, inode); | 1066 | nolock = btrfs_is_free_space_inode(root, inode); |
1076 | 1067 | ||
1077 | if (nolock) | 1068 | if (nolock) |
1078 | trans = btrfs_join_transaction_nolock(root); | 1069 | trans = btrfs_join_transaction_nolock(root); |
@@ -1298,7 +1289,9 @@ static int btrfs_split_extent_hook(struct inode *inode, | |||
1298 | if (!(orig->state & EXTENT_DELALLOC)) | 1289 | if (!(orig->state & EXTENT_DELALLOC)) |
1299 | return 0; | 1290 | return 0; |
1300 | 1291 | ||
1301 | atomic_inc(&BTRFS_I(inode)->outstanding_extents); | 1292 | spin_lock(&BTRFS_I(inode)->lock); |
1293 | BTRFS_I(inode)->outstanding_extents++; | ||
1294 | spin_unlock(&BTRFS_I(inode)->lock); | ||
1302 | return 0; | 1295 | return 0; |
1303 | } | 1296 | } |
1304 | 1297 | ||
@@ -1316,7 +1309,9 @@ static int btrfs_merge_extent_hook(struct inode *inode, | |||
1316 | if (!(other->state & EXTENT_DELALLOC)) | 1309 | if (!(other->state & EXTENT_DELALLOC)) |
1317 | return 0; | 1310 | return 0; |
1318 | 1311 | ||
1319 | atomic_dec(&BTRFS_I(inode)->outstanding_extents); | 1312 | spin_lock(&BTRFS_I(inode)->lock); |
1313 | BTRFS_I(inode)->outstanding_extents--; | ||
1314 | spin_unlock(&BTRFS_I(inode)->lock); | ||
1320 | return 0; | 1315 | return 0; |
1321 | } | 1316 | } |
1322 | 1317 | ||
@@ -1337,12 +1332,15 @@ static int btrfs_set_bit_hook(struct inode *inode, | |||
1337 | if (!(state->state & EXTENT_DELALLOC) && (*bits & EXTENT_DELALLOC)) { | 1332 | if (!(state->state & EXTENT_DELALLOC) && (*bits & EXTENT_DELALLOC)) { |
1338 | struct btrfs_root *root = BTRFS_I(inode)->root; | 1333 | struct btrfs_root *root = BTRFS_I(inode)->root; |
1339 | u64 len = state->end + 1 - state->start; | 1334 | u64 len = state->end + 1 - state->start; |
1340 | bool do_list = !is_free_space_inode(root, inode); | 1335 | bool do_list = !btrfs_is_free_space_inode(root, inode); |
1341 | 1336 | ||
1342 | if (*bits & EXTENT_FIRST_DELALLOC) | 1337 | if (*bits & EXTENT_FIRST_DELALLOC) { |
1343 | *bits &= ~EXTENT_FIRST_DELALLOC; | 1338 | *bits &= ~EXTENT_FIRST_DELALLOC; |
1344 | else | 1339 | } else { |
1345 | atomic_inc(&BTRFS_I(inode)->outstanding_extents); | 1340 | spin_lock(&BTRFS_I(inode)->lock); |
1341 | BTRFS_I(inode)->outstanding_extents++; | ||
1342 | spin_unlock(&BTRFS_I(inode)->lock); | ||
1343 | } | ||
1346 | 1344 | ||
1347 | spin_lock(&root->fs_info->delalloc_lock); | 1345 | spin_lock(&root->fs_info->delalloc_lock); |
1348 | BTRFS_I(inode)->delalloc_bytes += len; | 1346 | BTRFS_I(inode)->delalloc_bytes += len; |
@@ -1370,12 +1368,15 @@ static int btrfs_clear_bit_hook(struct inode *inode, | |||
1370 | if ((state->state & EXTENT_DELALLOC) && (*bits & EXTENT_DELALLOC)) { | 1368 | if ((state->state & EXTENT_DELALLOC) && (*bits & EXTENT_DELALLOC)) { |
1371 | struct btrfs_root *root = BTRFS_I(inode)->root; | 1369 | struct btrfs_root *root = BTRFS_I(inode)->root; |
1372 | u64 len = state->end + 1 - state->start; | 1370 | u64 len = state->end + 1 - state->start; |
1373 | bool do_list = !is_free_space_inode(root, inode); | 1371 | bool do_list = !btrfs_is_free_space_inode(root, inode); |
1374 | 1372 | ||
1375 | if (*bits & EXTENT_FIRST_DELALLOC) | 1373 | if (*bits & EXTENT_FIRST_DELALLOC) { |
1376 | *bits &= ~EXTENT_FIRST_DELALLOC; | 1374 | *bits &= ~EXTENT_FIRST_DELALLOC; |
1377 | else if (!(*bits & EXTENT_DO_ACCOUNTING)) | 1375 | } else if (!(*bits & EXTENT_DO_ACCOUNTING)) { |
1378 | atomic_dec(&BTRFS_I(inode)->outstanding_extents); | 1376 | spin_lock(&BTRFS_I(inode)->lock); |
1377 | BTRFS_I(inode)->outstanding_extents--; | ||
1378 | spin_unlock(&BTRFS_I(inode)->lock); | ||
1379 | } | ||
1379 | 1380 | ||
1380 | if (*bits & EXTENT_DO_ACCOUNTING) | 1381 | if (*bits & EXTENT_DO_ACCOUNTING) |
1381 | btrfs_delalloc_release_metadata(inode, len); | 1382 | btrfs_delalloc_release_metadata(inode, len); |
@@ -1477,7 +1478,7 @@ static int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio, | |||
1477 | 1478 | ||
1478 | skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM; | 1479 | skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM; |
1479 | 1480 | ||
1480 | if (is_free_space_inode(root, inode)) | 1481 | if (btrfs_is_free_space_inode(root, inode)) |
1481 | ret = btrfs_bio_wq_end_io(root->fs_info, bio, 2); | 1482 | ret = btrfs_bio_wq_end_io(root->fs_info, bio, 2); |
1482 | else | 1483 | else |
1483 | ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0); | 1484 | ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0); |
@@ -1726,7 +1727,7 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end) | |||
1726 | return 0; | 1727 | return 0; |
1727 | BUG_ON(!ordered_extent); | 1728 | BUG_ON(!ordered_extent); |
1728 | 1729 | ||
1729 | nolock = is_free_space_inode(root, inode); | 1730 | nolock = btrfs_is_free_space_inode(root, inode); |
1730 | 1731 | ||
1731 | if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) { | 1732 | if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) { |
1732 | BUG_ON(!list_empty(&ordered_extent->list)); | 1733 | BUG_ON(!list_empty(&ordered_extent->list)); |
@@ -2531,13 +2532,6 @@ static void btrfs_read_locked_inode(struct inode *inode) | |||
2531 | 2532 | ||
2532 | inode_item = btrfs_item_ptr(leaf, path->slots[0], | 2533 | inode_item = btrfs_item_ptr(leaf, path->slots[0], |
2533 | struct btrfs_inode_item); | 2534 | struct btrfs_inode_item); |
2534 | if (!leaf->map_token) | ||
2535 | map_private_extent_buffer(leaf, (unsigned long)inode_item, | ||
2536 | sizeof(struct btrfs_inode_item), | ||
2537 | &leaf->map_token, &leaf->kaddr, | ||
2538 | &leaf->map_start, &leaf->map_len, | ||
2539 | KM_USER1); | ||
2540 | |||
2541 | inode->i_mode = btrfs_inode_mode(leaf, inode_item); | 2535 | inode->i_mode = btrfs_inode_mode(leaf, inode_item); |
2542 | inode->i_nlink = btrfs_inode_nlink(leaf, inode_item); | 2536 | inode->i_nlink = btrfs_inode_nlink(leaf, inode_item); |
2543 | inode->i_uid = btrfs_inode_uid(leaf, inode_item); | 2537 | inode->i_uid = btrfs_inode_uid(leaf, inode_item); |
@@ -2575,11 +2569,6 @@ cache_acl: | |||
2575 | if (!maybe_acls) | 2569 | if (!maybe_acls) |
2576 | cache_no_acl(inode); | 2570 | cache_no_acl(inode); |
2577 | 2571 | ||
2578 | if (leaf->map_token) { | ||
2579 | unmap_extent_buffer(leaf, leaf->map_token, KM_USER1); | ||
2580 | leaf->map_token = NULL; | ||
2581 | } | ||
2582 | |||
2583 | btrfs_free_path(path); | 2572 | btrfs_free_path(path); |
2584 | 2573 | ||
2585 | switch (inode->i_mode & S_IFMT) { | 2574 | switch (inode->i_mode & S_IFMT) { |
@@ -2624,13 +2613,6 @@ static void fill_inode_item(struct btrfs_trans_handle *trans, | |||
2624 | struct btrfs_inode_item *item, | 2613 | struct btrfs_inode_item *item, |
2625 | struct inode *inode) | 2614 | struct inode *inode) |
2626 | { | 2615 | { |
2627 | if (!leaf->map_token) | ||
2628 | map_private_extent_buffer(leaf, (unsigned long)item, | ||
2629 | sizeof(struct btrfs_inode_item), | ||
2630 | &leaf->map_token, &leaf->kaddr, | ||
2631 | &leaf->map_start, &leaf->map_len, | ||
2632 | KM_USER1); | ||
2633 | |||
2634 | btrfs_set_inode_uid(leaf, item, inode->i_uid); | 2616 | btrfs_set_inode_uid(leaf, item, inode->i_uid); |
2635 | btrfs_set_inode_gid(leaf, item, inode->i_gid); | 2617 | btrfs_set_inode_gid(leaf, item, inode->i_gid); |
2636 | btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size); | 2618 | btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size); |
@@ -2659,11 +2641,6 @@ static void fill_inode_item(struct btrfs_trans_handle *trans, | |||
2659 | btrfs_set_inode_rdev(leaf, item, inode->i_rdev); | 2641 | btrfs_set_inode_rdev(leaf, item, inode->i_rdev); |
2660 | btrfs_set_inode_flags(leaf, item, BTRFS_I(inode)->flags); | 2642 | btrfs_set_inode_flags(leaf, item, BTRFS_I(inode)->flags); |
2661 | btrfs_set_inode_block_group(leaf, item, 0); | 2643 | btrfs_set_inode_block_group(leaf, item, 0); |
2662 | |||
2663 | if (leaf->map_token) { | ||
2664 | unmap_extent_buffer(leaf, leaf->map_token, KM_USER1); | ||
2665 | leaf->map_token = NULL; | ||
2666 | } | ||
2667 | } | 2644 | } |
2668 | 2645 | ||
2669 | /* | 2646 | /* |
@@ -2684,7 +2661,7 @@ noinline int btrfs_update_inode(struct btrfs_trans_handle *trans, | |||
2684 | * The data relocation inode should also be directly updated | 2661 | * The data relocation inode should also be directly updated |
2685 | * without delay | 2662 | * without delay |
2686 | */ | 2663 | */ |
2687 | if (!is_free_space_inode(root, inode) | 2664 | if (!btrfs_is_free_space_inode(root, inode) |
2688 | && root->root_key.objectid != BTRFS_DATA_RELOC_TREE_OBJECTID) { | 2665 | && root->root_key.objectid != BTRFS_DATA_RELOC_TREE_OBJECTID) { |
2689 | ret = btrfs_delayed_update_inode(trans, root, inode); | 2666 | ret = btrfs_delayed_update_inode(trans, root, inode); |
2690 | if (!ret) | 2667 | if (!ret) |
@@ -3398,7 +3375,7 @@ static int btrfs_truncate_page(struct address_space *mapping, loff_t from) | |||
3398 | 3375 | ||
3399 | ret = -ENOMEM; | 3376 | ret = -ENOMEM; |
3400 | again: | 3377 | again: |
3401 | page = grab_cache_page(mapping, index); | 3378 | page = find_or_create_page(mapping, index, GFP_NOFS); |
3402 | if (!page) { | 3379 | if (!page) { |
3403 | btrfs_delalloc_release_space(inode, PAGE_CACHE_SIZE); | 3380 | btrfs_delalloc_release_space(inode, PAGE_CACHE_SIZE); |
3404 | goto out; | 3381 | goto out; |
@@ -3634,7 +3611,7 @@ void btrfs_evict_inode(struct inode *inode) | |||
3634 | 3611 | ||
3635 | truncate_inode_pages(&inode->i_data, 0); | 3612 | truncate_inode_pages(&inode->i_data, 0); |
3636 | if (inode->i_nlink && (btrfs_root_refs(&root->root_item) != 0 || | 3613 | if (inode->i_nlink && (btrfs_root_refs(&root->root_item) != 0 || |
3637 | is_free_space_inode(root, inode))) | 3614 | btrfs_is_free_space_inode(root, inode))) |
3638 | goto no_delete; | 3615 | goto no_delete; |
3639 | 3616 | ||
3640 | if (is_bad_inode(inode)) { | 3617 | if (is_bad_inode(inode)) { |
@@ -4277,7 +4254,7 @@ int btrfs_write_inode(struct inode *inode, struct writeback_control *wbc) | |||
4277 | if (BTRFS_I(inode)->dummy_inode) | 4254 | if (BTRFS_I(inode)->dummy_inode) |
4278 | return 0; | 4255 | return 0; |
4279 | 4256 | ||
4280 | if (btrfs_fs_closing(root->fs_info) && is_free_space_inode(root, inode)) | 4257 | if (btrfs_fs_closing(root->fs_info) && btrfs_is_free_space_inode(root, inode)) |
4281 | nolock = true; | 4258 | nolock = true; |
4282 | 4259 | ||
4283 | if (wbc->sync_mode == WB_SYNC_ALL) { | 4260 | if (wbc->sync_mode == WB_SYNC_ALL) { |
@@ -6735,8 +6712,9 @@ struct inode *btrfs_alloc_inode(struct super_block *sb) | |||
6735 | ei->index_cnt = (u64)-1; | 6712 | ei->index_cnt = (u64)-1; |
6736 | ei->last_unlink_trans = 0; | 6713 | ei->last_unlink_trans = 0; |
6737 | 6714 | ||
6738 | atomic_set(&ei->outstanding_extents, 0); | 6715 | spin_lock_init(&ei->lock); |
6739 | atomic_set(&ei->reserved_extents, 0); | 6716 | ei->outstanding_extents = 0; |
6717 | ei->reserved_extents = 0; | ||
6740 | 6718 | ||
6741 | ei->ordered_data_close = 0; | 6719 | ei->ordered_data_close = 0; |
6742 | ei->orphan_meta_reserved = 0; | 6720 | ei->orphan_meta_reserved = 0; |
@@ -6774,8 +6752,8 @@ void btrfs_destroy_inode(struct inode *inode) | |||
6774 | 6752 | ||
6775 | WARN_ON(!list_empty(&inode->i_dentry)); | 6753 | WARN_ON(!list_empty(&inode->i_dentry)); |
6776 | WARN_ON(inode->i_data.nrpages); | 6754 | WARN_ON(inode->i_data.nrpages); |
6777 | WARN_ON(atomic_read(&BTRFS_I(inode)->outstanding_extents)); | 6755 | WARN_ON(BTRFS_I(inode)->outstanding_extents); |
6778 | WARN_ON(atomic_read(&BTRFS_I(inode)->reserved_extents)); | 6756 | WARN_ON(BTRFS_I(inode)->reserved_extents); |
6779 | 6757 | ||
6780 | /* | 6758 | /* |
6781 | * This can happen where we create an inode, but somebody else also | 6759 | * This can happen where we create an inode, but somebody else also |
@@ -6830,7 +6808,7 @@ int btrfs_drop_inode(struct inode *inode) | |||
6830 | struct btrfs_root *root = BTRFS_I(inode)->root; | 6808 | struct btrfs_root *root = BTRFS_I(inode)->root; |
6831 | 6809 | ||
6832 | if (btrfs_root_refs(&root->root_item) == 0 && | 6810 | if (btrfs_root_refs(&root->root_item) == 0 && |
6833 | !is_free_space_inode(root, inode)) | 6811 | !btrfs_is_free_space_inode(root, inode)) |
6834 | return 1; | 6812 | return 1; |
6835 | else | 6813 | else |
6836 | return generic_drop_inode(inode); | 6814 | return generic_drop_inode(inode); |