diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-07-21 10:29:44 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:05 -0400 |
commit | 4a09675279674041862d2210635b0cc1f60be28e (patch) | |
tree | 19e4736c062f87729dcdc1bd57f4919b3227ec32 /fs/btrfs/extent-tree.c | |
parent | e5a2217ef6ff088d08a27208929a6f9c635d672c (diff) |
Btrfs: Data ordered fixes
* In btrfs_delete_inode, wait for ordered extents after calling
truncate_inode_pages. This is much faster, and more correct
* Properly clear our the PageChecked bit everywhere we redirty the page.
* Change the writepage fixup handler to lock the page range and check to
see if an ordered extent had been inserted since the improperly dirtied
page was discovered
* Wait for ordered extents outside the transaction. This isn't required
for locking rules but does improve transaction latencies
* Reduce contention on the alloc_mutex by dropping it while incrementing
refs on a node/leaf and while dropping refs on a leaf.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index be2aef1cb7ae..ccd49322f793 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -934,7 +934,6 @@ int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, | |||
934 | if (!root->ref_cows) | 934 | if (!root->ref_cows) |
935 | return 0; | 935 | return 0; |
936 | 936 | ||
937 | mutex_lock(&root->fs_info->alloc_mutex); | ||
938 | level = btrfs_header_level(buf); | 937 | level = btrfs_header_level(buf); |
939 | nritems = btrfs_header_nritems(buf); | 938 | nritems = btrfs_header_nritems(buf); |
940 | for (i = 0; i < nritems; i++) { | 939 | for (i = 0; i < nritems; i++) { |
@@ -951,29 +950,36 @@ int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, | |||
951 | disk_bytenr = btrfs_file_extent_disk_bytenr(buf, fi); | 950 | disk_bytenr = btrfs_file_extent_disk_bytenr(buf, fi); |
952 | if (disk_bytenr == 0) | 951 | if (disk_bytenr == 0) |
953 | continue; | 952 | continue; |
953 | |||
954 | mutex_lock(&root->fs_info->alloc_mutex); | ||
954 | ret = __btrfs_inc_extent_ref(trans, root, disk_bytenr, | 955 | ret = __btrfs_inc_extent_ref(trans, root, disk_bytenr, |
955 | btrfs_file_extent_disk_num_bytes(buf, fi), | 956 | btrfs_file_extent_disk_num_bytes(buf, fi), |
956 | root->root_key.objectid, trans->transid, | 957 | root->root_key.objectid, trans->transid, |
957 | key.objectid, key.offset); | 958 | key.objectid, key.offset); |
959 | mutex_unlock(&root->fs_info->alloc_mutex); | ||
958 | if (ret) { | 960 | if (ret) { |
959 | faili = i; | 961 | faili = i; |
962 | WARN_ON(1); | ||
960 | goto fail; | 963 | goto fail; |
961 | } | 964 | } |
962 | } else { | 965 | } else { |
963 | bytenr = btrfs_node_blockptr(buf, i); | 966 | bytenr = btrfs_node_blockptr(buf, i); |
964 | btrfs_node_key_to_cpu(buf, &key, i); | 967 | btrfs_node_key_to_cpu(buf, &key, i); |
968 | |||
969 | mutex_lock(&root->fs_info->alloc_mutex); | ||
965 | ret = __btrfs_inc_extent_ref(trans, root, bytenr, | 970 | ret = __btrfs_inc_extent_ref(trans, root, bytenr, |
966 | btrfs_level_size(root, level - 1), | 971 | btrfs_level_size(root, level - 1), |
967 | root->root_key.objectid, | 972 | root->root_key.objectid, |
968 | trans->transid, | 973 | trans->transid, |
969 | level - 1, key.objectid); | 974 | level - 1, key.objectid); |
975 | mutex_unlock(&root->fs_info->alloc_mutex); | ||
970 | if (ret) { | 976 | if (ret) { |
971 | faili = i; | 977 | faili = i; |
978 | WARN_ON(1); | ||
972 | goto fail; | 979 | goto fail; |
973 | } | 980 | } |
974 | } | 981 | } |
975 | } | 982 | } |
976 | mutex_unlock(&root->fs_info->alloc_mutex); | ||
977 | return 0; | 983 | return 0; |
978 | fail: | 984 | fail: |
979 | WARN_ON(1); | 985 | WARN_ON(1); |
@@ -1004,7 +1010,6 @@ fail: | |||
1004 | } | 1010 | } |
1005 | } | 1011 | } |
1006 | #endif | 1012 | #endif |
1007 | mutex_unlock(&root->fs_info->alloc_mutex); | ||
1008 | return ret; | 1013 | return ret; |
1009 | } | 1014 | } |
1010 | 1015 | ||
@@ -2180,6 +2185,8 @@ static int noinline drop_leaf_ref(struct btrfs_trans_handle *trans, | |||
2180 | leaf_owner = btrfs_header_owner(leaf); | 2185 | leaf_owner = btrfs_header_owner(leaf); |
2181 | leaf_generation = btrfs_header_generation(leaf); | 2186 | leaf_generation = btrfs_header_generation(leaf); |
2182 | 2187 | ||
2188 | mutex_unlock(&root->fs_info->alloc_mutex); | ||
2189 | |||
2183 | for (i = 0; i < nritems; i++) { | 2190 | for (i = 0; i < nritems; i++) { |
2184 | u64 disk_bytenr; | 2191 | u64 disk_bytenr; |
2185 | 2192 | ||
@@ -2197,12 +2204,17 @@ static int noinline drop_leaf_ref(struct btrfs_trans_handle *trans, | |||
2197 | disk_bytenr = btrfs_file_extent_disk_bytenr(leaf, fi); | 2204 | disk_bytenr = btrfs_file_extent_disk_bytenr(leaf, fi); |
2198 | if (disk_bytenr == 0) | 2205 | if (disk_bytenr == 0) |
2199 | continue; | 2206 | continue; |
2207 | |||
2208 | mutex_lock(&root->fs_info->alloc_mutex); | ||
2200 | ret = __btrfs_free_extent(trans, root, disk_bytenr, | 2209 | ret = __btrfs_free_extent(trans, root, disk_bytenr, |
2201 | btrfs_file_extent_disk_num_bytes(leaf, fi), | 2210 | btrfs_file_extent_disk_num_bytes(leaf, fi), |
2202 | leaf_owner, leaf_generation, | 2211 | leaf_owner, leaf_generation, |
2203 | key.objectid, key.offset, 0); | 2212 | key.objectid, key.offset, 0); |
2213 | mutex_unlock(&root->fs_info->alloc_mutex); | ||
2204 | BUG_ON(ret); | 2214 | BUG_ON(ret); |
2205 | } | 2215 | } |
2216 | |||
2217 | mutex_lock(&root->fs_info->alloc_mutex); | ||
2206 | return 0; | 2218 | return 0; |
2207 | } | 2219 | } |
2208 | 2220 | ||