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>
This commit is contained in:
parent
e62958fce9
commit
db72e47f79
@ -763,7 +763,7 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
|
|||||||
|
|
||||||
if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) {
|
if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) {
|
||||||
ret = btrfs_lookup_bio_sums(inode, comp_bio,
|
ret = btrfs_lookup_bio_sums(inode, comp_bio,
|
||||||
false, 0, sums);
|
(u64)-1, sums);
|
||||||
BUG_ON(ret); /* -ENOMEM */
|
BUG_ON(ret); /* -ENOMEM */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -791,7 +791,7 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
|
|||||||
BUG_ON(ret); /* -ENOMEM */
|
BUG_ON(ret); /* -ENOMEM */
|
||||||
|
|
||||||
if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) {
|
if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) {
|
||||||
ret = btrfs_lookup_bio_sums(inode, comp_bio, false, 0, sums);
|
ret = btrfs_lookup_bio_sums(inode, comp_bio, (u64)-1, sums);
|
||||||
BUG_ON(ret); /* -ENOMEM */
|
BUG_ON(ret); /* -ENOMEM */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2789,7 +2789,7 @@ struct btrfs_dio_private;
|
|||||||
int btrfs_del_csums(struct btrfs_trans_handle *trans,
|
int btrfs_del_csums(struct btrfs_trans_handle *trans,
|
||||||
struct btrfs_root *root, u64 bytenr, u64 len);
|
struct btrfs_root *root, u64 bytenr, u64 len);
|
||||||
blk_status_t btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio,
|
blk_status_t btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio,
|
||||||
bool at_offset, u64 offset, u8 *dst);
|
u64 offset, u8 *dst);
|
||||||
int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
|
int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
|
||||||
struct btrfs_root *root,
|
struct btrfs_root *root,
|
||||||
u64 objectid, u64 pos,
|
u64 objectid, u64 pos,
|
||||||
|
@ -152,17 +152,15 @@ int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans,
|
|||||||
* btrfs_lookup_bio_sums - Look up checksums for a bio.
|
* btrfs_lookup_bio_sums - Look up checksums for a bio.
|
||||||
* @inode: inode that the bio is for.
|
* @inode: inode that the bio is for.
|
||||||
* @bio: bio embedded in btrfs_io_bio.
|
* @bio: bio embedded in btrfs_io_bio.
|
||||||
* @at_offset: If true, look up checksums for the extent at @offset.
|
* @offset: Unless (u64)-1, look up checksums for this offset in the file.
|
||||||
* If false, use the page offsets from the bio.
|
* If (u64)-1, use the page offsets from the bio instead.
|
||||||
* @offset: If @at_offset is true, offset in file to look up checksums for.
|
|
||||||
* Ignored otherwise.
|
|
||||||
* @dst: Buffer of size btrfs_super_csum_size() used to return checksum. If
|
* @dst: Buffer of size btrfs_super_csum_size() used to return checksum. If
|
||||||
* NULL, the checksum is returned in btrfs_io_bio(bio)->csum instead.
|
* NULL, the checksum is returned in btrfs_io_bio(bio)->csum instead.
|
||||||
*
|
*
|
||||||
* Return: BLK_STS_RESOURCE if allocating memory fails, BLK_STS_OK otherwise.
|
* Return: BLK_STS_RESOURCE if allocating memory fails, BLK_STS_OK otherwise.
|
||||||
*/
|
*/
|
||||||
blk_status_t btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio,
|
blk_status_t btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio,
|
||||||
bool at_offset, u64 offset, u8 *dst)
|
u64 offset, u8 *dst)
|
||||||
{
|
{
|
||||||
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
|
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
|
||||||
struct bio_vec bvec;
|
struct bio_vec bvec;
|
||||||
@ -171,6 +169,7 @@ blk_status_t btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio,
|
|||||||
struct btrfs_csum_item *item = NULL;
|
struct btrfs_csum_item *item = NULL;
|
||||||
struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
|
struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
|
||||||
struct btrfs_path *path;
|
struct btrfs_path *path;
|
||||||
|
const bool page_offsets = (offset == (u64)-1);
|
||||||
u8 *csum;
|
u8 *csum;
|
||||||
u64 item_start_offset = 0;
|
u64 item_start_offset = 0;
|
||||||
u64 item_last_offset = 0;
|
u64 item_last_offset = 0;
|
||||||
@ -223,7 +222,7 @@ blk_status_t btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio,
|
|||||||
if (count)
|
if (count)
|
||||||
goto next;
|
goto next;
|
||||||
|
|
||||||
if (!at_offset)
|
if (page_offsets)
|
||||||
offset = page_offset(bvec.bv_page) + bvec.bv_offset;
|
offset = page_offset(bvec.bv_page) + bvec.bv_offset;
|
||||||
count = btrfs_find_ordered_sum(inode, offset, disk_bytenr,
|
count = btrfs_find_ordered_sum(inode, offset, disk_bytenr,
|
||||||
csum, nblocks);
|
csum, nblocks);
|
||||||
|
@ -2127,7 +2127,7 @@ static blk_status_t btrfs_submit_bio_hook(struct inode *inode, struct bio *bio,
|
|||||||
bio_flags);
|
bio_flags);
|
||||||
goto out;
|
goto out;
|
||||||
} else if (!skip_sum) {
|
} else if (!skip_sum) {
|
||||||
ret = btrfs_lookup_bio_sums(inode, bio, false, 0, NULL);
|
ret = btrfs_lookup_bio_sums(inode, bio, (u64)-1, NULL);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -8387,8 +8387,8 @@ static inline blk_status_t btrfs_lookup_and_bind_dio_csum(struct inode *inode,
|
|||||||
* contention.
|
* contention.
|
||||||
*/
|
*/
|
||||||
if (dip->logical_offset == file_offset) {
|
if (dip->logical_offset == file_offset) {
|
||||||
ret = btrfs_lookup_bio_sums(inode, dip->orig_bio, true,
|
ret = btrfs_lookup_bio_sums(inode, dip->orig_bio, file_offset,
|
||||||
file_offset, NULL);
|
NULL);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user