Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

btrfs: get rid of at_offset parameter to btrfs_lookup_bio_sums()

We can encode this in the offset parameter: -1 means use the page
offsets, anything else is a valid offset.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Omar Sandoval and committed by
David Sterba
db72e47f e62958fc

+11 -12
+2 -2
fs/btrfs/compression.c
··· 763 763 764 764 if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) { 765 765 ret = btrfs_lookup_bio_sums(inode, comp_bio, 766 - false, 0, sums); 766 + (u64)-1, sums); 767 767 BUG_ON(ret); /* -ENOMEM */ 768 768 } 769 769 ··· 791 791 BUG_ON(ret); /* -ENOMEM */ 792 792 793 793 if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) { 794 - ret = btrfs_lookup_bio_sums(inode, comp_bio, false, 0, sums); 794 + ret = btrfs_lookup_bio_sums(inode, comp_bio, (u64)-1, sums); 795 795 BUG_ON(ret); /* -ENOMEM */ 796 796 } 797 797
+1 -1
fs/btrfs/ctree.h
··· 2789 2789 int btrfs_del_csums(struct btrfs_trans_handle *trans, 2790 2790 struct btrfs_root *root, u64 bytenr, u64 len); 2791 2791 blk_status_t btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio, 2792 - bool at_offset, u64 offset, u8 *dst); 2792 + u64 offset, u8 *dst); 2793 2793 int btrfs_insert_file_extent(struct btrfs_trans_handle *trans, 2794 2794 struct btrfs_root *root, 2795 2795 u64 objectid, u64 pos,
+5 -6
fs/btrfs/file-item.c
··· 152 152 * btrfs_lookup_bio_sums - Look up checksums for a bio. 153 153 * @inode: inode that the bio is for. 154 154 * @bio: bio embedded in btrfs_io_bio. 155 - * @at_offset: If true, look up checksums for the extent at @offset. 156 - * If false, use the page offsets from the bio. 157 - * @offset: If @at_offset is true, offset in file to look up checksums for. 158 - * Ignored otherwise. 155 + * @offset: Unless (u64)-1, look up checksums for this offset in the file. 156 + * If (u64)-1, use the page offsets from the bio instead. 159 157 * @dst: Buffer of size btrfs_super_csum_size() used to return checksum. If 160 158 * NULL, the checksum is returned in btrfs_io_bio(bio)->csum instead. 161 159 * 162 160 * Return: BLK_STS_RESOURCE if allocating memory fails, BLK_STS_OK otherwise. 163 161 */ 164 162 blk_status_t btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio, 165 - bool at_offset, u64 offset, u8 *dst) 163 + u64 offset, u8 *dst) 166 164 { 167 165 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); 168 166 struct bio_vec bvec; ··· 169 171 struct btrfs_csum_item *item = NULL; 170 172 struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree; 171 173 struct btrfs_path *path; 174 + const bool page_offsets = (offset == (u64)-1); 172 175 u8 *csum; 173 176 u64 item_start_offset = 0; 174 177 u64 item_last_offset = 0; ··· 222 223 if (count) 223 224 goto next; 224 225 225 - if (!at_offset) 226 + if (page_offsets) 226 227 offset = page_offset(bvec.bv_page) + bvec.bv_offset; 227 228 count = btrfs_find_ordered_sum(inode, offset, disk_bytenr, 228 229 csum, nblocks);
+3 -3
fs/btrfs/inode.c
··· 2127 2127 bio_flags); 2128 2128 goto out; 2129 2129 } else if (!skip_sum) { 2130 - ret = btrfs_lookup_bio_sums(inode, bio, false, 0, NULL); 2130 + ret = btrfs_lookup_bio_sums(inode, bio, (u64)-1, NULL); 2131 2131 if (ret) 2132 2132 goto out; 2133 2133 } ··· 8387 8387 * contention. 8388 8388 */ 8389 8389 if (dip->logical_offset == file_offset) { 8390 - ret = btrfs_lookup_bio_sums(inode, dip->orig_bio, true, 8391 - file_offset, NULL); 8390 + ret = btrfs_lookup_bio_sums(inode, dip->orig_bio, file_offset, 8391 + NULL); 8392 8392 if (ret) 8393 8393 return ret; 8394 8394 }