aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-09-02 16:10:25 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-09-02 16:10:25 -0400
commit1081230b748de8f03f37f80c53dfa89feda9b8de (patch)
tree7238d60e01f0843bad8f03b5d84e4220fbba5e76 /fs/btrfs/disk-io.c
parentdf910390e2db07a76c87f258475f6c96253cee6c (diff)
parent2ca495ac27d245513c11fed70591b1838250e240 (diff)
Merge branch 'for-4.3/core' of git://git.kernel.dk/linux-block
Pull core block updates from Jens Axboe: "This first core part of the block IO changes contains: - Cleanup of the bio IO error signaling from Christoph. We used to rely on the uptodate bit and passing around of an error, now we store the error in the bio itself. - Improvement of the above from myself, by shrinking the bio size down again to fit in two cachelines on x86-64. - Revert of the max_hw_sectors cap removal from a revision again, from Jeff Moyer. This caused performance regressions in various tests. Reinstate the limit, bump it to a more reasonable size instead. - Make /sys/block/<dev>/queue/discard_max_bytes writeable, by me. Most devices have huge trim limits, which can cause nasty latencies when deleting files. Enable the admin to configure the size down. We will look into having a more sane default instead of UINT_MAX sectors. - Improvement of the SGP gaps logic from Keith Busch. - Enable the block core to handle arbitrarily sized bios, which enables a nice simplification of bio_add_page() (which is an IO hot path). From Kent. - Improvements to the partition io stats accounting, making it faster. From Ming Lei. - Also from Ming Lei, a basic fixup for overflow of the sysfs pending file in blk-mq, as well as a fix for a blk-mq timeout race condition. - Ming Lin has been carrying Kents above mentioned patches forward for a while, and testing them. Ming also did a few fixes around that. - Sasha Levin found and fixed a use-after-free problem introduced by the bio->bi_error changes from Christoph. - Small blk cgroup cleanup from Viresh Kumar" * 'for-4.3/core' of git://git.kernel.dk/linux-block: (26 commits) blk: Fix bio_io_vec index when checking bvec gaps block: Replace SG_GAPS with new queue limits mask block: bump BLK_DEF_MAX_SECTORS to 2560 Revert "block: remove artifical max_hw_sectors cap" blk-mq: fix race between timeout and freeing request blk-mq: fix buffer overflow when reading sysfs file of 'pending' Documentation: update notes in biovecs about arbitrarily sized bios block: remove bio_get_nr_vecs() fs: use helper bio_add_page() instead of open coding on bi_io_vec block: kill merge_bvec_fn() completely md/raid5: get rid of bio_fits_rdev() md/raid5: split bio for chunk_aligned_read block: remove split code in blkdev_issue_{discard,write_same} btrfs: remove bio splitting and merge_bvec_fn() calls bcache: remove driver private bio splitting code block: simplify bio_add_page() block: make generic_make_request handle arbitrarily sized bios blk-cgroup: Drop unlikely before IS_ERR(_OR_NULL) block: don't access bio->bi_error after bio_put() block: shrink struct bio down to 2 cache lines again ...
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index f556c3732c2c..5e307bd0471a 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -703,7 +703,7 @@ static int btree_io_failed_hook(struct page *page, int failed_mirror)
703 return -EIO; /* we fixed nothing */ 703 return -EIO; /* we fixed nothing */
704} 704}
705 705
706static void end_workqueue_bio(struct bio *bio, int err) 706static void end_workqueue_bio(struct bio *bio)
707{ 707{
708 struct btrfs_end_io_wq *end_io_wq = bio->bi_private; 708 struct btrfs_end_io_wq *end_io_wq = bio->bi_private;
709 struct btrfs_fs_info *fs_info; 709 struct btrfs_fs_info *fs_info;
@@ -711,7 +711,7 @@ static void end_workqueue_bio(struct bio *bio, int err)
711 btrfs_work_func_t func; 711 btrfs_work_func_t func;
712 712
713 fs_info = end_io_wq->info; 713 fs_info = end_io_wq->info;
714 end_io_wq->error = err; 714 end_io_wq->error = bio->bi_error;
715 715
716 if (bio->bi_rw & REQ_WRITE) { 716 if (bio->bi_rw & REQ_WRITE) {
717 if (end_io_wq->metadata == BTRFS_WQ_ENDIO_METADATA) { 717 if (end_io_wq->metadata == BTRFS_WQ_ENDIO_METADATA) {
@@ -808,7 +808,8 @@ static void run_one_async_done(struct btrfs_work *work)
808 808
809 /* If an error occured we just want to clean up the bio and move on */ 809 /* If an error occured we just want to clean up the bio and move on */
810 if (async->error) { 810 if (async->error) {
811 bio_endio(async->bio, async->error); 811 async->bio->bi_error = async->error;
812 bio_endio(async->bio);
812 return; 813 return;
813 } 814 }
814 815
@@ -908,8 +909,10 @@ static int __btree_submit_bio_done(struct inode *inode, int rw, struct bio *bio,
908 * submission context. Just jump into btrfs_map_bio 909 * submission context. Just jump into btrfs_map_bio
909 */ 910 */
910 ret = btrfs_map_bio(BTRFS_I(inode)->root, rw, bio, mirror_num, 1); 911 ret = btrfs_map_bio(BTRFS_I(inode)->root, rw, bio, mirror_num, 1);
911 if (ret) 912 if (ret) {
912 bio_endio(bio, ret); 913 bio->bi_error = ret;
914 bio_endio(bio);
915 }
913 return ret; 916 return ret;
914} 917}
915 918
@@ -960,10 +963,13 @@ static int btree_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
960 __btree_submit_bio_done); 963 __btree_submit_bio_done);
961 } 964 }
962 965
963 if (ret) { 966 if (ret)
967 goto out_w_error;
968 return 0;
969
964out_w_error: 970out_w_error:
965 bio_endio(bio, ret); 971 bio->bi_error = ret;
966 } 972 bio_endio(bio);
967 return ret; 973 return ret;
968} 974}
969 975
@@ -1735,16 +1741,15 @@ static void end_workqueue_fn(struct btrfs_work *work)
1735{ 1741{
1736 struct bio *bio; 1742 struct bio *bio;
1737 struct btrfs_end_io_wq *end_io_wq; 1743 struct btrfs_end_io_wq *end_io_wq;
1738 int error;
1739 1744
1740 end_io_wq = container_of(work, struct btrfs_end_io_wq, work); 1745 end_io_wq = container_of(work, struct btrfs_end_io_wq, work);
1741 bio = end_io_wq->bio; 1746 bio = end_io_wq->bio;
1742 1747
1743 error = end_io_wq->error; 1748 bio->bi_error = end_io_wq->error;
1744 bio->bi_private = end_io_wq->private; 1749 bio->bi_private = end_io_wq->private;
1745 bio->bi_end_io = end_io_wq->end_io; 1750 bio->bi_end_io = end_io_wq->end_io;
1746 kmem_cache_free(btrfs_end_io_wq_cache, end_io_wq); 1751 kmem_cache_free(btrfs_end_io_wq_cache, end_io_wq);
1747 bio_endio(bio, error); 1752 bio_endio(bio);
1748} 1753}
1749 1754
1750static int cleaner_kthread(void *arg) 1755static int cleaner_kthread(void *arg)
@@ -3324,10 +3329,8 @@ static int write_dev_supers(struct btrfs_device *device,
3324 * endio for the write_dev_flush, this will wake anyone waiting 3329 * endio for the write_dev_flush, this will wake anyone waiting
3325 * for the barrier when it is done 3330 * for the barrier when it is done
3326 */ 3331 */
3327static void btrfs_end_empty_barrier(struct bio *bio, int err) 3332static void btrfs_end_empty_barrier(struct bio *bio)
3328{ 3333{
3329 if (err)
3330 clear_bit(BIO_UPTODATE, &bio->bi_flags);
3331 if (bio->bi_private) 3334 if (bio->bi_private)
3332 complete(bio->bi_private); 3335 complete(bio->bi_private);
3333 bio_put(bio); 3336 bio_put(bio);
@@ -3355,8 +3358,8 @@ static int write_dev_flush(struct btrfs_device *device, int wait)
3355 3358
3356 wait_for_completion(&device->flush_wait); 3359 wait_for_completion(&device->flush_wait);
3357 3360
3358 if (!bio_flagged(bio, BIO_UPTODATE)) { 3361 if (bio->bi_error) {
3359 ret = -EIO; 3362 ret = bio->bi_error;
3360 btrfs_dev_stat_inc_and_print(device, 3363 btrfs_dev_stat_inc_and_print(device,
3361 BTRFS_DEV_STAT_FLUSH_ERRS); 3364 BTRFS_DEV_STAT_FLUSH_ERRS);
3362 } 3365 }