diff options
author | David Sterba <dsterba@suse.com> | 2018-07-18 11:36:24 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2018-08-06 07:12:55 -0400 |
commit | e288c080dddd1fdc3b7e0165cebd7af51a52d016 (patch) | |
tree | 98f54cb59e09ff05f7205e1ed732687829397a08 | |
parent | d7cbfafc4bc37ed21351cdedbc6f9d979545dbf3 (diff) |
btrfs: unify end_io callbacks of async_submit_bio
The end_io callbacks passed to btrfs_wq_submit_bio
(btrfs_submit_bio_done and btree_submit_bio_done) are effectively the
same code, there's no point to do the indirection. Export
btrfs_submit_bio_done and call it directly.
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/disk-io.c | 28 | ||||
-rw-r--r-- | fs/btrfs/disk-io.h | 5 | ||||
-rw-r--r-- | fs/btrfs/extent_io.h | 3 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 8 |
4 files changed, 9 insertions, 35 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index d82df15af89c..03a7ed448f38 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -108,7 +108,6 @@ struct async_submit_bio { | |||
108 | void *private_data; | 108 | void *private_data; |
109 | struct bio *bio; | 109 | struct bio *bio; |
110 | extent_submit_bio_start_t *submit_bio_start; | 110 | extent_submit_bio_start_t *submit_bio_start; |
111 | extent_submit_bio_done_t *submit_bio_done; | ||
112 | int mirror_num; | 111 | int mirror_num; |
113 | /* | 112 | /* |
114 | * bio_offset is optional, can be used if the pages in the bio | 113 | * bio_offset is optional, can be used if the pages in the bio |
@@ -775,7 +774,7 @@ static void run_one_async_done(struct btrfs_work *work) | |||
775 | return; | 774 | return; |
776 | } | 775 | } |
777 | 776 | ||
778 | async->submit_bio_done(async->private_data, async->bio, async->mirror_num); | 777 | btrfs_submit_bio_done(async->private_data, async->bio, async->mirror_num); |
779 | } | 778 | } |
780 | 779 | ||
781 | static void run_one_async_free(struct btrfs_work *work) | 780 | static void run_one_async_free(struct btrfs_work *work) |
@@ -789,8 +788,7 @@ static void run_one_async_free(struct btrfs_work *work) | |||
789 | blk_status_t btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio, | 788 | blk_status_t btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio, |
790 | int mirror_num, unsigned long bio_flags, | 789 | int mirror_num, unsigned long bio_flags, |
791 | u64 bio_offset, void *private_data, | 790 | u64 bio_offset, void *private_data, |
792 | extent_submit_bio_start_t *submit_bio_start, | 791 | extent_submit_bio_start_t *submit_bio_start) |
793 | extent_submit_bio_done_t *submit_bio_done) | ||
794 | { | 792 | { |
795 | struct async_submit_bio *async; | 793 | struct async_submit_bio *async; |
796 | 794 | ||
@@ -802,7 +800,6 @@ blk_status_t btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio, | |||
802 | async->bio = bio; | 800 | async->bio = bio; |
803 | async->mirror_num = mirror_num; | 801 | async->mirror_num = mirror_num; |
804 | async->submit_bio_start = submit_bio_start; | 802 | async->submit_bio_start = submit_bio_start; |
805 | async->submit_bio_done = submit_bio_done; | ||
806 | 803 | ||
807 | btrfs_init_work(&async->work, btrfs_worker_helper, run_one_async_start, | 804 | btrfs_init_work(&async->work, btrfs_worker_helper, run_one_async_start, |
808 | run_one_async_done, run_one_async_free); | 805 | run_one_async_done, run_one_async_free); |
@@ -845,24 +842,6 @@ static blk_status_t btree_submit_bio_start(void *private_data, struct bio *bio, | |||
845 | return btree_csum_one_bio(bio); | 842 | return btree_csum_one_bio(bio); |
846 | } | 843 | } |
847 | 844 | ||
848 | static blk_status_t btree_submit_bio_done(void *private_data, struct bio *bio, | ||
849 | int mirror_num) | ||
850 | { | ||
851 | struct inode *inode = private_data; | ||
852 | blk_status_t ret; | ||
853 | |||
854 | /* | ||
855 | * when we're called for a write, we're already in the async | ||
856 | * submission context. Just jump into btrfs_map_bio | ||
857 | */ | ||
858 | ret = btrfs_map_bio(btrfs_sb(inode->i_sb), bio, mirror_num, 1); | ||
859 | if (ret) { | ||
860 | bio->bi_status = ret; | ||
861 | bio_endio(bio); | ||
862 | } | ||
863 | return ret; | ||
864 | } | ||
865 | |||
866 | static int check_async_write(struct btrfs_inode *bi) | 845 | static int check_async_write(struct btrfs_inode *bi) |
867 | { | 846 | { |
868 | if (atomic_read(&bi->sync_writers)) | 847 | if (atomic_read(&bi->sync_writers)) |
@@ -905,8 +884,7 @@ static blk_status_t btree_submit_bio_hook(void *private_data, struct bio *bio, | |||
905 | */ | 884 | */ |
906 | ret = btrfs_wq_submit_bio(fs_info, bio, mirror_num, 0, | 885 | ret = btrfs_wq_submit_bio(fs_info, bio, mirror_num, 0, |
907 | bio_offset, private_data, | 886 | bio_offset, private_data, |
908 | btree_submit_bio_start, | 887 | btree_submit_bio_start); |
909 | btree_submit_bio_done); | ||
910 | } | 888 | } |
911 | 889 | ||
912 | if (ret) | 890 | if (ret) |
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h index 1a3d277b027b..4cccba22640f 100644 --- a/fs/btrfs/disk-io.h +++ b/fs/btrfs/disk-io.h | |||
@@ -120,8 +120,9 @@ blk_status_t btrfs_bio_wq_end_io(struct btrfs_fs_info *info, struct bio *bio, | |||
120 | blk_status_t btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio, | 120 | blk_status_t btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio, |
121 | int mirror_num, unsigned long bio_flags, | 121 | int mirror_num, unsigned long bio_flags, |
122 | u64 bio_offset, void *private_data, | 122 | u64 bio_offset, void *private_data, |
123 | extent_submit_bio_start_t *submit_bio_start, | 123 | extent_submit_bio_start_t *submit_bio_start); |
124 | extent_submit_bio_done_t *submit_bio_done); | 124 | blk_status_t btrfs_submit_bio_done(void *private_data, struct bio *bio, |
125 | int mirror_num); | ||
125 | int btrfs_write_tree_block(struct extent_buffer *buf); | 126 | int btrfs_write_tree_block(struct extent_buffer *buf); |
126 | void btrfs_wait_tree_block_writeback(struct extent_buffer *buf); | 127 | void btrfs_wait_tree_block_writeback(struct extent_buffer *buf); |
127 | int btrfs_init_log_root_tree(struct btrfs_trans_handle *trans, | 128 | int btrfs_init_log_root_tree(struct btrfs_trans_handle *trans, |
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h index 0ecc13b7d6f7..4e6d34dd7caf 100644 --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h | |||
@@ -92,9 +92,6 @@ typedef blk_status_t (extent_submit_bio_hook_t)(void *private_data, struct bio * | |||
92 | typedef blk_status_t (extent_submit_bio_start_t)(void *private_data, | 92 | typedef blk_status_t (extent_submit_bio_start_t)(void *private_data, |
93 | struct bio *bio, u64 bio_offset); | 93 | struct bio *bio, u64 bio_offset); |
94 | 94 | ||
95 | typedef blk_status_t (extent_submit_bio_done_t)(void *private_data, | ||
96 | struct bio *bio, int mirror_num); | ||
97 | |||
98 | struct extent_io_ops { | 95 | struct extent_io_ops { |
99 | /* | 96 | /* |
100 | * The following callbacks must be allways defined, the function | 97 | * The following callbacks must be allways defined, the function |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 564ec00c765b..6cb42e33fdc3 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -1957,7 +1957,7 @@ static blk_status_t btrfs_submit_bio_start(void *private_data, struct bio *bio, | |||
1957 | * At IO completion time the cums attached on the ordered extent record | 1957 | * At IO completion time the cums attached on the ordered extent record |
1958 | * are inserted into the btree | 1958 | * are inserted into the btree |
1959 | */ | 1959 | */ |
1960 | static blk_status_t btrfs_submit_bio_done(void *private_data, struct bio *bio, | 1960 | blk_status_t btrfs_submit_bio_done(void *private_data, struct bio *bio, |
1961 | int mirror_num) | 1961 | int mirror_num) |
1962 | { | 1962 | { |
1963 | struct inode *inode = private_data; | 1963 | struct inode *inode = private_data; |
@@ -2030,8 +2030,7 @@ static blk_status_t btrfs_submit_bio_hook(void *private_data, struct bio *bio, | |||
2030 | /* we're doing a write, do the async checksumming */ | 2030 | /* we're doing a write, do the async checksumming */ |
2031 | ret = btrfs_wq_submit_bio(fs_info, bio, mirror_num, bio_flags, | 2031 | ret = btrfs_wq_submit_bio(fs_info, bio, mirror_num, bio_flags, |
2032 | bio_offset, inode, | 2032 | bio_offset, inode, |
2033 | btrfs_submit_bio_start, | 2033 | btrfs_submit_bio_start); |
2034 | btrfs_submit_bio_done); | ||
2035 | goto out; | 2034 | goto out; |
2036 | } else if (!skip_sum) { | 2035 | } else if (!skip_sum) { |
2037 | ret = btrfs_csum_one_bio(inode, bio, 0, 0); | 2036 | ret = btrfs_csum_one_bio(inode, bio, 0, 0); |
@@ -8295,8 +8294,7 @@ static inline blk_status_t btrfs_submit_dio_bio(struct bio *bio, | |||
8295 | if (write && async_submit) { | 8294 | if (write && async_submit) { |
8296 | ret = btrfs_wq_submit_bio(fs_info, bio, 0, 0, | 8295 | ret = btrfs_wq_submit_bio(fs_info, bio, 0, 0, |
8297 | file_offset, inode, | 8296 | file_offset, inode, |
8298 | btrfs_submit_bio_start_direct_io, | 8297 | btrfs_submit_bio_start_direct_io); |
8299 | btrfs_submit_bio_done); | ||
8300 | goto err; | 8298 | goto err; |
8301 | } else if (write) { | 8299 | } else if (write) { |
8302 | /* | 8300 | /* |