mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-30 06:10:56 +00:00
btrfs: simplify sync/async submission in btrfs_submit_data_write_bio
btrfs_submit_data_write_bio special cases the reloc root because the checksums are preloaded, but only does so for the !sync case. The sync case can't happen for data relocation, but just handling it more generally significantly simplifies the logic. Reviewed-by: Nikolay Borisov <nborisov@suse.com> Tested-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
b9af128d1e
commit
82443fd55c
1 changed files with 13 additions and 16 deletions
|
@ -2664,28 +2664,25 @@ void btrfs_submit_data_write_bio(struct inode *inode, struct bio *bio, int mirro
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Rules for async/sync submit:
|
* If we need to checksum, and the I/O is not issued by fsync and
|
||||||
* a) write without checksum: sync submit
|
* friends, that is ->sync_writers != 0, defer the submission to a
|
||||||
* b) write with checksum:
|
* workqueue to parallelize it.
|
||||||
* b-1) if bio is issued by fsync: sync submit
|
*
|
||||||
* (sync_writers != 0)
|
* Csum items for reloc roots have already been cloned at this point,
|
||||||
* b-2) if root is reloc root: sync submit
|
* so they are handled as part of the no-checksum case.
|
||||||
* (only in case of buffered IO)
|
|
||||||
* b-3) otherwise: async submit
|
|
||||||
*/
|
*/
|
||||||
if (!(bi->flags & BTRFS_INODE_NODATASUM) &&
|
if (!(bi->flags & BTRFS_INODE_NODATASUM) &&
|
||||||
!test_bit(BTRFS_FS_STATE_NO_CSUMS, &fs_info->fs_state)) {
|
!test_bit(BTRFS_FS_STATE_NO_CSUMS, &fs_info->fs_state) &&
|
||||||
if (atomic_read(&bi->sync_writers)) {
|
!btrfs_is_data_reloc_root(bi->root)) {
|
||||||
ret = btrfs_csum_one_bio(bi, bio, (u64)-1, false);
|
if (!atomic_read(&bi->sync_writers)) {
|
||||||
if (ret)
|
|
||||||
goto out;
|
|
||||||
} else if (btrfs_is_data_reloc_root(bi->root)) {
|
|
||||||
; /* Csum items have already been cloned */
|
|
||||||
} else {
|
|
||||||
ret = btrfs_wq_submit_bio(inode, bio, mirror_num, 0,
|
ret = btrfs_wq_submit_bio(inode, bio, mirror_num, 0,
|
||||||
btrfs_submit_bio_start);
|
btrfs_submit_bio_start);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = btrfs_csum_one_bio(bi, bio, (u64)-1, false);
|
||||||
|
if (ret)
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
btrfs_submit_bio(fs_info, bio, mirror_num);
|
btrfs_submit_bio(fs_info, bio, mirror_num);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue