aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent_io.c
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2012-03-15 18:24:42 -0400
committerChris Mason <chris.mason@oracle.com>2012-03-26 16:51:09 -0400
commit5df4235ea15bd39f441ef334d8329b3d46b2cc57 (patch)
tree119c51eff74939bcd8f1d1b3632b123fd805185d /fs/btrfs/extent_io.c
parent3083ee2e18b701122a3b841db83448543a87a583 (diff)
Btrfs: introduce mark_extent_buffer_accessed
Because an eb can have multiple pages we need to make sure that all pages within the eb are markes as accessed, since releasepage can be called against any page in the eb. This will keep us from possibly evicting hot eb's when we're doing larger than pagesize eb's. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com>
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();