mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
btrfs: consume given iter directly instead of copying in csum_one_bio()
Avoid copying the iter twice in async case. We already have a copy csum_one_bio() can consume directly. No need to copy it again the second time. We can use this copy also in the sync case and get rid of the parameter. Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Daniel Vacek <neelx@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
45f8681478
commit
57c6777ebd
|
|
@ -797,18 +797,18 @@ int btrfs_lookup_csums_bitmap(struct btrfs_root *root, struct btrfs_path *path,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void csum_one_bio(struct btrfs_bio *bbio, struct bvec_iter *src)
|
||||
static void csum_one_bio(struct btrfs_bio *bbio)
|
||||
{
|
||||
struct btrfs_inode *inode = bbio->inode;
|
||||
struct btrfs_fs_info *fs_info = inode->root->fs_info;
|
||||
struct btrfs_ordered_sum *sums = bbio->sums;
|
||||
struct bvec_iter iter;
|
||||
const u32 blocksize = fs_info->sectorsize;
|
||||
int index = 0;
|
||||
|
||||
for (iter = *src; iter.bi_size; bio_advance_iter(&bbio->bio, &iter, blocksize)) {
|
||||
btrfs_csum_one_bio_block(fs_info, &bbio->bio, &iter,
|
||||
sums->sums + index);
|
||||
for (struct bvec_iter *iter = &bbio->csum_saved_iter;
|
||||
iter->bi_size;
|
||||
bio_advance_iter(&bbio->bio, iter, blocksize)) {
|
||||
btrfs_csum_one_bio_block(fs_info, &bbio->bio, iter, sums->sums + index);
|
||||
|
||||
index += fs_info->csum_size;
|
||||
}
|
||||
|
|
@ -820,7 +820,7 @@ static void csum_one_bio_work(struct work_struct *work)
|
|||
|
||||
ASSERT(btrfs_op(&bbio->bio) == BTRFS_MAP_WRITE);
|
||||
ASSERT(bbio->async_csum == true);
|
||||
csum_one_bio(bbio, &bbio->csum_saved_iter);
|
||||
csum_one_bio(bbio);
|
||||
complete(&bbio->csum_done);
|
||||
}
|
||||
|
||||
|
|
@ -850,13 +850,13 @@ int btrfs_csum_one_bio(struct btrfs_bio *bbio, bool async)
|
|||
bbio->sums = sums;
|
||||
btrfs_add_ordered_sum(ordered, sums);
|
||||
|
||||
bbio->csum_saved_iter = bio->bi_iter;
|
||||
if (!async) {
|
||||
csum_one_bio(bbio, &bbio->bio.bi_iter);
|
||||
csum_one_bio(bbio);
|
||||
return 0;
|
||||
}
|
||||
init_completion(&bbio->csum_done);
|
||||
bbio->async_csum = true;
|
||||
bbio->csum_saved_iter = bbio->bio.bi_iter;
|
||||
INIT_WORK(&bbio->csum_work, csum_one_bio_work);
|
||||
schedule_work(&bbio->csum_work);
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user