diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-05-12 12:59:19 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:03 -0400 |
commit | ca7a79ad8dbe24669a8ced01f9fc0126b872745d (patch) | |
tree | 0d53d8e6fd9ff9aece4e703581918c7817175d5d /fs/btrfs/disk-io.c | |
parent | 188de649c51f03df3f8a601aea0110a3870815c2 (diff) |
Btrfs: Pass down the expected generation number when reading tree blocks
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r-- | fs/btrfs/disk-io.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index c3083165b172..edee7a44f861 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -207,7 +207,7 @@ static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf, | |||
207 | 207 | ||
208 | static int btree_read_extent_buffer_pages(struct btrfs_root *root, | 208 | static int btree_read_extent_buffer_pages(struct btrfs_root *root, |
209 | struct extent_buffer *eb, | 209 | struct extent_buffer *eb, |
210 | u64 start) | 210 | u64 start, u64 parent_transid) |
211 | { | 211 | { |
212 | struct extent_io_tree *io_tree; | 212 | struct extent_io_tree *io_tree; |
213 | int ret; | 213 | int ret; |
@@ -254,7 +254,8 @@ int csum_dirty_buffer(struct btrfs_root *root, struct page *page) | |||
254 | WARN_ON(1); | 254 | WARN_ON(1); |
255 | } | 255 | } |
256 | eb = alloc_extent_buffer(tree, start, len, page, GFP_NOFS); | 256 | eb = alloc_extent_buffer(tree, start, len, page, GFP_NOFS); |
257 | ret = btree_read_extent_buffer_pages(root, eb, start + PAGE_CACHE_SIZE); | 257 | ret = btree_read_extent_buffer_pages(root, eb, start + PAGE_CACHE_SIZE, |
258 | btrfs_header_generation(eb)); | ||
258 | BUG_ON(ret); | 259 | BUG_ON(ret); |
259 | btrfs_clear_buffer_defrag(eb); | 260 | btrfs_clear_buffer_defrag(eb); |
260 | found_start = btrfs_header_bytenr(eb); | 261 | found_start = btrfs_header_bytenr(eb); |
@@ -562,7 +563,8 @@ static struct address_space_operations btree_aops = { | |||
562 | .sync_page = block_sync_page, | 563 | .sync_page = block_sync_page, |
563 | }; | 564 | }; |
564 | 565 | ||
565 | int readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize) | 566 | int readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize, |
567 | u64 parent_transid) | ||
566 | { | 568 | { |
567 | struct extent_buffer *buf = NULL; | 569 | struct extent_buffer *buf = NULL; |
568 | struct inode *btree_inode = root->fs_info->btree_inode; | 570 | struct inode *btree_inode = root->fs_info->btree_inode; |
@@ -592,12 +594,6 @@ static int close_all_devices(struct btrfs_fs_info *fs_info) | |||
592 | return 0; | 594 | return 0; |
593 | } | 595 | } |
594 | 596 | ||
595 | int btrfs_verify_block_csum(struct btrfs_root *root, | ||
596 | struct extent_buffer *buf) | ||
597 | { | ||
598 | return btrfs_buffer_uptodate(buf); | ||
599 | } | ||
600 | |||
601 | struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root, | 597 | struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root, |
602 | u64 bytenr, u32 blocksize) | 598 | u64 bytenr, u32 blocksize) |
603 | { | 599 | { |
@@ -621,7 +617,7 @@ struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root, | |||
621 | 617 | ||
622 | 618 | ||
623 | struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr, | 619 | struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr, |
624 | u32 blocksize) | 620 | u32 blocksize, u64 parent_transid) |
625 | { | 621 | { |
626 | struct extent_buffer *buf = NULL; | 622 | struct extent_buffer *buf = NULL; |
627 | struct inode *btree_inode = root->fs_info->btree_inode; | 623 | struct inode *btree_inode = root->fs_info->btree_inode; |
@@ -634,7 +630,7 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr, | |||
634 | if (!buf) | 630 | if (!buf) |
635 | return NULL; | 631 | return NULL; |
636 | 632 | ||
637 | ret = btree_read_extent_buffer_pages(root, buf, 0); | 633 | ret = btree_read_extent_buffer_pages(root, buf, 0, parent_transid); |
638 | 634 | ||
639 | if (ret == 0) { | 635 | if (ret == 0) { |
640 | buf->flags |= EXTENT_UPTODATE; | 636 | buf->flags |= EXTENT_UPTODATE; |
@@ -715,7 +711,7 @@ static int find_and_setup_root(struct btrfs_root *tree_root, | |||
715 | 711 | ||
716 | blocksize = btrfs_level_size(root, btrfs_root_level(&root->root_item)); | 712 | blocksize = btrfs_level_size(root, btrfs_root_level(&root->root_item)); |
717 | root->node = read_tree_block(root, btrfs_root_bytenr(&root->root_item), | 713 | root->node = read_tree_block(root, btrfs_root_bytenr(&root->root_item), |
718 | blocksize); | 714 | blocksize, 0); |
719 | BUG_ON(!root->node); | 715 | BUG_ON(!root->node); |
720 | return 0; | 716 | return 0; |
721 | } | 717 | } |
@@ -771,7 +767,7 @@ out: | |||
771 | } | 767 | } |
772 | blocksize = btrfs_level_size(root, btrfs_root_level(&root->root_item)); | 768 | blocksize = btrfs_level_size(root, btrfs_root_level(&root->root_item)); |
773 | root->node = read_tree_block(root, btrfs_root_bytenr(&root->root_item), | 769 | root->node = read_tree_block(root, btrfs_root_bytenr(&root->root_item), |
774 | blocksize); | 770 | blocksize, 0); |
775 | BUG_ON(!root->node); | 771 | BUG_ON(!root->node); |
776 | insert: | 772 | insert: |
777 | root->ref_cows = 1; | 773 | root->ref_cows = 1; |
@@ -1288,7 +1284,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1288 | 1284 | ||
1289 | chunk_root->node = read_tree_block(chunk_root, | 1285 | chunk_root->node = read_tree_block(chunk_root, |
1290 | btrfs_super_chunk_root(disk_super), | 1286 | btrfs_super_chunk_root(disk_super), |
1291 | blocksize); | 1287 | blocksize, 0); |
1292 | BUG_ON(!chunk_root->node); | 1288 | BUG_ON(!chunk_root->node); |
1293 | 1289 | ||
1294 | read_extent_buffer(chunk_root->node, fs_info->chunk_tree_uuid, | 1290 | read_extent_buffer(chunk_root->node, fs_info->chunk_tree_uuid, |
@@ -1304,7 +1300,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1304 | 1300 | ||
1305 | tree_root->node = read_tree_block(tree_root, | 1301 | tree_root->node = read_tree_block(tree_root, |
1306 | btrfs_super_root(disk_super), | 1302 | btrfs_super_root(disk_super), |
1307 | blocksize); | 1303 | blocksize, 0); |
1308 | if (!tree_root->node) | 1304 | if (!tree_root->node) |
1309 | goto fail_sb_buffer; | 1305 | goto fail_sb_buffer; |
1310 | 1306 | ||
@@ -1732,11 +1728,11 @@ int btrfs_clear_buffer_defrag(struct extent_buffer *buf) | |||
1732 | EXTENT_DEFRAG, GFP_NOFS); | 1728 | EXTENT_DEFRAG, GFP_NOFS); |
1733 | } | 1729 | } |
1734 | 1730 | ||
1735 | int btrfs_read_buffer(struct extent_buffer *buf) | 1731 | int btrfs_read_buffer(struct extent_buffer *buf, u64 parent_transid) |
1736 | { | 1732 | { |
1737 | struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root; | 1733 | struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root; |
1738 | int ret; | 1734 | int ret; |
1739 | ret = btree_read_extent_buffer_pages(root, buf, 0); | 1735 | ret = btree_read_extent_buffer_pages(root, buf, 0, parent_transid); |
1740 | if (ret == 0) { | 1736 | if (ret == 0) { |
1741 | buf->flags |= EXTENT_UPTODATE; | 1737 | buf->flags |= EXTENT_UPTODATE; |
1742 | } | 1738 | } |