aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent_io.c
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2016-06-22 18:54:23 -0400
committerDavid Sterba <dsterba@suse.com>2016-12-06 10:06:59 -0500
commit0b246afa62b0cf5b09d078121f543135f28492ad (patch)
tree200ad296d09f1b2f5329658c8de81bc625007ace /fs/btrfs/extent_io.c
parent6202df6921494f29308307e0ae6f567c2ab2ba19 (diff)
btrfs: root->fs_info cleanup, add fs_info convenience variables
In routines where someptr->fs_info is referenced multiple times, we introduce a convenience variable. This makes the code considerably more readable. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/extent_io.c')
-rw-r--r--fs/btrfs/extent_io.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 3747af693e78..8df72ded9018 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2070,17 +2070,18 @@ int repair_io_failure(struct inode *inode, u64 start, u64 length, u64 logical,
2070int repair_eb_io_failure(struct btrfs_root *root, struct extent_buffer *eb, 2070int repair_eb_io_failure(struct btrfs_root *root, struct extent_buffer *eb,
2071 int mirror_num) 2071 int mirror_num)
2072{ 2072{
2073 struct btrfs_fs_info *fs_info = root->fs_info;
2073 u64 start = eb->start; 2074 u64 start = eb->start;
2074 unsigned long i, num_pages = num_extent_pages(eb->start, eb->len); 2075 unsigned long i, num_pages = num_extent_pages(eb->start, eb->len);
2075 int ret = 0; 2076 int ret = 0;
2076 2077
2077 if (root->fs_info->sb->s_flags & MS_RDONLY) 2078 if (fs_info->sb->s_flags & MS_RDONLY)
2078 return -EROFS; 2079 return -EROFS;
2079 2080
2080 for (i = 0; i < num_pages; i++) { 2081 for (i = 0; i < num_pages; i++) {
2081 struct page *p = eb->pages[i]; 2082 struct page *p = eb->pages[i];
2082 2083
2083 ret = repair_io_failure(root->fs_info->btree_inode, start, 2084 ret = repair_io_failure(fs_info->btree_inode, start,
2084 PAGE_SIZE, start, p, 2085 PAGE_SIZE, start, p,
2085 start - page_offset(p), mirror_num); 2086 start - page_offset(p), mirror_num);
2086 if (ret) 2087 if (ret)
@@ -2341,6 +2342,7 @@ struct bio *btrfs_create_repair_bio(struct inode *inode, struct bio *failed_bio,
2341 struct page *page, int pg_offset, int icsum, 2342 struct page *page, int pg_offset, int icsum,
2342 bio_end_io_t *endio_func, void *data) 2343 bio_end_io_t *endio_func, void *data)
2343{ 2344{
2345 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
2344 struct bio *bio; 2346 struct bio *bio;
2345 struct btrfs_io_bio *btrfs_failed_bio; 2347 struct btrfs_io_bio *btrfs_failed_bio;
2346 struct btrfs_io_bio *btrfs_bio; 2348 struct btrfs_io_bio *btrfs_bio;
@@ -2351,13 +2353,12 @@ struct bio *btrfs_create_repair_bio(struct inode *inode, struct bio *failed_bio,
2351 2353
2352 bio->bi_end_io = endio_func; 2354 bio->bi_end_io = endio_func;
2353 bio->bi_iter.bi_sector = failrec->logical >> 9; 2355 bio->bi_iter.bi_sector = failrec->logical >> 9;
2354 bio->bi_bdev = BTRFS_I(inode)->root->fs_info->fs_devices->latest_bdev; 2356 bio->bi_bdev = fs_info->fs_devices->latest_bdev;
2355 bio->bi_iter.bi_size = 0; 2357 bio->bi_iter.bi_size = 0;
2356 bio->bi_private = data; 2358 bio->bi_private = data;
2357 2359
2358 btrfs_failed_bio = btrfs_io_bio(failed_bio); 2360 btrfs_failed_bio = btrfs_io_bio(failed_bio);
2359 if (btrfs_failed_bio->csum) { 2361 if (btrfs_failed_bio->csum) {
2360 struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info;
2361 u16 csum_size = btrfs_super_csum_size(fs_info->super_copy); 2362 u16 csum_size = btrfs_super_csum_size(fs_info->super_copy);
2362 2363
2363 btrfs_bio = btrfs_io_bio(bio); 2364 btrfs_bio = btrfs_io_bio(bio);
@@ -2476,6 +2477,8 @@ static void end_bio_extent_writepage(struct bio *bio)
2476 2477
2477 bio_for_each_segment_all(bvec, bio, i) { 2478 bio_for_each_segment_all(bvec, bio, i) {
2478 struct page *page = bvec->bv_page; 2479 struct page *page = bvec->bv_page;
2480 struct inode *inode = page->mapping->host;
2481 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
2479 2482
2480 /* We always issue full-page reads, but if some block 2483 /* We always issue full-page reads, but if some block
2481 * in a page fails to read, blk_update_request() will 2484 * in a page fails to read, blk_update_request() will
@@ -2484,11 +2487,11 @@ static void end_bio_extent_writepage(struct bio *bio)
2484 * if they don't add up to a full page. */ 2487 * if they don't add up to a full page. */
2485 if (bvec->bv_offset || bvec->bv_len != PAGE_SIZE) { 2488 if (bvec->bv_offset || bvec->bv_len != PAGE_SIZE) {
2486 if (bvec->bv_offset + bvec->bv_len != PAGE_SIZE) 2489 if (bvec->bv_offset + bvec->bv_len != PAGE_SIZE)
2487 btrfs_err(BTRFS_I(page->mapping->host)->root->fs_info, 2490 btrfs_err(fs_info,
2488 "partial page write in btrfs with offset %u and length %u", 2491 "partial page write in btrfs with offset %u and length %u",
2489 bvec->bv_offset, bvec->bv_len); 2492 bvec->bv_offset, bvec->bv_len);
2490 else 2493 else
2491 btrfs_info(BTRFS_I(page->mapping->host)->root->fs_info, 2494 btrfs_info(fs_info,
2492 "incomplete page write in btrfs with offset %u and length %u", 2495 "incomplete page write in btrfs with offset %u and length %u",
2493 bvec->bv_offset, bvec->bv_len); 2496 bvec->bv_offset, bvec->bv_len);
2494 } 2497 }
@@ -5789,6 +5792,7 @@ static void copy_pages(struct page *dst_page, struct page *src_page,
5789void memcpy_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset, 5792void memcpy_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
5790 unsigned long src_offset, unsigned long len) 5793 unsigned long src_offset, unsigned long len)
5791{ 5794{
5795 struct btrfs_fs_info *fs_info = dst->fs_info;
5792 size_t cur; 5796 size_t cur;
5793 size_t dst_off_in_page; 5797 size_t dst_off_in_page;
5794 size_t src_off_in_page; 5798 size_t src_off_in_page;
@@ -5797,13 +5801,13 @@ void memcpy_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
5797 unsigned long src_i; 5801 unsigned long src_i;
5798 5802
5799 if (src_offset + len > dst->len) { 5803 if (src_offset + len > dst->len) {
5800 btrfs_err(dst->fs_info, 5804 btrfs_err(fs_info,
5801 "memmove bogus src_offset %lu move len %lu dst len %lu", 5805 "memmove bogus src_offset %lu move len %lu dst len %lu",
5802 src_offset, len, dst->len); 5806 src_offset, len, dst->len);
5803 BUG_ON(1); 5807 BUG_ON(1);
5804 } 5808 }
5805 if (dst_offset + len > dst->len) { 5809 if (dst_offset + len > dst->len) {
5806 btrfs_err(dst->fs_info, 5810 btrfs_err(fs_info,
5807 "memmove bogus dst_offset %lu move len %lu dst len %lu", 5811 "memmove bogus dst_offset %lu move len %lu dst len %lu",
5808 dst_offset, len, dst->len); 5812 dst_offset, len, dst->len);
5809 BUG_ON(1); 5813 BUG_ON(1);
@@ -5835,6 +5839,7 @@ void memcpy_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
5835void memmove_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset, 5839void memmove_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
5836 unsigned long src_offset, unsigned long len) 5840 unsigned long src_offset, unsigned long len)
5837{ 5841{
5842 struct btrfs_fs_info *fs_info = dst->fs_info;
5838 size_t cur; 5843 size_t cur;
5839 size_t dst_off_in_page; 5844 size_t dst_off_in_page;
5840 size_t src_off_in_page; 5845 size_t src_off_in_page;
@@ -5845,13 +5850,13 @@ void memmove_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
5845 unsigned long src_i; 5850 unsigned long src_i;
5846 5851
5847 if (src_offset + len > dst->len) { 5852 if (src_offset + len > dst->len) {
5848 btrfs_err(dst->fs_info, 5853 btrfs_err(fs_info,
5849 "memmove bogus src_offset %lu move len %lu len %lu", 5854 "memmove bogus src_offset %lu move len %lu len %lu",
5850 src_offset, len, dst->len); 5855 src_offset, len, dst->len);
5851 BUG_ON(1); 5856 BUG_ON(1);
5852 } 5857 }
5853 if (dst_offset + len > dst->len) { 5858 if (dst_offset + len > dst->len) {
5854 btrfs_err(dst->fs_info, 5859 btrfs_err(fs_info,
5855 "memmove bogus dst_offset %lu move len %lu len %lu", 5860 "memmove bogus dst_offset %lu move len %lu len %lu",
5856 dst_offset, len, dst->len); 5861 dst_offset, len, dst->len);
5857 BUG_ON(1); 5862 BUG_ON(1);