aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent_io.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/extent_io.c')
-rw-r--r--fs/btrfs/extent_io.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 0ce14369920c..4a97d8fd958d 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3683,6 +3683,17 @@ static inline void btrfs_release_extent_buffer(struct extent_buffer *eb)
3683 __free_extent_buffer(eb); 3683 __free_extent_buffer(eb);
3684} 3684}
3685 3685
3686static void mark_extent_buffer_accessed(struct extent_buffer *eb)
3687{
3688 unsigned long num_pages, i;
3689
3690 num_pages = num_extent_pages(eb->start, eb->len);
3691 for (i = 0; i < num_pages; i++) {
3692 struct page *p = extent_buffer_page(eb, i);
3693 mark_page_accessed(p);
3694 }
3695}
3696
3686struct extent_buffer *alloc_extent_buffer(struct extent_io_tree *tree, 3697struct extent_buffer *alloc_extent_buffer(struct extent_io_tree *tree,
3687 u64 start, unsigned long len) 3698 u64 start, unsigned long len)
3688{ 3699{
@@ -3700,7 +3711,7 @@ struct extent_buffer *alloc_extent_buffer(struct extent_io_tree *tree,
3700 eb = radix_tree_lookup(&tree->buffer, start >> PAGE_CACHE_SHIFT); 3711 eb = radix_tree_lookup(&tree->buffer, start >> PAGE_CACHE_SHIFT);
3701 if (eb && atomic_inc_not_zero(&eb->refs)) { 3712 if (eb && atomic_inc_not_zero(&eb->refs)) {
3702 rcu_read_unlock(); 3713 rcu_read_unlock();
3703 mark_page_accessed(eb->pages[0]); 3714 mark_extent_buffer_accessed(eb);
3704 return eb; 3715 return eb;
3705 } 3716 }
3706 rcu_read_unlock(); 3717 rcu_read_unlock();
@@ -3729,6 +3740,7 @@ struct extent_buffer *alloc_extent_buffer(struct extent_io_tree *tree,
3729 if (atomic_inc_not_zero(&exists->refs)) { 3740 if (atomic_inc_not_zero(&exists->refs)) {
3730 spin_unlock(&mapping->private_lock); 3741 spin_unlock(&mapping->private_lock);
3731 unlock_page(p); 3742 unlock_page(p);
3743 mark_extent_buffer_accessed(exists);
3732 goto free_eb; 3744 goto free_eb;
3733 } 3745 }
3734 3746
@@ -3771,6 +3783,7 @@ again:
3771 } 3783 }
3772 spin_unlock(&tree->buffer_lock); 3784 spin_unlock(&tree->buffer_lock);
3773 radix_tree_preload_end(); 3785 radix_tree_preload_end();
3786 mark_extent_buffer_accessed(exists);
3774 goto free_eb; 3787 goto free_eb;
3775 } 3788 }
3776 /* add one reference for the tree */ 3789 /* add one reference for the tree */
@@ -3820,7 +3833,7 @@ struct extent_buffer *find_extent_buffer(struct extent_io_tree *tree,
3820 eb = radix_tree_lookup(&tree->buffer, start >> PAGE_CACHE_SHIFT); 3833 eb = radix_tree_lookup(&tree->buffer, start >> PAGE_CACHE_SHIFT);
3821 if (eb && atomic_inc_not_zero(&eb->refs)) { 3834 if (eb && atomic_inc_not_zero(&eb->refs)) {
3822 rcu_read_unlock(); 3835 rcu_read_unlock();
3823 mark_page_accessed(eb->pages[0]); 3836 mark_extent_buffer_accessed(eb);
3824 return eb; 3837 return eb;
3825 } 3838 }
3826 rcu_read_unlock(); 3839 rcu_read_unlock();