Skip to content

Commit

Permalink
btrfs: remove btrfs_bio::logical member
Browse files Browse the repository at this point in the history
The member btrfs_bio::logical is only initialized by two call sites:

- btrfs_repair_one_sector()
  No corresponding site to utilize it.

- btrfs_submit_direct()
  The corresponding site to utilize it is btrfs_check_read_dio_bio().

However for btrfs_check_read_dio_bio(), we can grab the file_offset from
btrfs_dio_private::file_offset directly.

Thus it turns out we don't really need that btrfs_bio::logical member at
all.

For btrfs_bio, the logical bytenr can be fetched from its
bio->bi_iter.bi_sector directly.

So let's just remove the member to save 8 bytes for structure btrfs_bio.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Qu Wenruo authored and David Sterba committed Oct 26, 2021
1 parent 47926ab commit f4f39fc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
1 change: 0 additions & 1 deletion fs/btrfs/extent_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -2673,7 +2673,6 @@ int btrfs_repair_one_sector(struct inode *inode,
}

bio_add_page(repair_bio, page, failrec->len, pgoff);
repair_bbio->logical = failrec->start;
repair_bbio->iter = repair_bio->bi_iter;

btrfs_debug(btrfs_sb(inode->i_sb),
Expand Down
17 changes: 8 additions & 9 deletions fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -8089,18 +8089,20 @@ static blk_status_t submit_dio_repair_bio(struct inode *inode, struct bio *bio,
return ret;
}

static blk_status_t btrfs_check_read_dio_bio(struct inode *inode,
static blk_status_t btrfs_check_read_dio_bio(struct btrfs_dio_private *dip,
struct btrfs_bio *bbio,
const bool uptodate)
{
struct inode *inode = dip->inode;
struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info;
const u32 sectorsize = fs_info->sectorsize;
struct extent_io_tree *failure_tree = &BTRFS_I(inode)->io_failure_tree;
struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
const bool csum = !(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM);
struct bio_vec bvec;
struct bvec_iter iter;
u64 start = bbio->logical;
const u64 orig_file_offset = dip->file_offset;
u64 start = orig_file_offset;
u32 bio_offset = 0;
blk_status_t err = BLK_STS_OK;

Expand All @@ -8122,10 +8124,10 @@ static blk_status_t btrfs_check_read_dio_bio(struct inode *inode,
} else {
int ret;

ASSERT((start - bbio->logical) < UINT_MAX);
ASSERT((start - orig_file_offset) < UINT_MAX);
ret = btrfs_repair_one_sector(inode,
&bbio->bio,
start - bbio->logical,
start - orig_file_offset,
bvec.bv_page, pgoff,
start, bbio->mirror_num,
submit_dio_repair_bio);
Expand Down Expand Up @@ -8168,10 +8170,8 @@ static void btrfs_end_dio_bio(struct bio *bio)
bio->bi_opf, bio->bi_iter.bi_sector,
bio->bi_iter.bi_size, err);

if (bio_op(bio) == REQ_OP_READ) {
err = btrfs_check_read_dio_bio(dip->inode,
btrfs_bio(bio), !err);
}
if (bio_op(bio) == REQ_OP_READ)
err = btrfs_check_read_dio_bio(dip, btrfs_bio(bio), !err);

if (err)
dip->dio_bio->bi_status = err;
Expand Down Expand Up @@ -8337,7 +8337,6 @@ static blk_qc_t btrfs_submit_direct(const struct iomap_iter *iter,
bio = btrfs_bio_clone_partial(dio_bio, clone_offset, clone_len);
bio->bi_private = dip;
bio->bi_end_io = btrfs_end_dio_bio;
btrfs_bio(bio)->logical = file_offset;

if (bio_op(bio) == REQ_OP_ZONE_APPEND) {
status = extract_ordered_extent(BTRFS_I(inode), bio,
Expand Down
1 change: 0 additions & 1 deletion fs/btrfs/volumes.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ struct btrfs_bio {

/* @device is for stripe IO submission. */
struct btrfs_device *device;
u64 logical;
u8 *csum;
u8 csum_inline[BTRFS_BIO_INLINE_CSUM_SIZE];
struct bvec_iter iter;
Expand Down

0 comments on commit f4f39fc

Please sign in to comment.