diff options
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r-- | fs/btrfs/disk-io.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 0427183e3e05..e7b8f2c89ccb 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/kthread.h> | 27 | #include <linux/kthread.h> |
28 | #include <linux/freezer.h> | 28 | #include <linux/freezer.h> |
29 | #include <linux/crc32c.h> | 29 | #include <linux/crc32c.h> |
30 | #include <linux/slab.h> | ||
30 | #include "compat.h" | 31 | #include "compat.h" |
31 | #include "ctree.h" | 32 | #include "ctree.h" |
32 | #include "disk-io.h" | 33 | #include "disk-io.h" |
@@ -263,13 +264,15 @@ static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf, | |||
263 | static int verify_parent_transid(struct extent_io_tree *io_tree, | 264 | static int verify_parent_transid(struct extent_io_tree *io_tree, |
264 | struct extent_buffer *eb, u64 parent_transid) | 265 | struct extent_buffer *eb, u64 parent_transid) |
265 | { | 266 | { |
267 | struct extent_state *cached_state = NULL; | ||
266 | int ret; | 268 | int ret; |
267 | 269 | ||
268 | if (!parent_transid || btrfs_header_generation(eb) == parent_transid) | 270 | if (!parent_transid || btrfs_header_generation(eb) == parent_transid) |
269 | return 0; | 271 | return 0; |
270 | 272 | ||
271 | lock_extent(io_tree, eb->start, eb->start + eb->len - 1, GFP_NOFS); | 273 | lock_extent_bits(io_tree, eb->start, eb->start + eb->len - 1, |
272 | if (extent_buffer_uptodate(io_tree, eb) && | 274 | 0, &cached_state, GFP_NOFS); |
275 | if (extent_buffer_uptodate(io_tree, eb, cached_state) && | ||
273 | btrfs_header_generation(eb) == parent_transid) { | 276 | btrfs_header_generation(eb) == parent_transid) { |
274 | ret = 0; | 277 | ret = 0; |
275 | goto out; | 278 | goto out; |
@@ -282,10 +285,10 @@ static int verify_parent_transid(struct extent_io_tree *io_tree, | |||
282 | (unsigned long long)btrfs_header_generation(eb)); | 285 | (unsigned long long)btrfs_header_generation(eb)); |
283 | } | 286 | } |
284 | ret = 1; | 287 | ret = 1; |
285 | clear_extent_buffer_uptodate(io_tree, eb); | 288 | clear_extent_buffer_uptodate(io_tree, eb, &cached_state); |
286 | out: | 289 | out: |
287 | unlock_extent(io_tree, eb->start, eb->start + eb->len - 1, | 290 | unlock_extent_cached(io_tree, eb->start, eb->start + eb->len - 1, |
288 | GFP_NOFS); | 291 | &cached_state, GFP_NOFS); |
289 | return ret; | 292 | return ret; |
290 | } | 293 | } |
291 | 294 | ||
@@ -1632,7 +1635,6 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1632 | atomic_set(&fs_info->async_submit_draining, 0); | 1635 | atomic_set(&fs_info->async_submit_draining, 0); |
1633 | atomic_set(&fs_info->nr_async_bios, 0); | 1636 | atomic_set(&fs_info->nr_async_bios, 0); |
1634 | fs_info->sb = sb; | 1637 | fs_info->sb = sb; |
1635 | fs_info->max_extent = (u64)-1; | ||
1636 | fs_info->max_inline = 8192 * 1024; | 1638 | fs_info->max_inline = 8192 * 1024; |
1637 | fs_info->metadata_ratio = 0; | 1639 | fs_info->metadata_ratio = 0; |
1638 | 1640 | ||
@@ -1920,7 +1922,11 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1920 | 1922 | ||
1921 | csum_root->track_dirty = 1; | 1923 | csum_root->track_dirty = 1; |
1922 | 1924 | ||
1923 | btrfs_read_block_groups(extent_root); | 1925 | ret = btrfs_read_block_groups(extent_root); |
1926 | if (ret) { | ||
1927 | printk(KERN_ERR "Failed to read block groups: %d\n", ret); | ||
1928 | goto fail_block_groups; | ||
1929 | } | ||
1924 | 1930 | ||
1925 | fs_info->generation = generation; | 1931 | fs_info->generation = generation; |
1926 | fs_info->last_trans_committed = generation; | 1932 | fs_info->last_trans_committed = generation; |
@@ -1930,7 +1936,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1930 | fs_info->cleaner_kthread = kthread_run(cleaner_kthread, tree_root, | 1936 | fs_info->cleaner_kthread = kthread_run(cleaner_kthread, tree_root, |
1931 | "btrfs-cleaner"); | 1937 | "btrfs-cleaner"); |
1932 | if (IS_ERR(fs_info->cleaner_kthread)) | 1938 | if (IS_ERR(fs_info->cleaner_kthread)) |
1933 | goto fail_csum_root; | 1939 | goto fail_block_groups; |
1934 | 1940 | ||
1935 | fs_info->transaction_kthread = kthread_run(transaction_kthread, | 1941 | fs_info->transaction_kthread = kthread_run(transaction_kthread, |
1936 | tree_root, | 1942 | tree_root, |
@@ -2018,7 +2024,8 @@ fail_cleaner: | |||
2018 | filemap_write_and_wait(fs_info->btree_inode->i_mapping); | 2024 | filemap_write_and_wait(fs_info->btree_inode->i_mapping); |
2019 | invalidate_inode_pages2(fs_info->btree_inode->i_mapping); | 2025 | invalidate_inode_pages2(fs_info->btree_inode->i_mapping); |
2020 | 2026 | ||
2021 | fail_csum_root: | 2027 | fail_block_groups: |
2028 | btrfs_free_block_groups(fs_info); | ||
2022 | free_extent_buffer(csum_root->node); | 2029 | free_extent_buffer(csum_root->node); |
2023 | free_extent_buffer(csum_root->commit_root); | 2030 | free_extent_buffer(csum_root->commit_root); |
2024 | fail_dev_root: | 2031 | fail_dev_root: |
@@ -2497,7 +2504,8 @@ int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid) | |||
2497 | int ret; | 2504 | int ret; |
2498 | struct inode *btree_inode = buf->first_page->mapping->host; | 2505 | struct inode *btree_inode = buf->first_page->mapping->host; |
2499 | 2506 | ||
2500 | ret = extent_buffer_uptodate(&BTRFS_I(btree_inode)->io_tree, buf); | 2507 | ret = extent_buffer_uptodate(&BTRFS_I(btree_inode)->io_tree, buf, |
2508 | NULL); | ||
2501 | if (!ret) | 2509 | if (!ret) |
2502 | return ret; | 2510 | return ret; |
2503 | 2511 | ||