Skip to content

Commit c3a3b19

Browse files
adam900710kdave
authored andcommitted
btrfs: rename struct btrfs_io_bio to btrfs_bio
Previously we had "struct btrfs_bio", which records IO context for mirrored IO and RAID56, and "strcut btrfs_io_bio", which records extra btrfs specific info for logical bytenr bio. With "btrfs_bio" renamed to "btrfs_io_context", we are safe to rename "btrfs_io_bio" to "btrfs_bio" which is a more suitable name now. The struct btrfs_bio changes meaning by this commit. There was a suggested name like btrfs_logical_bio but it's a bit long and we'd prefer to use a shorter name. This could be a concern for backports to older kernels where the different meaning could possibly cause confusion or bugs. Comparing the new and old structures, there's no overlap among the struct members so a build would break in case of incorrect backport. We haven't had many backports to bio code anyway so this is more of a theoretical cause of bugs and a matter of precaution but we'll need to keep the semantic change in mind. Signed-off-by: Qu Wenruo <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent cd8e0cc commit c3a3b19

File tree

13 files changed

+107
-106
lines changed

13 files changed

+107
-106
lines changed

fs/btrfs/check-integrity.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,7 @@ static int btrfsic_read_block(struct btrfsic_state *state,
15611561
struct bio *bio;
15621562
unsigned int j;
15631563

1564-
bio = btrfs_io_bio_alloc(num_pages - i);
1564+
bio = btrfs_bio_alloc(num_pages - i);
15651565
bio_set_dev(bio, block_ctx->dev->bdev);
15661566
bio->bi_iter.bi_sector = dev_bytenr >> 9;
15671567
bio->bi_opf = REQ_OP_READ;

fs/btrfs/compression.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ static int check_compressed_csum(struct btrfs_inode *inode, struct bio *bio,
179179
if (memcmp(&csum, cb_sum, csum_size) != 0) {
180180
btrfs_print_data_csum_error(inode, disk_start,
181181
csum, cb_sum, cb->mirror_num);
182-
if (btrfs_io_bio(bio)->device)
182+
if (btrfs_bio(bio)->device)
183183
btrfs_dev_stat_inc_and_print(
184-
btrfs_io_bio(bio)->device,
184+
btrfs_bio(bio)->device,
185185
BTRFS_DEV_STAT_CORRUPTION_ERRS);
186186
return -EIO;
187187
}
@@ -208,7 +208,7 @@ static void end_compressed_bio_read(struct bio *bio)
208208
struct inode *inode;
209209
struct page *page;
210210
unsigned int index;
211-
unsigned int mirror = btrfs_io_bio(bio)->mirror_num;
211+
unsigned int mirror = btrfs_bio(bio)->mirror_num;
212212
int ret = 0;
213213

214214
if (bio->bi_status)
@@ -224,7 +224,7 @@ static void end_compressed_bio_read(struct bio *bio)
224224
* Record the correct mirror_num in cb->orig_bio so that
225225
* read-repair can work properly.
226226
*/
227-
btrfs_io_bio(cb->orig_bio)->mirror_num = mirror;
227+
btrfs_bio(cb->orig_bio)->mirror_num = mirror;
228228
cb->mirror_num = mirror;
229229

230230
/*
@@ -418,7 +418,7 @@ blk_status_t btrfs_submit_compressed_write(struct btrfs_inode *inode, u64 start,
418418
cb->orig_bio = NULL;
419419
cb->nr_pages = nr_pages;
420420

421-
bio = btrfs_io_bio_alloc(BIO_MAX_VECS);
421+
bio = btrfs_bio_alloc(BIO_MAX_VECS);
422422
bio->bi_iter.bi_sector = first_byte >> SECTOR_SHIFT;
423423
bio->bi_opf = bio_op | write_flags;
424424
bio->bi_private = cb;
@@ -491,7 +491,7 @@ blk_status_t btrfs_submit_compressed_write(struct btrfs_inode *inode, u64 start,
491491
bio_endio(bio);
492492
}
493493

494-
bio = btrfs_io_bio_alloc(BIO_MAX_VECS);
494+
bio = btrfs_bio_alloc(BIO_MAX_VECS);
495495
bio->bi_iter.bi_sector = first_byte >> SECTOR_SHIFT;
496496
bio->bi_opf = bio_op | write_flags;
497497
bio->bi_private = cb;
@@ -750,7 +750,7 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
750750
/* include any pages we added in add_ra-bio_pages */
751751
cb->len = bio->bi_iter.bi_size;
752752

753-
comp_bio = btrfs_io_bio_alloc(BIO_MAX_VECS);
753+
comp_bio = btrfs_bio_alloc(BIO_MAX_VECS);
754754
comp_bio->bi_iter.bi_sector = cur_disk_byte >> SECTOR_SHIFT;
755755
comp_bio->bi_opf = REQ_OP_READ;
756756
comp_bio->bi_private = cb;
@@ -809,7 +809,7 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
809809
bio_endio(comp_bio);
810810
}
811811

812-
comp_bio = btrfs_io_bio_alloc(BIO_MAX_VECS);
812+
comp_bio = btrfs_bio_alloc(BIO_MAX_VECS);
813813
comp_bio->bi_iter.bi_sector = cur_disk_byte >> SECTOR_SHIFT;
814814
comp_bio->bi_opf = REQ_OP_READ;
815815
comp_bio->bi_private = cb;

fs/btrfs/ctree.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ extern struct kmem_cache *btrfs_free_space_cachep;
4848
extern struct kmem_cache *btrfs_free_space_bitmap_cachep;
4949
struct btrfs_ordered_sum;
5050
struct btrfs_ref;
51+
struct btrfs_bio;
5152

5253
#define BTRFS_MAGIC 0x4D5F53665248425FULL /* ascii _BHRfS_M, no null */
5354

@@ -3140,8 +3141,9 @@ u64 btrfs_file_extent_end(const struct btrfs_path *path);
31403141
/* inode.c */
31413142
blk_status_t btrfs_submit_data_bio(struct inode *inode, struct bio *bio,
31423143
int mirror_num, unsigned long bio_flags);
3143-
unsigned int btrfs_verify_data_csum(struct btrfs_io_bio *io_bio, u32 bio_offset,
3144-
struct page *page, u64 start, u64 end);
3144+
unsigned int btrfs_verify_data_csum(struct btrfs_bio *bbio,
3145+
u32 bio_offset, struct page *page,
3146+
u64 start, u64 end);
31453147
struct extent_map *btrfs_get_extent_fiemap(struct btrfs_inode *inode,
31463148
u64 start, u64 len);
31473149
noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,

fs/btrfs/disk-io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ static int validate_subpage_buffer(struct page *page, u64 start, u64 end,
683683
return ret;
684684
}
685685

686-
int btrfs_validate_metadata_buffer(struct btrfs_io_bio *io_bio,
686+
int btrfs_validate_metadata_buffer(struct btrfs_bio *bbio,
687687
struct page *page, u64 start, u64 end,
688688
int mirror)
689689
{

fs/btrfs/disk-io.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void btrfs_btree_balance_dirty(struct btrfs_fs_info *fs_info);
8181
void btrfs_btree_balance_dirty_nodelay(struct btrfs_fs_info *fs_info);
8282
void btrfs_drop_and_free_fs_root(struct btrfs_fs_info *fs_info,
8383
struct btrfs_root *root);
84-
int btrfs_validate_metadata_buffer(struct btrfs_io_bio *io_bio,
84+
int btrfs_validate_metadata_buffer(struct btrfs_bio *bbio,
8585
struct page *page, u64 start, u64 end,
8686
int mirror);
8787
blk_status_t btrfs_submit_metadata_bio(struct inode *inode, struct bio *bio,

fs/btrfs/extent_io.c

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ int __init extent_io_init(void)
241241
return -ENOMEM;
242242

243243
if (bioset_init(&btrfs_bioset, BIO_POOL_SIZE,
244-
offsetof(struct btrfs_io_bio, bio),
244+
offsetof(struct btrfs_bio, bio),
245245
BIOSET_NEED_BVECS))
246246
goto free_buffer_cache;
247247

@@ -2299,7 +2299,7 @@ static int repair_io_failure(struct btrfs_fs_info *fs_info, u64 ino, u64 start,
22992299
if (btrfs_is_zoned(fs_info))
23002300
return btrfs_repair_one_zone(fs_info, logical);
23012301

2302-
bio = btrfs_io_bio_alloc(1);
2302+
bio = btrfs_bio_alloc(1);
23032303
bio->bi_iter.bi_size = 0;
23042304
map_length = length;
23052305

@@ -2618,10 +2618,10 @@ int btrfs_repair_one_sector(struct inode *inode,
26182618
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
26192619
struct extent_io_tree *tree = &BTRFS_I(inode)->io_tree;
26202620
struct extent_io_tree *failure_tree = &BTRFS_I(inode)->io_failure_tree;
2621-
struct btrfs_io_bio *failed_io_bio = btrfs_io_bio(failed_bio);
2621+
struct btrfs_bio *failed_bbio = btrfs_bio(failed_bio);
26222622
const int icsum = bio_offset >> fs_info->sectorsize_bits;
26232623
struct bio *repair_bio;
2624-
struct btrfs_io_bio *repair_io_bio;
2624+
struct btrfs_bio *repair_bbio;
26252625
blk_status_t status;
26262626

26272627
btrfs_debug(fs_info,
@@ -2639,24 +2639,24 @@ int btrfs_repair_one_sector(struct inode *inode,
26392639
return -EIO;
26402640
}
26412641

2642-
repair_bio = btrfs_io_bio_alloc(1);
2643-
repair_io_bio = btrfs_io_bio(repair_bio);
2642+
repair_bio = btrfs_bio_alloc(1);
2643+
repair_bbio = btrfs_bio(repair_bio);
26442644
repair_bio->bi_opf = REQ_OP_READ;
26452645
repair_bio->bi_end_io = failed_bio->bi_end_io;
26462646
repair_bio->bi_iter.bi_sector = failrec->logical >> 9;
26472647
repair_bio->bi_private = failed_bio->bi_private;
26482648

2649-
if (failed_io_bio->csum) {
2649+
if (failed_bbio->csum) {
26502650
const u32 csum_size = fs_info->csum_size;
26512651

2652-
repair_io_bio->csum = repair_io_bio->csum_inline;
2653-
memcpy(repair_io_bio->csum,
2654-
failed_io_bio->csum + csum_size * icsum, csum_size);
2652+
repair_bbio->csum = repair_bbio->csum_inline;
2653+
memcpy(repair_bbio->csum,
2654+
failed_bbio->csum + csum_size * icsum, csum_size);
26552655
}
26562656

26572657
bio_add_page(repair_bio, page, failrec->len, pgoff);
2658-
repair_io_bio->logical = failrec->start;
2659-
repair_io_bio->iter = repair_bio->bi_iter;
2658+
repair_bbio->logical = failrec->start;
2659+
repair_bbio->iter = repair_bio->bi_iter;
26602660

26612661
btrfs_debug(btrfs_sb(inode->i_sb),
26622662
"repair read error: submitting new read to mirror %d",
@@ -2976,7 +2976,7 @@ static struct extent_buffer *find_extent_buffer_readpage(
29762976
static void end_bio_extent_readpage(struct bio *bio)
29772977
{
29782978
struct bio_vec *bvec;
2979-
struct btrfs_io_bio *io_bio = btrfs_io_bio(bio);
2979+
struct btrfs_bio *bbio = btrfs_bio(bio);
29802980
struct extent_io_tree *tree, *failure_tree;
29812981
struct processed_extent processed = { 0 };
29822982
/*
@@ -3003,7 +3003,7 @@ static void end_bio_extent_readpage(struct bio *bio)
30033003
btrfs_debug(fs_info,
30043004
"end_bio_extent_readpage: bi_sector=%llu, err=%d, mirror=%u",
30053005
bio->bi_iter.bi_sector, bio->bi_status,
3006-
io_bio->mirror_num);
3006+
bbio->mirror_num);
30073007
tree = &BTRFS_I(inode)->io_tree;
30083008
failure_tree = &BTRFS_I(inode)->io_failure_tree;
30093009

@@ -3028,14 +3028,14 @@ static void end_bio_extent_readpage(struct bio *bio)
30283028
end = start + bvec->bv_len - 1;
30293029
len = bvec->bv_len;
30303030

3031-
mirror = io_bio->mirror_num;
3031+
mirror = bbio->mirror_num;
30323032
if (likely(uptodate)) {
30333033
if (is_data_inode(inode)) {
3034-
error_bitmap = btrfs_verify_data_csum(io_bio,
3034+
error_bitmap = btrfs_verify_data_csum(bbio,
30353035
bio_offset, page, start, end);
30363036
ret = error_bitmap;
30373037
} else {
3038-
ret = btrfs_validate_metadata_buffer(io_bio,
3038+
ret = btrfs_validate_metadata_buffer(bbio,
30393039
page, start, end, mirror);
30403040
}
30413041
if (ret)
@@ -3106,7 +3106,7 @@ static void end_bio_extent_readpage(struct bio *bio)
31063106
}
31073107
/* Release the last extent */
31083108
endio_readpage_release_extent(&processed, NULL, 0, 0, false);
3109-
btrfs_io_bio_free_csum(io_bio);
3109+
btrfs_bio_free_csum(bbio);
31103110
bio_put(bio);
31113111
}
31123112

@@ -3115,55 +3115,55 @@ static void end_bio_extent_readpage(struct bio *bio)
31153115
* new bio by bio_alloc_bioset as it does not initialize the bytes outside of
31163116
* 'bio' because use of __GFP_ZERO is not supported.
31173117
*/
3118-
static inline void btrfs_io_bio_init(struct btrfs_io_bio *btrfs_bio)
3118+
static inline void btrfs_bio_init(struct btrfs_bio *bbio)
31193119
{
3120-
memset(btrfs_bio, 0, offsetof(struct btrfs_io_bio, bio));
3120+
memset(bbio, 0, offsetof(struct btrfs_bio, bio));
31213121
}
31223122

31233123
/*
31243124
* Allocate a btrfs_io_bio, with @nr_iovecs as maximum number of iovecs.
31253125
*
31263126
* The bio allocation is backed by bioset and does not fail.
31273127
*/
3128-
struct bio *btrfs_io_bio_alloc(unsigned int nr_iovecs)
3128+
struct bio *btrfs_bio_alloc(unsigned int nr_iovecs)
31293129
{
31303130
struct bio *bio;
31313131

31323132
ASSERT(0 < nr_iovecs && nr_iovecs <= BIO_MAX_VECS);
31333133
bio = bio_alloc_bioset(GFP_NOFS, nr_iovecs, &btrfs_bioset);
3134-
btrfs_io_bio_init(btrfs_io_bio(bio));
3134+
btrfs_bio_init(btrfs_bio(bio));
31353135
return bio;
31363136
}
31373137

31383138
struct bio *btrfs_bio_clone(struct bio *bio)
31393139
{
3140-
struct btrfs_io_bio *btrfs_bio;
3140+
struct btrfs_bio *bbio;
31413141
struct bio *new;
31423142

31433143
/* Bio allocation backed by a bioset does not fail */
31443144
new = bio_clone_fast(bio, GFP_NOFS, &btrfs_bioset);
3145-
btrfs_bio = btrfs_io_bio(new);
3146-
btrfs_io_bio_init(btrfs_bio);
3147-
btrfs_bio->iter = bio->bi_iter;
3145+
bbio = btrfs_bio(new);
3146+
btrfs_bio_init(bbio);
3147+
bbio->iter = bio->bi_iter;
31483148
return new;
31493149
}
31503150

31513151
struct bio *btrfs_bio_clone_partial(struct bio *orig, u64 offset, u64 size)
31523152
{
31533153
struct bio *bio;
3154-
struct btrfs_io_bio *btrfs_bio;
3154+
struct btrfs_bio *bbio;
31553155

31563156
ASSERT(offset <= UINT_MAX && size <= UINT_MAX);
31573157

31583158
/* this will never fail when it's backed by a bioset */
31593159
bio = bio_clone_fast(orig, GFP_NOFS, &btrfs_bioset);
31603160
ASSERT(bio);
31613161

3162-
btrfs_bio = btrfs_io_bio(bio);
3163-
btrfs_io_bio_init(btrfs_bio);
3162+
bbio = btrfs_bio(bio);
3163+
btrfs_bio_init(bbio);
31643164

31653165
bio_trim(bio, offset >> 9, size >> 9);
3166-
btrfs_bio->iter = bio->bi_iter;
3166+
bbio->iter = bio->bi_iter;
31673167
return bio;
31683168
}
31693169

@@ -3297,7 +3297,7 @@ static int alloc_new_bio(struct btrfs_inode *inode,
32973297
struct bio *bio;
32983298
int ret;
32993299

3300-
bio = btrfs_io_bio_alloc(BIO_MAX_VECS);
3300+
bio = btrfs_bio_alloc(BIO_MAX_VECS);
33013301
/*
33023302
* For compressed page range, its disk_bytenr is always @disk_bytenr
33033303
* passed in, no matter if we have added any range into previous bio.
@@ -3332,7 +3332,7 @@ static int alloc_new_bio(struct btrfs_inode *inode,
33323332
goto error;
33333333
}
33343334

3335-
btrfs_io_bio(bio)->device = device;
3335+
btrfs_bio(bio)->device = device;
33363336
}
33373337
return 0;
33383338
error:

fs/btrfs/extent_io.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ void extent_range_redirty_for_io(struct inode *inode, u64 start, u64 end);
278278
void extent_clear_unlock_delalloc(struct btrfs_inode *inode, u64 start, u64 end,
279279
struct page *locked_page,
280280
u32 bits_to_clear, unsigned long page_ops);
281-
struct bio *btrfs_io_bio_alloc(unsigned int nr_iovecs);
281+
struct bio *btrfs_bio_alloc(unsigned int nr_iovecs);
282282
struct bio *btrfs_bio_clone(struct bio *bio);
283283
struct bio *btrfs_bio_clone_partial(struct bio *orig, u64 offset, u64 size);
284284

fs/btrfs/file-item.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ static int search_file_offset_in_bio(struct bio *bio, struct inode *inode,
358358
* @dst: Buffer of size nblocks * btrfs_super_csum_size() used to return
359359
* checksum (nblocks = bio->bi_iter.bi_size / fs_info->sectorsize). If
360360
* NULL, the checksum buffer is allocated and returned in
361-
* btrfs_io_bio(bio)->csum instead.
361+
* btrfs_bio(bio)->csum instead.
362362
*
363363
* Return: BLK_STS_RESOURCE if allocating memory fails, BLK_STS_OK otherwise.
364364
*/
@@ -397,19 +397,18 @@ blk_status_t btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio, u8 *dst
397397
return BLK_STS_RESOURCE;
398398

399399
if (!dst) {
400-
struct btrfs_io_bio *btrfs_bio = btrfs_io_bio(bio);
400+
struct btrfs_bio *bbio = btrfs_bio(bio);
401401

402402
if (nblocks * csum_size > BTRFS_BIO_INLINE_CSUM_SIZE) {
403-
btrfs_bio->csum = kmalloc_array(nblocks, csum_size,
404-
GFP_NOFS);
405-
if (!btrfs_bio->csum) {
403+
bbio->csum = kmalloc_array(nblocks, csum_size, GFP_NOFS);
404+
if (!bbio->csum) {
406405
btrfs_free_path(path);
407406
return BLK_STS_RESOURCE;
408407
}
409408
} else {
410-
btrfs_bio->csum = btrfs_bio->csum_inline;
409+
bbio->csum = bbio->csum_inline;
411410
}
412-
csum = btrfs_bio->csum;
411+
csum = bbio->csum;
413412
} else {
414413
csum = dst;
415414
}

0 commit comments

Comments
 (0)