Skip to content

Commit

Permalink
btrfs: rename btrfs_dio_private::logical_offset to file_offset
Browse files Browse the repository at this point in the history
The naming of "logical_offset" can be confused with logical bytenr of
the dio range.

In fact it's file offset, and the naming "file_offset" is already widely
used in all other sites.

Just do the rename to avoid confusion.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@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 3dcfbcc commit 47926ab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
7 changes: 6 additions & 1 deletion fs/btrfs/btrfs_inode.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,12 @@ static inline bool btrfs_inode_in_log(struct btrfs_inode *inode, u64 generation)

struct btrfs_dio_private {
struct inode *inode;
u64 logical_offset;

/*
* Since DIO can use anonymous page, we cannot use page_offset() to
* grab the file offset, thus need a dedicated member for file offset.
*/
u64 file_offset;
u64 disk_bytenr;
/* Used for bio::bi_size */
u32 bytes;
Expand Down
12 changes: 6 additions & 6 deletions fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -8055,13 +8055,13 @@ static void btrfs_dio_private_put(struct btrfs_dio_private *dip)

if (btrfs_op(dip->dio_bio) == BTRFS_MAP_WRITE) {
__endio_write_update_ordered(BTRFS_I(dip->inode),
dip->logical_offset,
dip->file_offset,
dip->bytes,
!dip->dio_bio->bi_status);
} else {
unlock_extent(&BTRFS_I(dip->inode)->io_tree,
dip->logical_offset,
dip->logical_offset + dip->bytes - 1);
dip->file_offset,
dip->file_offset + dip->bytes - 1);
}

bio_endio(dip->dio_bio);
Expand Down Expand Up @@ -8176,7 +8176,7 @@ static void btrfs_end_dio_bio(struct bio *bio)
if (err)
dip->dio_bio->bi_status = err;

btrfs_record_physical_zoned(dip->inode, dip->logical_offset, bio);
btrfs_record_physical_zoned(dip->inode, dip->file_offset, bio);

bio_put(bio);
btrfs_dio_private_put(dip);
Expand Down Expand Up @@ -8218,7 +8218,7 @@ static inline blk_status_t btrfs_submit_dio_bio(struct bio *bio,
} else {
u64 csum_offset;

csum_offset = file_offset - dip->logical_offset;
csum_offset = file_offset - dip->file_offset;
csum_offset >>= fs_info->sectorsize_bits;
csum_offset *= fs_info->csum_size;
btrfs_bio(bio)->csum = dip->csums + csum_offset;
Expand Down Expand Up @@ -8256,7 +8256,7 @@ static struct btrfs_dio_private *btrfs_create_dio_private(struct bio *dio_bio,
return NULL;

dip->inode = inode;
dip->logical_offset = file_offset;
dip->file_offset = file_offset;
dip->bytes = dio_bio->bi_iter.bi_size;
dip->disk_bytenr = dio_bio->bi_iter.bi_sector << 9;
dip->dio_bio = dio_bio;
Expand Down

0 comments on commit 47926ab

Please sign in to comment.