Skip to content

Commit

Permalink
btrfs: rename the bytenr field in struct btrfs_ordered_sum to logical
Browse files Browse the repository at this point in the history
btrfs_ordered_sum::bytendr stores a logical address.  Make that clear by
renaming it to ->logical.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Christoph Hellwig authored and kdave committed Jun 19, 2023
1 parent 6e4b247 commit 5cfe76f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions fs/btrfs/file-item.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ int btrfs_lookup_csums_list(struct btrfs_root *root, u64 start, u64 end,
goto fail;
}

sums->bytenr = start;
sums->logical = start;
sums->len = size;

offset = bytes_to_csum_size(fs_info, start - key.offset);
Expand Down Expand Up @@ -749,7 +749,7 @@ blk_status_t btrfs_csum_one_bio(struct btrfs_bio *bbio)
sums->len = bio->bi_iter.bi_size;
INIT_LIST_HEAD(&sums->list);

sums->bytenr = bio->bi_iter.bi_sector << SECTOR_SHIFT;
sums->logical = bio->bi_iter.bi_sector << SECTOR_SHIFT;
index = 0;

shash->tfm = fs_info->csum_shash;
Expand Down Expand Up @@ -799,7 +799,7 @@ blk_status_t btrfs_csum_one_bio(struct btrfs_bio *bbio)
ordered = btrfs_lookup_ordered_extent(inode,
offset);
ASSERT(ordered); /* Logic error */
sums->bytenr = (bio->bi_iter.bi_sector << SECTOR_SHIFT)
sums->logical = (bio->bi_iter.bi_sector << SECTOR_SHIFT)
+ total_bytes;
index = 0;
}
Expand Down Expand Up @@ -1086,7 +1086,7 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans,
again:
next_offset = (u64)-1;
found_next = 0;
bytenr = sums->bytenr + total_bytes;
bytenr = sums->logical + total_bytes;
file_key.objectid = BTRFS_EXTENT_CSUM_OBJECTID;
file_key.offset = bytenr;
file_key.type = BTRFS_EXTENT_CSUM_KEY;
Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2850,7 +2850,7 @@ static int add_pending_csums(struct btrfs_trans_handle *trans,
trans->adding_csums = true;
if (!csum_root)
csum_root = btrfs_csum_root(trans->fs_info,
sum->bytenr);
sum->logical);
ret = btrfs_csum_file_blocks(trans, csum_root, sum);
trans->adding_csums = false;
if (ret)
Expand Down
8 changes: 4 additions & 4 deletions fs/btrfs/ordered-data.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ struct btrfs_ordered_inode_tree {
};

struct btrfs_ordered_sum {
/* bytenr is the start of this extent on disk */
u64 bytenr;

/*
* this is the length in bytes covered by the sums array below.
* Logical start address and length for of the blocks covered by
* the sums array.
*/
u64 logical;
u32 len;

struct list_head list;
/* last field is a variable length array of csums */
u8 sums[];
Expand Down
4 changes: 2 additions & 2 deletions fs/btrfs/relocation.c
Original file line number Diff line number Diff line change
Expand Up @@ -4379,8 +4379,8 @@ int btrfs_reloc_clone_csums(struct btrfs_inode *inode, u64 file_pos, u64 len)
* disk_len vs real len like with real inodes since it's all
* disk length.
*/
new_bytenr = ordered->disk_bytenr + sums->bytenr - disk_bytenr;
sums->bytenr = new_bytenr;
new_bytenr = ordered->disk_bytenr + sums->logical - disk_bytenr;
sums->logical = new_bytenr;

btrfs_add_ordered_sum(ordered, sums);
}
Expand Down
12 changes: 6 additions & 6 deletions fs/btrfs/tree-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -859,10 +859,10 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
struct btrfs_ordered_sum,
list);
csum_root = btrfs_csum_root(fs_info,
sums->bytenr);
sums->logical);
if (!ret)
ret = btrfs_del_csums(trans, csum_root,
sums->bytenr,
sums->logical,
sums->len);
if (!ret)
ret = btrfs_csum_file_blocks(trans,
Expand Down Expand Up @@ -4221,7 +4221,7 @@ static int log_csums(struct btrfs_trans_handle *trans,
struct btrfs_root *log_root,
struct btrfs_ordered_sum *sums)
{
const u64 lock_end = sums->bytenr + sums->len - 1;
const u64 lock_end = sums->logical + sums->len - 1;
struct extent_state *cached_state = NULL;
int ret;

Expand All @@ -4239,7 +4239,7 @@ static int log_csums(struct btrfs_trans_handle *trans,
* file which happens to refer to the same extent as well. Such races
* can leave checksum items in the log with overlapping ranges.
*/
ret = lock_extent(&log_root->log_csum_range, sums->bytenr, lock_end,
ret = lock_extent(&log_root->log_csum_range, sums->logical, lock_end,
&cached_state);
if (ret)
return ret;
Expand All @@ -4252,11 +4252,11 @@ static int log_csums(struct btrfs_trans_handle *trans,
* some checksums missing in the fs/subvolume tree. So just delete (or
* trim and adjust) any existing csum items in the log for this range.
*/
ret = btrfs_del_csums(trans, log_root, sums->bytenr, sums->len);
ret = btrfs_del_csums(trans, log_root, sums->logical, sums->len);
if (!ret)
ret = btrfs_csum_file_blocks(trans, log_root, sums);

unlock_extent(&log_root->log_csum_range, sums->bytenr, lock_end,
unlock_extent(&log_root->log_csum_range, sums->logical, lock_end,
&cached_state);

return ret;
Expand Down
4 changes: 2 additions & 2 deletions fs/btrfs/zoned.c
Original file line number Diff line number Diff line change
Expand Up @@ -1711,9 +1711,9 @@ void btrfs_rewrite_logical_zoned(struct btrfs_ordered_extent *ordered)

list_for_each_entry(sum, &ordered->list, list) {
if (logical < orig_logical)
sum->bytenr -= orig_logical - logical;
sum->logical -= orig_logical - logical;
else
sum->bytenr += logical - orig_logical;
sum->logical += logical - orig_logical;
}
}

Expand Down

0 comments on commit 5cfe76f

Please sign in to comment.