aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 9d1b71060813..0e410478ad27 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -852,11 +852,16 @@ static int __btree_submit_bio_done(struct inode *inode, int rw, struct bio *bio,
852 int mirror_num, unsigned long bio_flags, 852 int mirror_num, unsigned long bio_flags,
853 u64 bio_offset) 853 u64 bio_offset)
854{ 854{
855 int ret;
856
855 /* 857 /*
856 * when we're called for a write, we're already in the async 858 * when we're called for a write, we're already in the async
857 * submission context. Just jump into btrfs_map_bio 859 * submission context. Just jump into btrfs_map_bio
858 */ 860 */
859 return btrfs_map_bio(BTRFS_I(inode)->root, rw, bio, mirror_num, 1); 861 ret = btrfs_map_bio(BTRFS_I(inode)->root, rw, bio, mirror_num, 1);
862 if (ret)
863 bio_endio(bio, ret);
864 return ret;
860} 865}
861 866
862static int check_async_write(struct inode *inode, unsigned long bio_flags) 867static int check_async_write(struct inode *inode, unsigned long bio_flags)
@@ -878,7 +883,6 @@ static int btree_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
878 int ret; 883 int ret;
879 884
880 if (!(rw & REQ_WRITE)) { 885 if (!(rw & REQ_WRITE)) {
881
882 /* 886 /*
883 * called for a read, do the setup so that checksum validation 887 * called for a read, do the setup so that checksum validation
884 * can happen in the async kernel threads 888 * can happen in the async kernel threads
@@ -886,26 +890,32 @@ static int btree_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
886 ret = btrfs_bio_wq_end_io(BTRFS_I(inode)->root->fs_info, 890 ret = btrfs_bio_wq_end_io(BTRFS_I(inode)->root->fs_info,
887 bio, 1); 891 bio, 1);
888 if (ret) 892 if (ret)
889 return ret; 893 goto out_w_error;
890 return btrfs_map_bio(BTRFS_I(inode)->root, rw, bio, 894 ret = btrfs_map_bio(BTRFS_I(inode)->root, rw, bio,
891 mirror_num, 0); 895 mirror_num, 0);
892 } else if (!async) { 896 } else if (!async) {
893 ret = btree_csum_one_bio(bio); 897 ret = btree_csum_one_bio(bio);
894 if (ret) 898 if (ret)
895 return ret; 899 goto out_w_error;
896 return btrfs_map_bio(BTRFS_I(inode)->root, rw, bio, 900 ret = btrfs_map_bio(BTRFS_I(inode)->root, rw, bio,
897 mirror_num, 0); 901 mirror_num, 0);
902 } else {
903 /*
904 * kthread helpers are used to submit writes so that
905 * checksumming can happen in parallel across all CPUs
906 */
907 ret = btrfs_wq_submit_bio(BTRFS_I(inode)->root->fs_info,
908 inode, rw, bio, mirror_num, 0,
909 bio_offset,
910 __btree_submit_bio_start,
911 __btree_submit_bio_done);
898 } 912 }
899 913
900 /* 914 if (ret) {
901 * kthread helpers are used to submit writes so that checksumming 915out_w_error:
902 * can happen in parallel across all CPUs 916 bio_endio(bio, ret);
903 */ 917 }
904 return btrfs_wq_submit_bio(BTRFS_I(inode)->root->fs_info, 918 return ret;
905 inode, rw, bio, mirror_num, 0,
906 bio_offset,
907 __btree_submit_bio_start,
908 __btree_submit_bio_done);
909} 919}
910 920
911#ifdef CONFIG_MIGRATION 921#ifdef CONFIG_MIGRATION