Skip to content

Commit 5df4235

Browse files
Josef Bacikchrismason-xx
authored andcommitted
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 <[email protected]>
1 parent 3083ee2 commit 5df4235

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

fs/btrfs/extent_io.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3683,6 +3683,17 @@ static inline void btrfs_release_extent_buffer(struct extent_buffer *eb)
36833683
__free_extent_buffer(eb);
36843684
}
36853685

3686+
static 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+
36863697
struct extent_buffer *alloc_extent_buffer(struct extent_io_tree *tree,
36873698
u64 start, unsigned long len)
36883699
{
@@ -3700,7 +3711,7 @@ struct extent_buffer *alloc_extent_buffer(struct extent_io_tree *tree,
37003711
eb = radix_tree_lookup(&tree->buffer, start >> PAGE_CACHE_SHIFT);
37013712
if (eb && atomic_inc_not_zero(&eb->refs)) {
37023713
rcu_read_unlock();
3703-
mark_page_accessed(eb->pages[0]);
3714+
mark_extent_buffer_accessed(eb);
37043715
return eb;
37053716
}
37063717
rcu_read_unlock();
@@ -3729,6 +3740,7 @@ struct extent_buffer *alloc_extent_buffer(struct extent_io_tree *tree,
37293740
if (atomic_inc_not_zero(&exists->refs)) {
37303741
spin_unlock(&mapping->private_lock);
37313742
unlock_page(p);
3743+
mark_extent_buffer_accessed(exists);
37323744
goto free_eb;
37333745
}
37343746

@@ -3771,6 +3783,7 @@ struct extent_buffer *alloc_extent_buffer(struct extent_io_tree *tree,
37713783
}
37723784
spin_unlock(&tree->buffer_lock);
37733785
radix_tree_preload_end();
3786+
mark_extent_buffer_accessed(exists);
37743787
goto free_eb;
37753788
}
37763789
/* add one reference for the tree */
@@ -3820,7 +3833,7 @@ struct extent_buffer *find_extent_buffer(struct extent_io_tree *tree,
38203833
eb = radix_tree_lookup(&tree->buffer, start >> PAGE_CACHE_SHIFT);
38213834
if (eb && atomic_inc_not_zero(&eb->refs)) {
38223835
rcu_read_unlock();
3823-
mark_page_accessed(eb->pages[0]);
3836+
mark_extent_buffer_accessed(eb);
38243837
return eb;
38253838
}
38263839
rcu_read_unlock();

0 commit comments

Comments
 (0)