diff options
author | David Sterba <dsterba@suse.cz> | 2014-07-30 19:03:53 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2014-10-02 11:30:32 -0400 |
commit | fb85fc9a675738ee2746b51c3aedde944b18ca02 (patch) | |
tree | 5743373c5a411c8d5112d6d8b5ee83d7836c483a /fs/btrfs | |
parent | a50924e3a4d7fccb0ecfbd42a4c7ed6e56ee1765 (diff) |
btrfs: kill extent_buffer_page helper
It used to be more complex but now it's just a simple array access.
Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/extent_io.c | 55 | ||||
-rw-r--r-- | fs/btrfs/extent_io.h | 6 |
2 files changed, 26 insertions, 35 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 638e1a5b00e2..3359969b1a36 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
@@ -2064,7 +2064,7 @@ int repair_eb_io_failure(struct btrfs_root *root, struct extent_buffer *eb, | |||
2064 | return -EROFS; | 2064 | return -EROFS; |
2065 | 2065 | ||
2066 | for (i = 0; i < num_pages; i++) { | 2066 | for (i = 0; i < num_pages; i++) { |
2067 | struct page *p = extent_buffer_page(eb, i); | 2067 | struct page *p = eb->pages[i]; |
2068 | 2068 | ||
2069 | ret = repair_io_failure(root->fs_info->btree_inode, start, | 2069 | ret = repair_io_failure(root->fs_info->btree_inode, start, |
2070 | PAGE_CACHE_SIZE, start, p, | 2070 | PAGE_CACHE_SIZE, start, p, |
@@ -3580,7 +3580,7 @@ lock_extent_buffer_for_io(struct extent_buffer *eb, | |||
3580 | 3580 | ||
3581 | num_pages = num_extent_pages(eb->start, eb->len); | 3581 | num_pages = num_extent_pages(eb->start, eb->len); |
3582 | for (i = 0; i < num_pages; i++) { | 3582 | for (i = 0; i < num_pages; i++) { |
3583 | struct page *p = extent_buffer_page(eb, i); | 3583 | struct page *p = eb->pages[i]; |
3584 | 3584 | ||
3585 | if (!trylock_page(p)) { | 3585 | if (!trylock_page(p)) { |
3586 | if (!flush) { | 3586 | if (!flush) { |
@@ -3651,7 +3651,7 @@ static noinline_for_stack int write_one_eb(struct extent_buffer *eb, | |||
3651 | bio_flags = EXTENT_BIO_TREE_LOG; | 3651 | bio_flags = EXTENT_BIO_TREE_LOG; |
3652 | 3652 | ||
3653 | for (i = 0; i < num_pages; i++) { | 3653 | for (i = 0; i < num_pages; i++) { |
3654 | struct page *p = extent_buffer_page(eb, i); | 3654 | struct page *p = eb->pages[i]; |
3655 | 3655 | ||
3656 | clear_page_dirty_for_io(p); | 3656 | clear_page_dirty_for_io(p); |
3657 | set_page_writeback(p); | 3657 | set_page_writeback(p); |
@@ -3674,10 +3674,8 @@ static noinline_for_stack int write_one_eb(struct extent_buffer *eb, | |||
3674 | } | 3674 | } |
3675 | 3675 | ||
3676 | if (unlikely(ret)) { | 3676 | if (unlikely(ret)) { |
3677 | for (; i < num_pages; i++) { | 3677 | for (; i < num_pages; i++) |
3678 | struct page *p = extent_buffer_page(eb, i); | 3678 | unlock_page(eb->pages[i]); |
3679 | unlock_page(p); | ||
3680 | } | ||
3681 | } | 3679 | } |
3682 | 3680 | ||
3683 | return ret; | 3681 | return ret; |
@@ -4464,7 +4462,7 @@ static void btrfs_release_extent_buffer_page(struct extent_buffer *eb) | |||
4464 | 4462 | ||
4465 | do { | 4463 | do { |
4466 | index--; | 4464 | index--; |
4467 | page = extent_buffer_page(eb, index); | 4465 | page = eb->pages[index]; |
4468 | if (page && mapped) { | 4466 | if (page && mapped) { |
4469 | spin_lock(&page->mapping->private_lock); | 4467 | spin_lock(&page->mapping->private_lock); |
4470 | /* | 4468 | /* |
@@ -4646,7 +4644,8 @@ static void mark_extent_buffer_accessed(struct extent_buffer *eb, | |||
4646 | 4644 | ||
4647 | num_pages = num_extent_pages(eb->start, eb->len); | 4645 | num_pages = num_extent_pages(eb->start, eb->len); |
4648 | for (i = 0; i < num_pages; i++) { | 4646 | for (i = 0; i < num_pages; i++) { |
4649 | struct page *p = extent_buffer_page(eb, i); | 4647 | struct page *p = eb->pages[i]; |
4648 | |||
4650 | if (p != accessed) | 4649 | if (p != accessed) |
4651 | mark_page_accessed(p); | 4650 | mark_page_accessed(p); |
4652 | } | 4651 | } |
@@ -4815,7 +4814,7 @@ again: | |||
4815 | */ | 4814 | */ |
4816 | SetPageChecked(eb->pages[0]); | 4815 | SetPageChecked(eb->pages[0]); |
4817 | for (i = 1; i < num_pages; i++) { | 4816 | for (i = 1; i < num_pages; i++) { |
4818 | p = extent_buffer_page(eb, i); | 4817 | p = eb->pages[i]; |
4819 | ClearPageChecked(p); | 4818 | ClearPageChecked(p); |
4820 | unlock_page(p); | 4819 | unlock_page(p); |
4821 | } | 4820 | } |
@@ -4926,7 +4925,7 @@ void clear_extent_buffer_dirty(struct extent_buffer *eb) | |||
4926 | num_pages = num_extent_pages(eb->start, eb->len); | 4925 | num_pages = num_extent_pages(eb->start, eb->len); |
4927 | 4926 | ||
4928 | for (i = 0; i < num_pages; i++) { | 4927 | for (i = 0; i < num_pages; i++) { |
4929 | page = extent_buffer_page(eb, i); | 4928 | page = eb->pages[i]; |
4930 | if (!PageDirty(page)) | 4929 | if (!PageDirty(page)) |
4931 | continue; | 4930 | continue; |
4932 | 4931 | ||
@@ -4962,7 +4961,7 @@ int set_extent_buffer_dirty(struct extent_buffer *eb) | |||
4962 | WARN_ON(!test_bit(EXTENT_BUFFER_TREE_REF, &eb->bflags)); | 4961 | WARN_ON(!test_bit(EXTENT_BUFFER_TREE_REF, &eb->bflags)); |
4963 | 4962 | ||
4964 | for (i = 0; i < num_pages; i++) | 4963 | for (i = 0; i < num_pages; i++) |
4965 | set_page_dirty(extent_buffer_page(eb, i)); | 4964 | set_page_dirty(eb->pages[i]); |
4966 | return was_dirty; | 4965 | return was_dirty; |
4967 | } | 4966 | } |
4968 | 4967 | ||
@@ -4975,7 +4974,7 @@ int clear_extent_buffer_uptodate(struct extent_buffer *eb) | |||
4975 | clear_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags); | 4974 | clear_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags); |
4976 | num_pages = num_extent_pages(eb->start, eb->len); | 4975 | num_pages = num_extent_pages(eb->start, eb->len); |
4977 | for (i = 0; i < num_pages; i++) { | 4976 | for (i = 0; i < num_pages; i++) { |
4978 | page = extent_buffer_page(eb, i); | 4977 | page = eb->pages[i]; |
4979 | if (page) | 4978 | if (page) |
4980 | ClearPageUptodate(page); | 4979 | ClearPageUptodate(page); |
4981 | } | 4980 | } |
@@ -4991,7 +4990,7 @@ int set_extent_buffer_uptodate(struct extent_buffer *eb) | |||
4991 | set_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags); | 4990 | set_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags); |
4992 | num_pages = num_extent_pages(eb->start, eb->len); | 4991 | num_pages = num_extent_pages(eb->start, eb->len); |
4993 | for (i = 0; i < num_pages; i++) { | 4992 | for (i = 0; i < num_pages; i++) { |
4994 | page = extent_buffer_page(eb, i); | 4993 | page = eb->pages[i]; |
4995 | SetPageUptodate(page); | 4994 | SetPageUptodate(page); |
4996 | } | 4995 | } |
4997 | return 0; | 4996 | return 0; |
@@ -5031,7 +5030,7 @@ int read_extent_buffer_pages(struct extent_io_tree *tree, | |||
5031 | 5030 | ||
5032 | num_pages = num_extent_pages(eb->start, eb->len); | 5031 | num_pages = num_extent_pages(eb->start, eb->len); |
5033 | for (i = start_i; i < num_pages; i++) { | 5032 | for (i = start_i; i < num_pages; i++) { |
5034 | page = extent_buffer_page(eb, i); | 5033 | page = eb->pages[i]; |
5035 | if (wait == WAIT_NONE) { | 5034 | if (wait == WAIT_NONE) { |
5036 | if (!trylock_page(page)) | 5035 | if (!trylock_page(page)) |
5037 | goto unlock_exit; | 5036 | goto unlock_exit; |
@@ -5054,7 +5053,7 @@ int read_extent_buffer_pages(struct extent_io_tree *tree, | |||
5054 | eb->read_mirror = 0; | 5053 | eb->read_mirror = 0; |
5055 | atomic_set(&eb->io_pages, num_reads); | 5054 | atomic_set(&eb->io_pages, num_reads); |
5056 | for (i = start_i; i < num_pages; i++) { | 5055 | for (i = start_i; i < num_pages; i++) { |
5057 | page = extent_buffer_page(eb, i); | 5056 | page = eb->pages[i]; |
5058 | if (!PageUptodate(page)) { | 5057 | if (!PageUptodate(page)) { |
5059 | ClearPageError(page); | 5058 | ClearPageError(page); |
5060 | err = __extent_read_full_page(tree, page, | 5059 | err = __extent_read_full_page(tree, page, |
@@ -5079,7 +5078,7 @@ int read_extent_buffer_pages(struct extent_io_tree *tree, | |||
5079 | return ret; | 5078 | return ret; |
5080 | 5079 | ||
5081 | for (i = start_i; i < num_pages; i++) { | 5080 | for (i = start_i; i < num_pages; i++) { |
5082 | page = extent_buffer_page(eb, i); | 5081 | page = eb->pages[i]; |
5083 | wait_on_page_locked(page); | 5082 | wait_on_page_locked(page); |
5084 | if (!PageUptodate(page)) | 5083 | if (!PageUptodate(page)) |
5085 | ret = -EIO; | 5084 | ret = -EIO; |
@@ -5090,7 +5089,7 @@ int read_extent_buffer_pages(struct extent_io_tree *tree, | |||
5090 | unlock_exit: | 5089 | unlock_exit: |
5091 | i = start_i; | 5090 | i = start_i; |
5092 | while (locked_pages > 0) { | 5091 | while (locked_pages > 0) { |
5093 | page = extent_buffer_page(eb, i); | 5092 | page = eb->pages[i]; |
5094 | i++; | 5093 | i++; |
5095 | unlock_page(page); | 5094 | unlock_page(page); |
5096 | locked_pages--; | 5095 | locked_pages--; |
@@ -5116,7 +5115,7 @@ void read_extent_buffer(struct extent_buffer *eb, void *dstv, | |||
5116 | offset = (start_offset + start) & (PAGE_CACHE_SIZE - 1); | 5115 | offset = (start_offset + start) & (PAGE_CACHE_SIZE - 1); |
5117 | 5116 | ||
5118 | while (len > 0) { | 5117 | while (len > 0) { |
5119 | page = extent_buffer_page(eb, i); | 5118 | page = eb->pages[i]; |
5120 | 5119 | ||
5121 | cur = min(len, (PAGE_CACHE_SIZE - offset)); | 5120 | cur = min(len, (PAGE_CACHE_SIZE - offset)); |
5122 | kaddr = page_address(page); | 5121 | kaddr = page_address(page); |
@@ -5148,7 +5147,7 @@ int read_extent_buffer_to_user(struct extent_buffer *eb, void __user *dstv, | |||
5148 | offset = (start_offset + start) & (PAGE_CACHE_SIZE - 1); | 5147 | offset = (start_offset + start) & (PAGE_CACHE_SIZE - 1); |
5149 | 5148 | ||
5150 | while (len > 0) { | 5149 | while (len > 0) { |
5151 | page = extent_buffer_page(eb, i); | 5150 | page = eb->pages[i]; |
5152 | 5151 | ||
5153 | cur = min(len, (PAGE_CACHE_SIZE - offset)); | 5152 | cur = min(len, (PAGE_CACHE_SIZE - offset)); |
5154 | kaddr = page_address(page); | 5153 | kaddr = page_address(page); |
@@ -5197,7 +5196,7 @@ int map_private_extent_buffer(struct extent_buffer *eb, unsigned long start, | |||
5197 | return -EINVAL; | 5196 | return -EINVAL; |
5198 | } | 5197 | } |
5199 | 5198 | ||
5200 | p = extent_buffer_page(eb, i); | 5199 | p = eb->pages[i]; |
5201 | kaddr = page_address(p); | 5200 | kaddr = page_address(p); |
5202 | *map = kaddr + offset; | 5201 | *map = kaddr + offset; |
5203 | *map_len = PAGE_CACHE_SIZE - offset; | 5202 | *map_len = PAGE_CACHE_SIZE - offset; |
@@ -5223,7 +5222,7 @@ int memcmp_extent_buffer(struct extent_buffer *eb, const void *ptrv, | |||
5223 | offset = (start_offset + start) & (PAGE_CACHE_SIZE - 1); | 5222 | offset = (start_offset + start) & (PAGE_CACHE_SIZE - 1); |
5224 | 5223 | ||
5225 | while (len > 0) { | 5224 | while (len > 0) { |
5226 | page = extent_buffer_page(eb, i); | 5225 | page = eb->pages[i]; |
5227 | 5226 | ||
5228 | cur = min(len, (PAGE_CACHE_SIZE - offset)); | 5227 | cur = min(len, (PAGE_CACHE_SIZE - offset)); |
5229 | 5228 | ||
@@ -5257,7 +5256,7 @@ void write_extent_buffer(struct extent_buffer *eb, const void *srcv, | |||
5257 | offset = (start_offset + start) & (PAGE_CACHE_SIZE - 1); | 5256 | offset = (start_offset + start) & (PAGE_CACHE_SIZE - 1); |
5258 | 5257 | ||
5259 | while (len > 0) { | 5258 | while (len > 0) { |
5260 | page = extent_buffer_page(eb, i); | 5259 | page = eb->pages[i]; |
5261 | WARN_ON(!PageUptodate(page)); | 5260 | WARN_ON(!PageUptodate(page)); |
5262 | 5261 | ||
5263 | cur = min(len, PAGE_CACHE_SIZE - offset); | 5262 | cur = min(len, PAGE_CACHE_SIZE - offset); |
@@ -5287,7 +5286,7 @@ void memset_extent_buffer(struct extent_buffer *eb, char c, | |||
5287 | offset = (start_offset + start) & (PAGE_CACHE_SIZE - 1); | 5286 | offset = (start_offset + start) & (PAGE_CACHE_SIZE - 1); |
5288 | 5287 | ||
5289 | while (len > 0) { | 5288 | while (len > 0) { |
5290 | page = extent_buffer_page(eb, i); | 5289 | page = eb->pages[i]; |
5291 | WARN_ON(!PageUptodate(page)); | 5290 | WARN_ON(!PageUptodate(page)); |
5292 | 5291 | ||
5293 | cur = min(len, PAGE_CACHE_SIZE - offset); | 5292 | cur = min(len, PAGE_CACHE_SIZE - offset); |
@@ -5318,7 +5317,7 @@ void copy_extent_buffer(struct extent_buffer *dst, struct extent_buffer *src, | |||
5318 | (PAGE_CACHE_SIZE - 1); | 5317 | (PAGE_CACHE_SIZE - 1); |
5319 | 5318 | ||
5320 | while (len > 0) { | 5319 | while (len > 0) { |
5321 | page = extent_buffer_page(dst, i); | 5320 | page = dst->pages[i]; |
5322 | WARN_ON(!PageUptodate(page)); | 5321 | WARN_ON(!PageUptodate(page)); |
5323 | 5322 | ||
5324 | cur = min(len, (unsigned long)(PAGE_CACHE_SIZE - offset)); | 5323 | cur = min(len, (unsigned long)(PAGE_CACHE_SIZE - offset)); |
@@ -5396,8 +5395,7 @@ void memcpy_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset, | |||
5396 | cur = min_t(unsigned long, cur, | 5395 | cur = min_t(unsigned long, cur, |
5397 | (unsigned long)(PAGE_CACHE_SIZE - dst_off_in_page)); | 5396 | (unsigned long)(PAGE_CACHE_SIZE - dst_off_in_page)); |
5398 | 5397 | ||
5399 | copy_pages(extent_buffer_page(dst, dst_i), | 5398 | copy_pages(dst->pages[dst_i], dst->pages[src_i], |
5400 | extent_buffer_page(dst, src_i), | ||
5401 | dst_off_in_page, src_off_in_page, cur); | 5399 | dst_off_in_page, src_off_in_page, cur); |
5402 | 5400 | ||
5403 | src_offset += cur; | 5401 | src_offset += cur; |
@@ -5443,8 +5441,7 @@ void memmove_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset, | |||
5443 | 5441 | ||
5444 | cur = min_t(unsigned long, len, src_off_in_page + 1); | 5442 | cur = min_t(unsigned long, len, src_off_in_page + 1); |
5445 | cur = min(cur, dst_off_in_page + 1); | 5443 | cur = min(cur, dst_off_in_page + 1); |
5446 | copy_pages(extent_buffer_page(dst, dst_i), | 5444 | copy_pages(dst->pages[dst_i], dst->pages[src_i], |
5447 | extent_buffer_page(dst, src_i), | ||
5448 | dst_off_in_page - cur + 1, | 5445 | dst_off_in_page - cur + 1, |
5449 | src_off_in_page - cur + 1, cur); | 5446 | src_off_in_page - cur + 1, cur); |
5450 | 5447 | ||
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h index 1e06f0e4a185..63f2b10ee763 100644 --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h | |||
@@ -279,12 +279,6 @@ static inline unsigned long num_extent_pages(u64 start, u64 len) | |||
279 | (start >> PAGE_CACHE_SHIFT); | 279 | (start >> PAGE_CACHE_SHIFT); |
280 | } | 280 | } |
281 | 281 | ||
282 | static inline struct page *extent_buffer_page(struct extent_buffer *eb, | ||
283 | unsigned long i) | ||
284 | { | ||
285 | return eb->pages[i]; | ||
286 | } | ||
287 | |||
288 | static inline void extent_buffer_get(struct extent_buffer *eb) | 282 | static inline void extent_buffer_get(struct extent_buffer *eb) |
289 | { | 283 | { |
290 | atomic_inc(&eb->refs); | 284 | atomic_inc(&eb->refs); |