btrfs: Move skip checksum check from btrfs_submit_direct to __btrfs_submit_dio_bio
Currently the code checks whether we should do data checksumming in btrfs_submit_direct and the boolean result of this check is passed to btrfs_submit_direct_hook, in turn passing it to __btrfs_submit_dio_bio which actually consumes it. The last function actually has all the necessary context to figure out whether to skip the check or not, so let's move the check closer to where it's being consumed. No functional changes. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Chris Mason <clm@fb.com> Signed-off-by: Chris Mason <clm@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
6399fb5a0b
commit
e6961cac73
|
@ -8514,8 +8514,7 @@ static inline blk_status_t btrfs_lookup_and_bind_dio_csum(struct inode *inode,
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode,
|
static inline int __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode,
|
||||||
u64 file_offset, int skip_sum,
|
u64 file_offset, int async_submit)
|
||||||
int async_submit)
|
|
||||||
{
|
{
|
||||||
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
|
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
|
||||||
struct btrfs_dio_private *dip = bio->bi_private;
|
struct btrfs_dio_private *dip = bio->bi_private;
|
||||||
|
@ -8533,7 +8532,7 @@ static inline int __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode,
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skip_sum)
|
if (BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)
|
||||||
goto map;
|
goto map;
|
||||||
|
|
||||||
if (write && async_submit) {
|
if (write && async_submit) {
|
||||||
|
@ -8563,8 +8562,7 @@ err:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip,
|
static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip)
|
||||||
int skip_sum)
|
|
||||||
{
|
{
|
||||||
struct inode *inode = dip->inode;
|
struct inode *inode = dip->inode;
|
||||||
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
|
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
|
||||||
|
@ -8627,7 +8625,7 @@ static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip,
|
||||||
*/
|
*/
|
||||||
atomic_inc(&dip->pending_bios);
|
atomic_inc(&dip->pending_bios);
|
||||||
|
|
||||||
ret = __btrfs_submit_dio_bio(bio, inode, file_offset, skip_sum,
|
ret = __btrfs_submit_dio_bio(bio, inode, file_offset,
|
||||||
async_submit);
|
async_submit);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
bio_put(bio);
|
bio_put(bio);
|
||||||
|
@ -8647,8 +8645,7 @@ static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip,
|
||||||
} while (submit_len > 0);
|
} while (submit_len > 0);
|
||||||
|
|
||||||
submit:
|
submit:
|
||||||
ret = __btrfs_submit_dio_bio(bio, inode, file_offset, skip_sum,
|
ret = __btrfs_submit_dio_bio(bio, inode, file_offset, async_submit);
|
||||||
async_submit);
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -8673,12 +8670,9 @@ static void btrfs_submit_direct(struct bio *dio_bio, struct inode *inode,
|
||||||
struct btrfs_dio_private *dip = NULL;
|
struct btrfs_dio_private *dip = NULL;
|
||||||
struct bio *bio = NULL;
|
struct bio *bio = NULL;
|
||||||
struct btrfs_io_bio *io_bio;
|
struct btrfs_io_bio *io_bio;
|
||||||
int skip_sum;
|
|
||||||
bool write = (bio_op(dio_bio) == REQ_OP_WRITE);
|
bool write = (bio_op(dio_bio) == REQ_OP_WRITE);
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;
|
|
||||||
|
|
||||||
bio = btrfs_bio_clone(dio_bio);
|
bio = btrfs_bio_clone(dio_bio);
|
||||||
|
|
||||||
dip = kzalloc(sizeof(*dip), GFP_NOFS);
|
dip = kzalloc(sizeof(*dip), GFP_NOFS);
|
||||||
|
@ -8721,7 +8715,7 @@ static void btrfs_submit_direct(struct bio *dio_bio, struct inode *inode,
|
||||||
dio_data->unsubmitted_oe_range_end;
|
dio_data->unsubmitted_oe_range_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = btrfs_submit_direct_hook(dip, skip_sum);
|
ret = btrfs_submit_direct_hook(dip);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue