diff options
author | Josef Bacik <jbacik@fusionio.com> | 2013-04-24 16:41:19 -0400 |
---|---|---|
committer | Josef Bacik <jbacik@fusionio.com> | 2013-05-06 15:55:11 -0400 |
commit | fd8b2b611580929ab1aa01e3942dce20f9e95732 (patch) | |
tree | 54bbfbcb8551ecfb0c58f83e206a7512f268f758 /fs | |
parent | abefa55ac1f8cb8fb8cb4d7e8d619dc0859181ab (diff) |
Btrfs: cleanup destroy_marked_extents
We can just look up the extent_buffers for the range and free stuff that way.
This makes the cleanup a bit cleaner and we can make sure to evict the
extent_buffers pretty quickly by marking them as stale. Thanks,
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/disk-io.c | 40 | ||||
-rw-r--r-- | fs/btrfs/extent_io.c | 2 | ||||
-rw-r--r-- | fs/btrfs/extent_io.h | 1 |
3 files changed, 11 insertions, 32 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index b20f1121efae..aff571cb6e04 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -3752,13 +3752,9 @@ static int btrfs_destroy_marked_extents(struct btrfs_root *root, | |||
3752 | int mark) | 3752 | int mark) |
3753 | { | 3753 | { |
3754 | int ret; | 3754 | int ret; |
3755 | struct page *page; | ||
3756 | struct inode *btree_inode = root->fs_info->btree_inode; | ||
3757 | struct extent_buffer *eb; | 3755 | struct extent_buffer *eb; |
3758 | u64 start = 0; | 3756 | u64 start = 0; |
3759 | u64 end; | 3757 | u64 end; |
3760 | u64 offset; | ||
3761 | unsigned long index; | ||
3762 | 3758 | ||
3763 | while (1) { | 3759 | while (1) { |
3764 | ret = find_first_extent_bit(dirty_pages, start, &start, &end, | 3760 | ret = find_first_extent_bit(dirty_pages, start, &start, &end, |
@@ -3768,35 +3764,17 @@ static int btrfs_destroy_marked_extents(struct btrfs_root *root, | |||
3768 | 3764 | ||
3769 | clear_extent_bits(dirty_pages, start, end, mark, GFP_NOFS); | 3765 | clear_extent_bits(dirty_pages, start, end, mark, GFP_NOFS); |
3770 | while (start <= end) { | 3766 | while (start <= end) { |
3771 | index = start >> PAGE_CACHE_SHIFT; | 3767 | eb = btrfs_find_tree_block(root, start, |
3772 | start = (u64)(index + 1) << PAGE_CACHE_SHIFT; | 3768 | root->leafsize); |
3773 | page = find_get_page(btree_inode->i_mapping, index); | 3769 | start += eb->len; |
3774 | if (!page) | 3770 | if (!eb) |
3775 | continue; | 3771 | continue; |
3776 | offset = page_offset(page); | 3772 | wait_on_extent_buffer_writeback(eb); |
3777 | |||
3778 | spin_lock(&dirty_pages->buffer_lock); | ||
3779 | eb = radix_tree_lookup( | ||
3780 | &(&BTRFS_I(page->mapping->host)->io_tree)->buffer, | ||
3781 | offset >> PAGE_CACHE_SHIFT); | ||
3782 | spin_unlock(&dirty_pages->buffer_lock); | ||
3783 | if (eb) | ||
3784 | ret = test_and_clear_bit(EXTENT_BUFFER_DIRTY, | ||
3785 | &eb->bflags); | ||
3786 | lock_page(page); | ||
3787 | |||
3788 | wait_on_page_writeback(page); | ||
3789 | if (PageDirty(page)) { | ||
3790 | clear_page_dirty_for_io(page); | ||
3791 | spin_lock_irq(&page->mapping->tree_lock); | ||
3792 | radix_tree_tag_clear(&page->mapping->page_tree, | ||
3793 | page_index(page), | ||
3794 | PAGECACHE_TAG_DIRTY); | ||
3795 | spin_unlock_irq(&page->mapping->tree_lock); | ||
3796 | } | ||
3797 | 3773 | ||
3798 | unlock_page(page); | 3774 | if (test_and_clear_bit(EXTENT_BUFFER_DIRTY, |
3799 | page_cache_release(page); | 3775 | &eb->bflags)) |
3776 | clear_extent_buffer_dirty(eb); | ||
3777 | free_extent_buffer_stale(eb); | ||
3800 | } | 3778 | } |
3801 | } | 3779 | } |
3802 | 3780 | ||
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 2107a06679c5..d9a82f261e04 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
@@ -3162,7 +3162,7 @@ static int eb_wait(void *word) | |||
3162 | return 0; | 3162 | return 0; |
3163 | } | 3163 | } |
3164 | 3164 | ||
3165 | static void wait_on_extent_buffer_writeback(struct extent_buffer *eb) | 3165 | void wait_on_extent_buffer_writeback(struct extent_buffer *eb) |
3166 | { | 3166 | { |
3167 | wait_on_bit(&eb->bflags, EXTENT_BUFFER_WRITEBACK, eb_wait, | 3167 | wait_on_bit(&eb->bflags, EXTENT_BUFFER_WRITEBACK, eb_wait, |
3168 | TASK_UNINTERRUPTIBLE); | 3168 | TASK_UNINTERRUPTIBLE); |
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h index db009d80bef4..fa86861de244 100644 --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h | |||
@@ -282,6 +282,7 @@ void free_extent_buffer_stale(struct extent_buffer *eb); | |||
282 | int read_extent_buffer_pages(struct extent_io_tree *tree, | 282 | int read_extent_buffer_pages(struct extent_io_tree *tree, |
283 | struct extent_buffer *eb, u64 start, int wait, | 283 | struct extent_buffer *eb, u64 start, int wait, |
284 | get_extent_t *get_extent, int mirror_num); | 284 | get_extent_t *get_extent, int mirror_num); |
285 | void wait_on_extent_buffer_writeback(struct extent_buffer *eb); | ||
285 | 286 | ||
286 | static inline unsigned long num_extent_pages(u64 start, u64 len) | 287 | static inline unsigned long num_extent_pages(u64 start, u64 len) |
287 | { | 288 | { |