aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-01-24 16:13:08 -0500
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:03:59 -0400
commitd1310b2e0cd98eb1348553e69b73827b436dca7b (patch)
treef55e9c380df0f3a7e9fb792b2308b52b632b90aa /fs/btrfs/disk-io.c
parent5f56406aabdf5444d040c5955effc665b1d0dbaf (diff)
Btrfs: Split the extent_map code into two parts
There is now extent_map for mapping offsets in the file to disk and extent_io for state tracking, IO submission and extent_bufers. The new extent_map code shifts from [start,end] pairs to [start,len], and pushes the locking out into the caller. This allows a few performance optimizations and is easier to use. A number of extent_map usage bugs were fixed, mostly with failing to remove extent_map entries when changing the file. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c123
1 files changed, 66 insertions, 57 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 5d1f9bca2712..4c4ebea0b2a9 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -43,14 +43,14 @@ static int check_tree_block(struct btrfs_root *root, struct extent_buffer *buf)
43} 43}
44#endif 44#endif
45 45
46static struct extent_map_ops btree_extent_map_ops; 46static struct extent_io_ops btree_extent_io_ops;
47 47
48struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root, 48struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root,
49 u64 bytenr, u32 blocksize) 49 u64 bytenr, u32 blocksize)
50{ 50{
51 struct inode *btree_inode = root->fs_info->btree_inode; 51 struct inode *btree_inode = root->fs_info->btree_inode;
52 struct extent_buffer *eb; 52 struct extent_buffer *eb;
53 eb = find_extent_buffer(&BTRFS_I(btree_inode)->extent_tree, 53 eb = find_extent_buffer(&BTRFS_I(btree_inode)->io_tree,
54 bytenr, blocksize, GFP_NOFS); 54 bytenr, blocksize, GFP_NOFS);
55 return eb; 55 return eb;
56} 56}
@@ -61,13 +61,13 @@ struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root,
61 struct inode *btree_inode = root->fs_info->btree_inode; 61 struct inode *btree_inode = root->fs_info->btree_inode;
62 struct extent_buffer *eb; 62 struct extent_buffer *eb;
63 63
64 eb = alloc_extent_buffer(&BTRFS_I(btree_inode)->extent_tree, 64 eb = alloc_extent_buffer(&BTRFS_I(btree_inode)->io_tree,
65 bytenr, blocksize, NULL, GFP_NOFS); 65 bytenr, blocksize, NULL, GFP_NOFS);
66 return eb; 66 return eb;
67} 67}
68 68
69struct extent_map *btree_get_extent(struct inode *inode, struct page *page, 69struct extent_map *btree_get_extent(struct inode *inode, struct page *page,
70 size_t page_offset, u64 start, u64 end, 70 size_t page_offset, u64 start, u64 len,
71 int create) 71 int create)
72{ 72{
73 struct extent_map_tree *em_tree = &BTRFS_I(inode)->extent_tree; 73 struct extent_map_tree *em_tree = &BTRFS_I(inode)->extent_tree;
@@ -75,7 +75,9 @@ struct extent_map *btree_get_extent(struct inode *inode, struct page *page,
75 int ret; 75 int ret;
76 76
77again: 77again:
78 em = lookup_extent_mapping(em_tree, start, end); 78 spin_lock(&em_tree->lock);
79 em = lookup_extent_mapping(em_tree, start, len);
80 spin_unlock(&em_tree->lock);
79 if (em) { 81 if (em) {
80 goto out; 82 goto out;
81 } 83 }
@@ -85,11 +87,14 @@ again:
85 goto out; 87 goto out;
86 } 88 }
87 em->start = 0; 89 em->start = 0;
88 em->end = (i_size_read(inode) & ~((u64)PAGE_CACHE_SIZE -1)) - 1; 90 em->len = i_size_read(inode);
89 em->block_start = 0; 91 em->block_start = 0;
90 em->block_end = em->end;
91 em->bdev = inode->i_sb->s_bdev; 92 em->bdev = inode->i_sb->s_bdev;
93
94 spin_lock(&em_tree->lock);
92 ret = add_extent_mapping(em_tree, em); 95 ret = add_extent_mapping(em_tree, em);
96 spin_unlock(&em_tree->lock);
97
93 if (ret == -EEXIST) { 98 if (ret == -EEXIST) {
94 free_extent_map(em); 99 free_extent_map(em);
95 em = NULL; 100 em = NULL;
@@ -175,13 +180,13 @@ static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
175 180
176int csum_dirty_buffer(struct btrfs_root *root, struct page *page) 181int csum_dirty_buffer(struct btrfs_root *root, struct page *page)
177{ 182{
178 struct extent_map_tree *tree; 183 struct extent_io_tree *tree;
179 u64 start = (u64)page->index << PAGE_CACHE_SHIFT; 184 u64 start = (u64)page->index << PAGE_CACHE_SHIFT;
180 u64 found_start; 185 u64 found_start;
181 int found_level; 186 int found_level;
182 unsigned long len; 187 unsigned long len;
183 struct extent_buffer *eb; 188 struct extent_buffer *eb;
184 tree = &BTRFS_I(page->mapping->host)->extent_tree; 189 tree = &BTRFS_I(page->mapping->host)->io_tree;
185 190
186 if (page->private == EXTENT_PAGE_PRIVATE) 191 if (page->private == EXTENT_PAGE_PRIVATE)
187 goto out; 192 goto out;
@@ -230,16 +235,16 @@ static int btree_writepage_io_hook(struct page *page, u64 start, u64 end)
230 235
231static int btree_writepage(struct page *page, struct writeback_control *wbc) 236static int btree_writepage(struct page *page, struct writeback_control *wbc)
232{ 237{
233 struct extent_map_tree *tree; 238 struct extent_io_tree *tree;
234 tree = &BTRFS_I(page->mapping->host)->extent_tree; 239 tree = &BTRFS_I(page->mapping->host)->io_tree;
235 return extent_write_full_page(tree, page, btree_get_extent, wbc); 240 return extent_write_full_page(tree, page, btree_get_extent, wbc);
236} 241}
237 242
238static int btree_writepages(struct address_space *mapping, 243static int btree_writepages(struct address_space *mapping,
239 struct writeback_control *wbc) 244 struct writeback_control *wbc)
240{ 245{
241 struct extent_map_tree *tree; 246 struct extent_io_tree *tree;
242 tree = &BTRFS_I(mapping->host)->extent_tree; 247 tree = &BTRFS_I(mapping->host)->io_tree;
243 if (wbc->sync_mode == WB_SYNC_NONE) { 248 if (wbc->sync_mode == WB_SYNC_NONE) {
244 u64 num_dirty; 249 u64 num_dirty;
245 u64 start = 0; 250 u64 start = 0;
@@ -264,18 +269,20 @@ static int btree_writepages(struct address_space *mapping,
264 269
265int btree_readpage(struct file *file, struct page *page) 270int btree_readpage(struct file *file, struct page *page)
266{ 271{
267 struct extent_map_tree *tree; 272 struct extent_io_tree *tree;
268 tree = &BTRFS_I(page->mapping->host)->extent_tree; 273 tree = &BTRFS_I(page->mapping->host)->io_tree;
269 return extent_read_full_page(tree, page, btree_get_extent); 274 return extent_read_full_page(tree, page, btree_get_extent);
270} 275}
271 276
272static int btree_releasepage(struct page *page, gfp_t unused_gfp_flags) 277static int btree_releasepage(struct page *page, gfp_t unused_gfp_flags)
273{ 278{
274 struct extent_map_tree *tree; 279 struct extent_io_tree *tree;
280 struct extent_map_tree *map;
275 int ret; 281 int ret;
276 282
277 tree = &BTRFS_I(page->mapping->host)->extent_tree; 283 tree = &BTRFS_I(page->mapping->host)->io_tree;
278 ret = try_release_extent_mapping(tree, page); 284 map = &BTRFS_I(page->mapping->host)->extent_tree;
285 ret = try_release_extent_mapping(map, tree, page);
279 if (ret == 1) { 286 if (ret == 1) {
280 ClearPagePrivate(page); 287 ClearPagePrivate(page);
281 set_page_private(page, 0); 288 set_page_private(page, 0);
@@ -286,8 +293,8 @@ static int btree_releasepage(struct page *page, gfp_t unused_gfp_flags)
286 293
287static void btree_invalidatepage(struct page *page, unsigned long offset) 294static void btree_invalidatepage(struct page *page, unsigned long offset)
288{ 295{
289 struct extent_map_tree *tree; 296 struct extent_io_tree *tree;
290 tree = &BTRFS_I(page->mapping->host)->extent_tree; 297 tree = &BTRFS_I(page->mapping->host)->io_tree;
291 extent_invalidatepage(tree, page, offset); 298 extent_invalidatepage(tree, page, offset);
292 btree_releasepage(page, GFP_NOFS); 299 btree_releasepage(page, GFP_NOFS);
293} 300}
@@ -331,7 +338,7 @@ int readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize)
331 buf = btrfs_find_create_tree_block(root, bytenr, blocksize); 338 buf = btrfs_find_create_tree_block(root, bytenr, blocksize);
332 if (!buf) 339 if (!buf)
333 return 0; 340 return 0;
334 read_extent_buffer_pages(&BTRFS_I(btree_inode)->extent_tree, 341 read_extent_buffer_pages(&BTRFS_I(btree_inode)->io_tree,
335 buf, 0, 0); 342 buf, 0, 0);
336 free_extent_buffer(buf); 343 free_extent_buffer(buf);
337 return ret; 344 return ret;
@@ -342,40 +349,39 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
342{ 349{
343 struct extent_buffer *buf = NULL; 350 struct extent_buffer *buf = NULL;
344 struct inode *btree_inode = root->fs_info->btree_inode; 351 struct inode *btree_inode = root->fs_info->btree_inode;
345 struct extent_map_tree *extent_tree; 352 struct extent_io_tree *io_tree;
346 u64 end; 353 u64 end;
347 int ret; 354 int ret;
348 355
349 extent_tree = &BTRFS_I(btree_inode)->extent_tree; 356 io_tree = &BTRFS_I(btree_inode)->io_tree;
350 357
351 buf = btrfs_find_create_tree_block(root, bytenr, blocksize); 358 buf = btrfs_find_create_tree_block(root, bytenr, blocksize);
352 if (!buf) 359 if (!buf)
353 return NULL; 360 return NULL;
354 read_extent_buffer_pages(&BTRFS_I(btree_inode)->extent_tree, 361 read_extent_buffer_pages(&BTRFS_I(btree_inode)->io_tree, buf, 0, 1);
355 buf, 0, 1);
356 362
357 if (buf->flags & EXTENT_CSUM) 363 if (buf->flags & EXTENT_CSUM)
358 return buf; 364 return buf;
359 365
360 end = buf->start + PAGE_CACHE_SIZE - 1; 366 end = buf->start + PAGE_CACHE_SIZE - 1;
361 if (test_range_bit(extent_tree, buf->start, end, EXTENT_CSUM, 1)) { 367 if (test_range_bit(io_tree, buf->start, end, EXTENT_CSUM, 1)) {
362 buf->flags |= EXTENT_CSUM; 368 buf->flags |= EXTENT_CSUM;
363 return buf; 369 return buf;
364 } 370 }
365 371
366 lock_extent(extent_tree, buf->start, end, GFP_NOFS); 372 lock_extent(io_tree, buf->start, end, GFP_NOFS);
367 373
368 if (test_range_bit(extent_tree, buf->start, end, EXTENT_CSUM, 1)) { 374 if (test_range_bit(io_tree, buf->start, end, EXTENT_CSUM, 1)) {
369 buf->flags |= EXTENT_CSUM; 375 buf->flags |= EXTENT_CSUM;
370 goto out_unlock; 376 goto out_unlock;
371 } 377 }
372 378
373 ret = csum_tree_block(root, buf, 1); 379 ret = csum_tree_block(root, buf, 1);
374 set_extent_bits(extent_tree, buf->start, end, EXTENT_CSUM, GFP_NOFS); 380 set_extent_bits(io_tree, buf->start, end, EXTENT_CSUM, GFP_NOFS);
375 buf->flags |= EXTENT_CSUM; 381 buf->flags |= EXTENT_CSUM;
376 382
377out_unlock: 383out_unlock:
378 unlock_extent(extent_tree, buf->start, end, GFP_NOFS); 384 unlock_extent(io_tree, buf->start, end, GFP_NOFS);
379 return buf; 385 return buf;
380} 386}
381 387
@@ -385,7 +391,7 @@ int clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
385 struct inode *btree_inode = root->fs_info->btree_inode; 391 struct inode *btree_inode = root->fs_info->btree_inode;
386 if (btrfs_header_generation(buf) == 392 if (btrfs_header_generation(buf) ==
387 root->fs_info->running_transaction->transid) 393 root->fs_info->running_transaction->transid)
388 clear_extent_buffer_dirty(&BTRFS_I(btree_inode)->extent_tree, 394 clear_extent_buffer_dirty(&BTRFS_I(btree_inode)->io_tree,
389 buf); 395 buf);
390 return 0; 396 return 0;
391} 397}
@@ -394,7 +400,7 @@ int wait_on_tree_block_writeback(struct btrfs_root *root,
394 struct extent_buffer *buf) 400 struct extent_buffer *buf)
395{ 401{
396 struct inode *btree_inode = root->fs_info->btree_inode; 402 struct inode *btree_inode = root->fs_info->btree_inode;
397 wait_on_extent_buffer_writeback(&BTRFS_I(btree_inode)->extent_tree, 403 wait_on_extent_buffer_writeback(&BTRFS_I(btree_inode)->io_tree,
398 buf); 404 buf);
399 return 0; 405 return 0;
400} 406}
@@ -659,20 +665,23 @@ struct btrfs_root *open_ctree(struct super_block *sb)
659 fs_info->btree_inode->i_nlink = 1; 665 fs_info->btree_inode->i_nlink = 1;
660 fs_info->btree_inode->i_size = sb->s_bdev->bd_inode->i_size; 666 fs_info->btree_inode->i_size = sb->s_bdev->bd_inode->i_size;
661 fs_info->btree_inode->i_mapping->a_ops = &btree_aops; 667 fs_info->btree_inode->i_mapping->a_ops = &btree_aops;
662 extent_map_tree_init(&BTRFS_I(fs_info->btree_inode)->extent_tree, 668 extent_io_tree_init(&BTRFS_I(fs_info->btree_inode)->io_tree,
663 fs_info->btree_inode->i_mapping, 669 fs_info->btree_inode->i_mapping,
664 GFP_NOFS); 670 GFP_NOFS);
665 BTRFS_I(fs_info->btree_inode)->extent_tree.ops = &btree_extent_map_ops; 671 extent_map_tree_init(&BTRFS_I(fs_info->btree_inode)->extent_tree,
672 GFP_NOFS);
673
674 BTRFS_I(fs_info->btree_inode)->io_tree.ops = &btree_extent_io_ops;
666 675
667 extent_map_tree_init(&fs_info->free_space_cache, 676 extent_io_tree_init(&fs_info->free_space_cache,
668 fs_info->btree_inode->i_mapping, GFP_NOFS); 677 fs_info->btree_inode->i_mapping, GFP_NOFS);
669 extent_map_tree_init(&fs_info->block_group_cache, 678 extent_io_tree_init(&fs_info->block_group_cache,
670 fs_info->btree_inode->i_mapping, GFP_NOFS); 679 fs_info->btree_inode->i_mapping, GFP_NOFS);
671 extent_map_tree_init(&fs_info->pinned_extents, 680 extent_io_tree_init(&fs_info->pinned_extents,
672 fs_info->btree_inode->i_mapping, GFP_NOFS); 681 fs_info->btree_inode->i_mapping, GFP_NOFS);
673 extent_map_tree_init(&fs_info->pending_del, 682 extent_io_tree_init(&fs_info->pending_del,
674 fs_info->btree_inode->i_mapping, GFP_NOFS); 683 fs_info->btree_inode->i_mapping, GFP_NOFS);
675 extent_map_tree_init(&fs_info->extent_ins, 684 extent_io_tree_init(&fs_info->extent_ins,
676 fs_info->btree_inode->i_mapping, GFP_NOFS); 685 fs_info->btree_inode->i_mapping, GFP_NOFS);
677 fs_info->do_barriers = 1; 686 fs_info->do_barriers = 1;
678 fs_info->closing = 0; 687 fs_info->closing = 0;
@@ -787,7 +796,7 @@ int write_ctree_super(struct btrfs_trans_handle *trans, struct btrfs_root
787 796
788 if (!btrfs_test_opt(root, NOBARRIER)) 797 if (!btrfs_test_opt(root, NOBARRIER))
789 blkdev_issue_flush(sb->s_bdev, NULL); 798 blkdev_issue_flush(sb->s_bdev, NULL);
790 set_extent_buffer_dirty(&BTRFS_I(btree_inode)->extent_tree, super); 799 set_extent_buffer_dirty(&BTRFS_I(btree_inode)->io_tree, super);
791 ret = sync_page_range_nolock(btree_inode, btree_inode->i_mapping, 800 ret = sync_page_range_nolock(btree_inode, btree_inode->i_mapping,
792 super->start, super->len); 801 super->start, super->len);
793 if (!btrfs_test_opt(root, NOBARRIER)) 802 if (!btrfs_test_opt(root, NOBARRIER))
@@ -864,12 +873,12 @@ int close_ctree(struct btrfs_root *root)
864 873
865 filemap_write_and_wait(fs_info->btree_inode->i_mapping); 874 filemap_write_and_wait(fs_info->btree_inode->i_mapping);
866 875
867 extent_map_tree_empty_lru(&fs_info->free_space_cache); 876 extent_io_tree_empty_lru(&fs_info->free_space_cache);
868 extent_map_tree_empty_lru(&fs_info->block_group_cache); 877 extent_io_tree_empty_lru(&fs_info->block_group_cache);
869 extent_map_tree_empty_lru(&fs_info->pinned_extents); 878 extent_io_tree_empty_lru(&fs_info->pinned_extents);
870 extent_map_tree_empty_lru(&fs_info->pending_del); 879 extent_io_tree_empty_lru(&fs_info->pending_del);
871 extent_map_tree_empty_lru(&fs_info->extent_ins); 880 extent_io_tree_empty_lru(&fs_info->extent_ins);
872 extent_map_tree_empty_lru(&BTRFS_I(fs_info->btree_inode)->extent_tree); 881 extent_io_tree_empty_lru(&BTRFS_I(fs_info->btree_inode)->io_tree);
873 882
874 truncate_inode_pages(fs_info->btree_inode->i_mapping, 0); 883 truncate_inode_pages(fs_info->btree_inode->i_mapping, 0);
875 884
@@ -892,13 +901,13 @@ int close_ctree(struct btrfs_root *root)
892int btrfs_buffer_uptodate(struct extent_buffer *buf) 901int btrfs_buffer_uptodate(struct extent_buffer *buf)
893{ 902{
894 struct inode *btree_inode = buf->first_page->mapping->host; 903 struct inode *btree_inode = buf->first_page->mapping->host;
895 return extent_buffer_uptodate(&BTRFS_I(btree_inode)->extent_tree, buf); 904 return extent_buffer_uptodate(&BTRFS_I(btree_inode)->io_tree, buf);
896} 905}
897 906
898int btrfs_set_buffer_uptodate(struct extent_buffer *buf) 907int btrfs_set_buffer_uptodate(struct extent_buffer *buf)
899{ 908{
900 struct inode *btree_inode = buf->first_page->mapping->host; 909 struct inode *btree_inode = buf->first_page->mapping->host;
901 return set_extent_buffer_uptodate(&BTRFS_I(btree_inode)->extent_tree, 910 return set_extent_buffer_uptodate(&BTRFS_I(btree_inode)->io_tree,
902 buf); 911 buf);
903} 912}
904 913
@@ -914,7 +923,7 @@ void btrfs_mark_buffer_dirty(struct extent_buffer *buf)
914 transid, root->fs_info->generation); 923 transid, root->fs_info->generation);
915 WARN_ON(1); 924 WARN_ON(1);
916 } 925 }
917 set_extent_buffer_dirty(&BTRFS_I(btree_inode)->extent_tree, buf); 926 set_extent_buffer_dirty(&BTRFS_I(btree_inode)->io_tree, buf);
918} 927}
919 928
920void btrfs_throttle(struct btrfs_root *root) 929void btrfs_throttle(struct btrfs_root *root)
@@ -941,7 +950,7 @@ void btrfs_set_buffer_defrag(struct extent_buffer *buf)
941{ 950{
942 struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root; 951 struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root;
943 struct inode *btree_inode = root->fs_info->btree_inode; 952 struct inode *btree_inode = root->fs_info->btree_inode;
944 set_extent_bits(&BTRFS_I(btree_inode)->extent_tree, buf->start, 953 set_extent_bits(&BTRFS_I(btree_inode)->io_tree, buf->start,
945 buf->start + buf->len - 1, EXTENT_DEFRAG, GFP_NOFS); 954 buf->start + buf->len - 1, EXTENT_DEFRAG, GFP_NOFS);
946} 955}
947 956
@@ -949,7 +958,7 @@ void btrfs_set_buffer_defrag_done(struct extent_buffer *buf)
949{ 958{
950 struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root; 959 struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root;
951 struct inode *btree_inode = root->fs_info->btree_inode; 960 struct inode *btree_inode = root->fs_info->btree_inode;
952 set_extent_bits(&BTRFS_I(btree_inode)->extent_tree, buf->start, 961 set_extent_bits(&BTRFS_I(btree_inode)->io_tree, buf->start,
953 buf->start + buf->len - 1, EXTENT_DEFRAG_DONE, 962 buf->start + buf->len - 1, EXTENT_DEFRAG_DONE,
954 GFP_NOFS); 963 GFP_NOFS);
955} 964}
@@ -958,7 +967,7 @@ int btrfs_buffer_defrag(struct extent_buffer *buf)
958{ 967{
959 struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root; 968 struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root;
960 struct inode *btree_inode = root->fs_info->btree_inode; 969 struct inode *btree_inode = root->fs_info->btree_inode;
961 return test_range_bit(&BTRFS_I(btree_inode)->extent_tree, 970 return test_range_bit(&BTRFS_I(btree_inode)->io_tree,
962 buf->start, buf->start + buf->len - 1, EXTENT_DEFRAG, 0); 971 buf->start, buf->start + buf->len - 1, EXTENT_DEFRAG, 0);
963} 972}
964 973
@@ -966,7 +975,7 @@ int btrfs_buffer_defrag_done(struct extent_buffer *buf)
966{ 975{
967 struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root; 976 struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root;
968 struct inode *btree_inode = root->fs_info->btree_inode; 977 struct inode *btree_inode = root->fs_info->btree_inode;
969 return test_range_bit(&BTRFS_I(btree_inode)->extent_tree, 978 return test_range_bit(&BTRFS_I(btree_inode)->io_tree,
970 buf->start, buf->start + buf->len - 1, 979 buf->start, buf->start + buf->len - 1,
971 EXTENT_DEFRAG_DONE, 0); 980 EXTENT_DEFRAG_DONE, 0);
972} 981}
@@ -975,7 +984,7 @@ int btrfs_clear_buffer_defrag_done(struct extent_buffer *buf)
975{ 984{
976 struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root; 985 struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root;
977 struct inode *btree_inode = root->fs_info->btree_inode; 986 struct inode *btree_inode = root->fs_info->btree_inode;
978 return clear_extent_bits(&BTRFS_I(btree_inode)->extent_tree, 987 return clear_extent_bits(&BTRFS_I(btree_inode)->io_tree,
979 buf->start, buf->start + buf->len - 1, 988 buf->start, buf->start + buf->len - 1,
980 EXTENT_DEFRAG_DONE, GFP_NOFS); 989 EXTENT_DEFRAG_DONE, GFP_NOFS);
981} 990}
@@ -984,7 +993,7 @@ int btrfs_clear_buffer_defrag(struct extent_buffer *buf)
984{ 993{
985 struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root; 994 struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root;
986 struct inode *btree_inode = root->fs_info->btree_inode; 995 struct inode *btree_inode = root->fs_info->btree_inode;
987 return clear_extent_bits(&BTRFS_I(btree_inode)->extent_tree, 996 return clear_extent_bits(&BTRFS_I(btree_inode)->io_tree,
988 buf->start, buf->start + buf->len - 1, 997 buf->start, buf->start + buf->len - 1,
989 EXTENT_DEFRAG, GFP_NOFS); 998 EXTENT_DEFRAG, GFP_NOFS);
990} 999}
@@ -993,10 +1002,10 @@ int btrfs_read_buffer(struct extent_buffer *buf)
993{ 1002{
994 struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root; 1003 struct btrfs_root *root = BTRFS_I(buf->first_page->mapping->host)->root;
995 struct inode *btree_inode = root->fs_info->btree_inode; 1004 struct inode *btree_inode = root->fs_info->btree_inode;
996 return read_extent_buffer_pages(&BTRFS_I(btree_inode)->extent_tree, 1005 return read_extent_buffer_pages(&BTRFS_I(btree_inode)->io_tree,
997 buf, 0, 1); 1006 buf, 0, 1);
998} 1007}
999 1008
1000static struct extent_map_ops btree_extent_map_ops = { 1009static struct extent_io_ops btree_extent_io_ops = {
1001 .writepage_io_hook = btree_writepage_io_hook, 1010 .writepage_io_hook = btree_writepage_io_hook,
1002}; 1011};