Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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
...

+1197 -2128
+1 -1
Documentation/block/biodoc.txt
··· 1109 1109 as specified. 1110 1110 1111 1111 Now bh->b_end_io is replaced by bio->bi_end_io, but most of the time the 1112 - right thing to use is bio_endio(bio, uptodate) instead. 1112 + right thing to use is bio_endio(bio) instead. 1113 1113 1114 1114 If the driver is dropping the io_request_lock from its request_fn strategy, 1115 1115 then it just needs to replace that with q->queue_lock instead.
+9 -1
Documentation/block/biovecs.txt
··· 24 24 normal code doesn't have to deal with bi_bvec_done. 25 25 26 26 * Driver code should no longer refer to biovecs directly; we now have 27 - bio_iovec() and bio_iovec_iter() macros that return literal struct biovecs, 27 + bio_iovec() and bio_iter_iovec() macros that return literal struct biovecs, 28 28 constructed from the raw biovecs but taking into account bi_bvec_done and 29 29 bi_size. 30 30 ··· 109 109 over all the biovecs in the new bio - which is silly as it's not needed. 110 110 111 111 So, don't use bi_vcnt anymore. 112 + 113 + * The current interface allows the block layer to split bios as needed, so we 114 + could eliminate a lot of complexity particularly in stacked drivers. Code 115 + that creates bios can then create whatever size bios are convenient, and 116 + more importantly stacked drivers don't have to deal with both their own bio 117 + size limitations and the limitations of the underlying devices. Thus 118 + there's no need to define ->merge_bvec_fn() callbacks for individual block 119 + drivers.
+9 -1
Documentation/block/queue-sysfs.txt
··· 20 20 reported by the device. A value of '0' means device does not support 21 21 the discard functionality. 22 22 23 - discard_max_bytes (RO) 23 + discard_max_hw_bytes (RO) 24 24 ---------------------- 25 25 Devices that support discard functionality may have internal limits on 26 26 the number of bytes that can be trimmed or unmapped in a single operation. ··· 28 28 number of bytes that can be discarded in a single operation. Discard 29 29 requests issued to the device must not exceed this limit. A discard_max_bytes 30 30 value of 0 means that the device does not support discard functionality. 31 + 32 + discard_max_bytes (RW) 33 + ---------------------- 34 + While discard_max_hw_bytes is the hardware limit for the device, this 35 + setting is the software limit. Some devices exhibit large latencies when 36 + large discards are issued, setting this value lower will make Linux issue 37 + smaller discards and potentially help reduce latencies induced by large 38 + discard operations. 31 39 32 40 discard_zeroes_data (RO) 33 41 ------------------------
+1 -1
arch/m68k/emu/nfblock.c
··· 76 76 bvec_to_phys(&bvec)); 77 77 sec += len; 78 78 } 79 - bio_endio(bio, 0); 79 + bio_endio(bio); 80 80 } 81 81 82 82 static int nfhd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
+1 -1
arch/powerpc/sysdev/axonram.c
··· 132 132 phys_mem += vec.bv_len; 133 133 transfered += vec.bv_len; 134 134 } 135 - bio_endio(bio, 0); 135 + bio_endio(bio); 136 136 } 137 137 138 138 /**
+3 -9
arch/xtensa/platforms/iss/simdisk.c
··· 101 101 spin_unlock(&dev->lock); 102 102 } 103 103 104 - static int simdisk_xfer_bio(struct simdisk *dev, struct bio *bio) 104 + static void simdisk_make_request(struct request_queue *q, struct bio *bio) 105 105 { 106 + struct simdisk *dev = q->queuedata; 106 107 struct bio_vec bvec; 107 108 struct bvec_iter iter; 108 109 sector_t sector = bio->bi_iter.bi_sector; ··· 117 116 sector += len; 118 117 __bio_kunmap_atomic(buffer); 119 118 } 120 - return 0; 121 - } 122 119 123 - static void simdisk_make_request(struct request_queue *q, struct bio *bio) 124 - { 125 - struct simdisk *dev = q->queuedata; 126 - int status = simdisk_xfer_bio(dev, bio); 127 - bio_endio(bio, status); 120 + bio_endio(bio); 128 121 } 129 - 130 122 131 123 static int simdisk_open(struct block_device *bdev, fmode_t mode) 132 124 {
+5 -6
block/bio-integrity.c
··· 355 355 container_of(work, struct bio_integrity_payload, bip_work); 356 356 struct bio *bio = bip->bip_bio; 357 357 struct blk_integrity *bi = bdev_get_integrity(bio->bi_bdev); 358 - int error; 359 358 360 - error = bio_integrity_process(bio, bi->verify_fn); 359 + bio->bi_error = bio_integrity_process(bio, bi->verify_fn); 361 360 362 361 /* Restore original bio completion handler */ 363 362 bio->bi_end_io = bip->bip_end_io; 364 - bio_endio(bio, error); 363 + bio_endio(bio); 365 364 } 366 365 367 366 /** ··· 375 376 * in process context. This function postpones completion 376 377 * accordingly. 377 378 */ 378 - void bio_integrity_endio(struct bio *bio, int error) 379 + void bio_integrity_endio(struct bio *bio) 379 380 { 380 381 struct bio_integrity_payload *bip = bio_integrity(bio); 381 382 ··· 385 386 * integrity metadata. Restore original bio end_io handler 386 387 * and run it. 387 388 */ 388 - if (error) { 389 + if (bio->bi_error) { 389 390 bio->bi_end_io = bip->bip_end_io; 390 - bio_endio(bio, error); 391 + bio_endio(bio); 391 392 392 393 return; 393 394 }
+78 -134
block/bio.c
··· 269 269 void bio_init(struct bio *bio) 270 270 { 271 271 memset(bio, 0, sizeof(*bio)); 272 - bio->bi_flags = 1 << BIO_UPTODATE; 273 272 atomic_set(&bio->__bi_remaining, 1); 274 273 atomic_set(&bio->__bi_cnt, 1); 275 274 } ··· 291 292 __bio_free(bio); 292 293 293 294 memset(bio, 0, BIO_RESET_BYTES); 294 - bio->bi_flags = flags | (1 << BIO_UPTODATE); 295 + bio->bi_flags = flags; 295 296 atomic_set(&bio->__bi_remaining, 1); 296 297 } 297 298 EXPORT_SYMBOL(bio_reset); 298 299 299 - static void bio_chain_endio(struct bio *bio, int error) 300 + static void bio_chain_endio(struct bio *bio) 300 301 { 301 - bio_endio(bio->bi_private, error); 302 + struct bio *parent = bio->bi_private; 303 + 304 + parent->bi_error = bio->bi_error; 305 + bio_endio(parent); 302 306 bio_put(bio); 303 307 } 304 308 ··· 311 309 */ 312 310 static inline void bio_inc_remaining(struct bio *bio) 313 311 { 314 - bio->bi_flags |= (1 << BIO_CHAIN); 312 + bio_set_flag(bio, BIO_CHAIN); 315 313 smp_mb__before_atomic(); 316 314 atomic_inc(&bio->__bi_remaining); 317 315 } ··· 495 493 if (unlikely(!bvl)) 496 494 goto err_free; 497 495 498 - bio->bi_flags |= 1 << BIO_OWNS_VEC; 496 + bio_set_flag(bio, BIO_OWNS_VEC); 499 497 } else if (nr_iovecs) { 500 498 bvl = bio->bi_inline_vecs; 501 499 } ··· 580 578 * so we don't set nor calculate new physical/hw segment counts here 581 579 */ 582 580 bio->bi_bdev = bio_src->bi_bdev; 583 - bio->bi_flags |= 1 << BIO_CLONED; 581 + bio_set_flag(bio, BIO_CLONED); 584 582 bio->bi_rw = bio_src->bi_rw; 585 583 bio->bi_iter = bio_src->bi_iter; 586 584 bio->bi_io_vec = bio_src->bi_io_vec; ··· 694 692 EXPORT_SYMBOL(bio_clone_bioset); 695 693 696 694 /** 697 - * bio_get_nr_vecs - return approx number of vecs 698 - * @bdev: I/O target 695 + * bio_add_pc_page - attempt to add page to bio 696 + * @q: the target queue 697 + * @bio: destination bio 698 + * @page: page to add 699 + * @len: vec entry length 700 + * @offset: vec entry offset 699 701 * 700 - * Return the approximate number of pages we can send to this target. 701 - * There's no guarantee that you will be able to fit this number of pages 702 - * into a bio, it does not account for dynamic restrictions that vary 703 - * on offset. 702 + * Attempt to add a page to the bio_vec maplist. This can fail for a 703 + * number of reasons, such as the bio being full or target block device 704 + * limitations. The target block device must allow bio's up to PAGE_SIZE, 705 + * so it is always possible to add a single page to an empty bio. 706 + * 707 + * This should only be used by REQ_PC bios. 704 708 */ 705 - int bio_get_nr_vecs(struct block_device *bdev) 706 - { 707 - struct request_queue *q = bdev_get_queue(bdev); 708 - int nr_pages; 709 - 710 - nr_pages = min_t(unsigned, 711 - queue_max_segments(q), 712 - queue_max_sectors(q) / (PAGE_SIZE >> 9) + 1); 713 - 714 - return min_t(unsigned, nr_pages, BIO_MAX_PAGES); 715 - 716 - } 717 - EXPORT_SYMBOL(bio_get_nr_vecs); 718 - 719 - static int __bio_add_page(struct request_queue *q, struct bio *bio, struct page 720 - *page, unsigned int len, unsigned int offset, 721 - unsigned int max_sectors) 709 + int bio_add_pc_page(struct request_queue *q, struct bio *bio, struct page 710 + *page, unsigned int len, unsigned int offset) 722 711 { 723 712 int retried_segments = 0; 724 713 struct bio_vec *bvec; ··· 720 727 if (unlikely(bio_flagged(bio, BIO_CLONED))) 721 728 return 0; 722 729 723 - if (((bio->bi_iter.bi_size + len) >> 9) > max_sectors) 730 + if (((bio->bi_iter.bi_size + len) >> 9) > queue_max_hw_sectors(q)) 724 731 return 0; 725 732 726 733 /* ··· 733 740 734 741 if (page == prev->bv_page && 735 742 offset == prev->bv_offset + prev->bv_len) { 736 - unsigned int prev_bv_len = prev->bv_len; 737 743 prev->bv_len += len; 738 - 739 - if (q->merge_bvec_fn) { 740 - struct bvec_merge_data bvm = { 741 - /* prev_bvec is already charged in 742 - bi_size, discharge it in order to 743 - simulate merging updated prev_bvec 744 - as new bvec. */ 745 - .bi_bdev = bio->bi_bdev, 746 - .bi_sector = bio->bi_iter.bi_sector, 747 - .bi_size = bio->bi_iter.bi_size - 748 - prev_bv_len, 749 - .bi_rw = bio->bi_rw, 750 - }; 751 - 752 - if (q->merge_bvec_fn(q, &bvm, prev) < prev->bv_len) { 753 - prev->bv_len -= len; 754 - return 0; 755 - } 756 - } 757 - 758 744 bio->bi_iter.bi_size += len; 759 745 goto done; 760 746 } ··· 742 770 * If the queue doesn't support SG gaps and adding this 743 771 * offset would create a gap, disallow it. 744 772 */ 745 - if (q->queue_flags & (1 << QUEUE_FLAG_SG_GAPS) && 746 - bvec_gap_to_prev(prev, offset)) 773 + if (bvec_gap_to_prev(q, prev, offset)) 747 774 return 0; 748 775 } 749 776 ··· 775 804 blk_recount_segments(q, bio); 776 805 } 777 806 778 - /* 779 - * if queue has other restrictions (eg varying max sector size 780 - * depending on offset), it can specify a merge_bvec_fn in the 781 - * queue to get further control 782 - */ 783 - if (q->merge_bvec_fn) { 784 - struct bvec_merge_data bvm = { 785 - .bi_bdev = bio->bi_bdev, 786 - .bi_sector = bio->bi_iter.bi_sector, 787 - .bi_size = bio->bi_iter.bi_size - len, 788 - .bi_rw = bio->bi_rw, 789 - }; 790 - 791 - /* 792 - * merge_bvec_fn() returns number of bytes it can accept 793 - * at this offset 794 - */ 795 - if (q->merge_bvec_fn(q, &bvm, bvec) < bvec->bv_len) 796 - goto failed; 797 - } 798 - 799 807 /* If we may be able to merge these biovecs, force a recount */ 800 808 if (bio->bi_vcnt > 1 && (BIOVEC_PHYS_MERGEABLE(bvec-1, bvec))) 801 - bio->bi_flags &= ~(1 << BIO_SEG_VALID); 809 + bio_clear_flag(bio, BIO_SEG_VALID); 802 810 803 811 done: 804 812 return len; ··· 791 841 blk_recount_segments(q, bio); 792 842 return 0; 793 843 } 794 - 795 - /** 796 - * bio_add_pc_page - attempt to add page to bio 797 - * @q: the target queue 798 - * @bio: destination bio 799 - * @page: page to add 800 - * @len: vec entry length 801 - * @offset: vec entry offset 802 - * 803 - * Attempt to add a page to the bio_vec maplist. This can fail for a 804 - * number of reasons, such as the bio being full or target block device 805 - * limitations. The target block device must allow bio's up to PAGE_SIZE, 806 - * so it is always possible to add a single page to an empty bio. 807 - * 808 - * This should only be used by REQ_PC bios. 809 - */ 810 - int bio_add_pc_page(struct request_queue *q, struct bio *bio, struct page *page, 811 - unsigned int len, unsigned int offset) 812 - { 813 - return __bio_add_page(q, bio, page, len, offset, 814 - queue_max_hw_sectors(q)); 815 - } 816 844 EXPORT_SYMBOL(bio_add_pc_page); 817 845 818 846 /** ··· 800 872 * @len: vec entry length 801 873 * @offset: vec entry offset 802 874 * 803 - * Attempt to add a page to the bio_vec maplist. This can fail for a 804 - * number of reasons, such as the bio being full or target block device 805 - * limitations. The target block device must allow bio's up to PAGE_SIZE, 806 - * so it is always possible to add a single page to an empty bio. 875 + * Attempt to add a page to the bio_vec maplist. This will only fail 876 + * if either bio->bi_vcnt == bio->bi_max_vecs or it's a cloned bio. 807 877 */ 808 - int bio_add_page(struct bio *bio, struct page *page, unsigned int len, 809 - unsigned int offset) 878 + int bio_add_page(struct bio *bio, struct page *page, 879 + unsigned int len, unsigned int offset) 810 880 { 811 - struct request_queue *q = bdev_get_queue(bio->bi_bdev); 812 - unsigned int max_sectors; 881 + struct bio_vec *bv; 813 882 814 - max_sectors = blk_max_size_offset(q, bio->bi_iter.bi_sector); 815 - if ((max_sectors < (len >> 9)) && !bio->bi_iter.bi_size) 816 - max_sectors = len >> 9; 883 + /* 884 + * cloned bio must not modify vec list 885 + */ 886 + if (WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED))) 887 + return 0; 817 888 818 - return __bio_add_page(q, bio, page, len, offset, max_sectors); 889 + /* 890 + * For filesystems with a blocksize smaller than the pagesize 891 + * we will often be called with the same page as last time and 892 + * a consecutive offset. Optimize this special case. 893 + */ 894 + if (bio->bi_vcnt > 0) { 895 + bv = &bio->bi_io_vec[bio->bi_vcnt - 1]; 896 + 897 + if (page == bv->bv_page && 898 + offset == bv->bv_offset + bv->bv_len) { 899 + bv->bv_len += len; 900 + goto done; 901 + } 902 + } 903 + 904 + if (bio->bi_vcnt >= bio->bi_max_vecs) 905 + return 0; 906 + 907 + bv = &bio->bi_io_vec[bio->bi_vcnt]; 908 + bv->bv_page = page; 909 + bv->bv_len = len; 910 + bv->bv_offset = offset; 911 + 912 + bio->bi_vcnt++; 913 + done: 914 + bio->bi_iter.bi_size += len; 915 + return len; 819 916 } 820 917 EXPORT_SYMBOL(bio_add_page); 821 918 ··· 849 896 int error; 850 897 }; 851 898 852 - static void submit_bio_wait_endio(struct bio *bio, int error) 899 + static void submit_bio_wait_endio(struct bio *bio) 853 900 { 854 901 struct submit_bio_ret *ret = bio->bi_private; 855 902 856 - ret->error = error; 903 + ret->error = bio->bi_error; 857 904 complete(&ret->event); 858 905 } 859 906 ··· 1341 1388 if (iter->type & WRITE) 1342 1389 bio->bi_rw |= REQ_WRITE; 1343 1390 1344 - bio->bi_flags |= (1 << BIO_USER_MAPPED); 1391 + bio_set_flag(bio, BIO_USER_MAPPED); 1345 1392 1346 1393 /* 1347 1394 * subtle -- if __bio_map_user() ended up bouncing a bio, ··· 1398 1445 } 1399 1446 EXPORT_SYMBOL(bio_unmap_user); 1400 1447 1401 - static void bio_map_kern_endio(struct bio *bio, int err) 1448 + static void bio_map_kern_endio(struct bio *bio) 1402 1449 { 1403 1450 bio_put(bio); 1404 1451 } ··· 1454 1501 } 1455 1502 EXPORT_SYMBOL(bio_map_kern); 1456 1503 1457 - static void bio_copy_kern_endio(struct bio *bio, int err) 1504 + static void bio_copy_kern_endio(struct bio *bio) 1458 1505 { 1459 1506 bio_free_pages(bio); 1460 1507 bio_put(bio); 1461 1508 } 1462 1509 1463 - static void bio_copy_kern_endio_read(struct bio *bio, int err) 1510 + static void bio_copy_kern_endio_read(struct bio *bio) 1464 1511 { 1465 1512 char *p = bio->bi_private; 1466 1513 struct bio_vec *bvec; ··· 1471 1518 p += bvec->bv_len; 1472 1519 } 1473 1520 1474 - bio_copy_kern_endio(bio, err); 1521 + bio_copy_kern_endio(bio); 1475 1522 } 1476 1523 1477 1524 /** ··· 1721 1768 BUG_ON(atomic_read(&bio->__bi_remaining) <= 0); 1722 1769 1723 1770 if (atomic_dec_and_test(&bio->__bi_remaining)) { 1724 - clear_bit(BIO_CHAIN, &bio->bi_flags); 1771 + bio_clear_flag(bio, BIO_CHAIN); 1725 1772 return true; 1726 1773 } 1727 1774 ··· 1731 1778 /** 1732 1779 * bio_endio - end I/O on a bio 1733 1780 * @bio: bio 1734 - * @error: error, if any 1735 1781 * 1736 1782 * Description: 1737 - * bio_endio() will end I/O on the whole bio. bio_endio() is the 1738 - * preferred way to end I/O on a bio, it takes care of clearing 1739 - * BIO_UPTODATE on error. @error is 0 on success, and and one of the 1740 - * established -Exxxx (-EIO, for instance) error values in case 1741 - * something went wrong. No one should call bi_end_io() directly on a 1742 - * bio unless they own it and thus know that it has an end_io 1743 - * function. 1783 + * bio_endio() will end I/O on the whole bio. bio_endio() is the preferred 1784 + * way to end I/O on a bio. No one should call bi_end_io() directly on a 1785 + * bio unless they own it and thus know that it has an end_io function. 1744 1786 **/ 1745 - void bio_endio(struct bio *bio, int error) 1787 + void bio_endio(struct bio *bio) 1746 1788 { 1747 1789 while (bio) { 1748 - if (error) 1749 - clear_bit(BIO_UPTODATE, &bio->bi_flags); 1750 - else if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) 1751 - error = -EIO; 1752 - 1753 1790 if (unlikely(!bio_remaining_done(bio))) 1754 1791 break; 1755 1792 ··· 1753 1810 */ 1754 1811 if (bio->bi_end_io == bio_chain_endio) { 1755 1812 struct bio *parent = bio->bi_private; 1813 + parent->bi_error = bio->bi_error; 1756 1814 bio_put(bio); 1757 1815 bio = parent; 1758 1816 } else { 1759 1817 if (bio->bi_end_io) 1760 - bio->bi_end_io(bio, error); 1818 + bio->bi_end_io(bio); 1761 1819 bio = NULL; 1762 1820 } 1763 1821 } ··· 1826 1882 if (offset == 0 && size == bio->bi_iter.bi_size) 1827 1883 return; 1828 1884 1829 - clear_bit(BIO_SEG_VALID, &bio->bi_flags); 1885 + bio_clear_flag(bio, BIO_SEG_VALID); 1830 1886 1831 1887 bio_advance(bio, offset << 9); 1832 1888
+18 -18
block/blk-core.c
··· 143 143 unsigned int nbytes, int error) 144 144 { 145 145 if (error) 146 - clear_bit(BIO_UPTODATE, &bio->bi_flags); 147 - else if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) 148 - error = -EIO; 146 + bio->bi_error = error; 149 147 150 148 if (unlikely(rq->cmd_flags & REQ_QUIET)) 151 - set_bit(BIO_QUIET, &bio->bi_flags); 149 + bio_set_flag(bio, BIO_QUIET); 152 150 153 151 bio_advance(bio, nbytes); 154 152 155 153 /* don't actually finish bio if it's part of flush sequence */ 156 154 if (bio->bi_iter.bi_size == 0 && !(rq->cmd_flags & REQ_FLUSH_SEQ)) 157 - bio_endio(bio, error); 155 + bio_endio(bio); 158 156 } 159 157 160 158 void blk_dump_rq_flags(struct request *rq, char *msg) ··· 643 645 if (q->id < 0) 644 646 goto fail_q; 645 647 648 + q->bio_split = bioset_create(BIO_POOL_SIZE, 0); 649 + if (!q->bio_split) 650 + goto fail_id; 651 + 646 652 q->backing_dev_info.ra_pages = 647 653 (VM_MAX_READAHEAD * 1024) / PAGE_CACHE_SIZE; 648 654 q->backing_dev_info.capabilities = BDI_CAP_CGROUP_WRITEBACK; ··· 655 653 656 654 err = bdi_init(&q->backing_dev_info); 657 655 if (err) 658 - goto fail_id; 656 + goto fail_split; 659 657 660 658 setup_timer(&q->backing_dev_info.laptop_mode_wb_timer, 661 659 laptop_mode_timer_fn, (unsigned long) q); ··· 697 695 698 696 fail_bdi: 699 697 bdi_destroy(&q->backing_dev_info); 698 + fail_split: 699 + bioset_free(q->bio_split); 700 700 fail_id: 701 701 ida_simple_remove(&blk_queue_ida, q->id); 702 702 fail_q: ··· 1616 1612 struct request *req; 1617 1613 unsigned int request_count = 0; 1618 1614 1615 + blk_queue_split(q, &bio, q->bio_split); 1616 + 1619 1617 /* 1620 1618 * low level driver can indicate that it wants pages above a 1621 1619 * certain limit bounced to low memory (ie for highmem, or even ··· 1626 1620 blk_queue_bounce(q, &bio); 1627 1621 1628 1622 if (bio_integrity_enabled(bio) && bio_integrity_prep(bio)) { 1629 - bio_endio(bio, -EIO); 1623 + bio->bi_error = -EIO; 1624 + bio_endio(bio); 1630 1625 return; 1631 1626 } 1632 1627 ··· 1680 1673 */ 1681 1674 req = get_request(q, rw_flags, bio, GFP_NOIO); 1682 1675 if (IS_ERR(req)) { 1683 - bio_endio(bio, PTR_ERR(req)); /* @q is dead */ 1676 + bio->bi_error = PTR_ERR(req); 1677 + bio_endio(bio); 1684 1678 goto out_unlock; 1685 1679 } 1686 1680 ··· 1840 1832 goto end_io; 1841 1833 } 1842 1834 1843 - if (likely(bio_is_rw(bio) && 1844 - nr_sectors > queue_max_hw_sectors(q))) { 1845 - printk(KERN_ERR "bio too big device %s (%u > %u)\n", 1846 - bdevname(bio->bi_bdev, b), 1847 - bio_sectors(bio), 1848 - queue_max_hw_sectors(q)); 1849 - goto end_io; 1850 - } 1851 - 1852 1835 part = bio->bi_bdev->bd_part; 1853 1836 if (should_fail_request(part, bio->bi_iter.bi_size) || 1854 1837 should_fail_request(&part_to_disk(part)->part0, ··· 1895 1896 return true; 1896 1897 1897 1898 end_io: 1898 - bio_endio(bio, err); 1899 + bio->bi_error = err; 1900 + bio_endio(bio); 1899 1901 return false; 1900 1902 } 1901 1903
+14 -1
block/blk-flush.c
··· 73 73 74 74 #include "blk.h" 75 75 #include "blk-mq.h" 76 + #include "blk-mq-tag.h" 76 77 77 78 /* FLUSH/FUA sequences */ 78 79 enum { ··· 227 226 struct blk_flush_queue *fq = blk_get_flush_queue(q, flush_rq->mq_ctx); 228 227 229 228 if (q->mq_ops) { 229 + struct blk_mq_hw_ctx *hctx; 230 + 231 + /* release the tag's ownership to the req cloned from */ 230 232 spin_lock_irqsave(&fq->mq_flush_lock, flags); 233 + hctx = q->mq_ops->map_queue(q, flush_rq->mq_ctx->cpu); 234 + blk_mq_tag_set_rq(hctx, flush_rq->tag, fq->orig_rq); 231 235 flush_rq->tag = -1; 232 236 } 233 237 ··· 314 308 315 309 /* 316 310 * Borrow tag from the first request since they can't 317 - * be in flight at the same time. 311 + * be in flight at the same time. And acquire the tag's 312 + * ownership for flush req. 318 313 */ 319 314 if (q->mq_ops) { 315 + struct blk_mq_hw_ctx *hctx; 316 + 320 317 flush_rq->mq_ctx = first_rq->mq_ctx; 321 318 flush_rq->tag = first_rq->tag; 319 + fq->orig_rq = first_rq; 320 + 321 + hctx = q->mq_ops->map_queue(q, first_rq->mq_ctx->cpu); 322 + blk_mq_tag_set_rq(hctx, first_rq->tag, flush_rq); 322 323 } 323 324 324 325 flush_rq->cmd_type = REQ_TYPE_FS;
+24 -53
block/blk-lib.c
··· 11 11 12 12 struct bio_batch { 13 13 atomic_t done; 14 - unsigned long flags; 14 + int error; 15 15 struct completion *wait; 16 16 }; 17 17 18 - static void bio_batch_end_io(struct bio *bio, int err) 18 + static void bio_batch_end_io(struct bio *bio) 19 19 { 20 20 struct bio_batch *bb = bio->bi_private; 21 21 22 - if (err && (err != -EOPNOTSUPP)) 23 - clear_bit(BIO_UPTODATE, &bb->flags); 22 + if (bio->bi_error && bio->bi_error != -EOPNOTSUPP) 23 + bb->error = bio->bi_error; 24 24 if (atomic_dec_and_test(&bb->done)) 25 25 complete(bb->wait); 26 26 bio_put(bio); 27 27 } 28 + 29 + /* 30 + * Ensure that max discard sectors doesn't overflow bi_size and hopefully 31 + * it is of the proper granularity as long as the granularity is a power 32 + * of two. 33 + */ 34 + #define MAX_BIO_SECTORS ((1U << 31) >> 9) 28 35 29 36 /** 30 37 * blkdev_issue_discard - queue a discard ··· 50 43 DECLARE_COMPLETION_ONSTACK(wait); 51 44 struct request_queue *q = bdev_get_queue(bdev); 52 45 int type = REQ_WRITE | REQ_DISCARD; 53 - unsigned int max_discard_sectors, granularity; 54 - int alignment; 55 46 struct bio_batch bb; 56 47 struct bio *bio; 57 48 int ret = 0; ··· 61 56 if (!blk_queue_discard(q)) 62 57 return -EOPNOTSUPP; 63 58 64 - /* Zero-sector (unknown) and one-sector granularities are the same. */ 65 - granularity = max(q->limits.discard_granularity >> 9, 1U); 66 - alignment = (bdev_discard_alignment(bdev) >> 9) % granularity; 67 - 68 - /* 69 - * Ensure that max_discard_sectors is of the proper 70 - * granularity, so that requests stay aligned after a split. 71 - */ 72 - max_discard_sectors = min(q->limits.max_discard_sectors, UINT_MAX >> 9); 73 - max_discard_sectors -= max_discard_sectors % granularity; 74 - if (unlikely(!max_discard_sectors)) { 75 - /* Avoid infinite loop below. Being cautious never hurts. */ 76 - return -EOPNOTSUPP; 77 - } 78 - 79 59 if (flags & BLKDEV_DISCARD_SECURE) { 80 60 if (!blk_queue_secdiscard(q)) 81 61 return -EOPNOTSUPP; ··· 68 78 } 69 79 70 80 atomic_set(&bb.done, 1); 71 - bb.flags = 1 << BIO_UPTODATE; 81 + bb.error = 0; 72 82 bb.wait = &wait; 73 83 74 84 blk_start_plug(&plug); 75 85 while (nr_sects) { 76 86 unsigned int req_sects; 77 - sector_t end_sect, tmp; 87 + sector_t end_sect; 78 88 79 89 bio = bio_alloc(gfp_mask, 1); 80 90 if (!bio) { ··· 82 92 break; 83 93 } 84 94 85 - req_sects = min_t(sector_t, nr_sects, max_discard_sectors); 86 - 87 - /* 88 - * If splitting a request, and the next starting sector would be 89 - * misaligned, stop the discard at the previous aligned sector. 90 - */ 95 + req_sects = min_t(sector_t, nr_sects, MAX_BIO_SECTORS); 91 96 end_sect = sector + req_sects; 92 - tmp = end_sect; 93 - if (req_sects < nr_sects && 94 - sector_div(tmp, granularity) != alignment) { 95 - end_sect = end_sect - alignment; 96 - sector_div(end_sect, granularity); 97 - end_sect = end_sect * granularity + alignment; 98 - req_sects = end_sect - sector; 99 - } 100 97 101 98 bio->bi_iter.bi_sector = sector; 102 99 bio->bi_end_io = bio_batch_end_io; ··· 111 134 if (!atomic_dec_and_test(&bb.done)) 112 135 wait_for_completion_io(&wait); 113 136 114 - if (!test_bit(BIO_UPTODATE, &bb.flags)) 115 - ret = -EIO; 116 - 137 + if (bb.error) 138 + return bb.error; 117 139 return ret; 118 140 } 119 141 EXPORT_SYMBOL(blkdev_issue_discard); ··· 142 166 if (!q) 143 167 return -ENXIO; 144 168 145 - max_write_same_sectors = q->limits.max_write_same_sectors; 146 - 147 - if (max_write_same_sectors == 0) 148 - return -EOPNOTSUPP; 169 + /* Ensure that max_write_same_sectors doesn't overflow bi_size */ 170 + max_write_same_sectors = UINT_MAX >> 9; 149 171 150 172 atomic_set(&bb.done, 1); 151 - bb.flags = 1 << BIO_UPTODATE; 173 + bb.error = 0; 152 174 bb.wait = &wait; 153 175 154 176 while (nr_sects) { ··· 182 208 if (!atomic_dec_and_test(&bb.done)) 183 209 wait_for_completion_io(&wait); 184 210 185 - if (!test_bit(BIO_UPTODATE, &bb.flags)) 186 - ret = -ENOTSUPP; 187 - 211 + if (bb.error) 212 + return bb.error; 188 213 return ret; 189 214 } 190 215 EXPORT_SYMBOL(blkdev_issue_write_same); ··· 209 236 DECLARE_COMPLETION_ONSTACK(wait); 210 237 211 238 atomic_set(&bb.done, 1); 212 - bb.flags = 1 << BIO_UPTODATE; 239 + bb.error = 0; 213 240 bb.wait = &wait; 214 241 215 242 ret = 0; ··· 243 270 if (!atomic_dec_and_test(&bb.done)) 244 271 wait_for_completion_io(&wait); 245 272 246 - if (!test_bit(BIO_UPTODATE, &bb.flags)) 247 - /* One of bios in the batch was completed with error.*/ 248 - ret = -EIO; 249 - 273 + if (bb.error) 274 + return bb.error; 250 275 return ret; 251 276 } 252 277
+2 -2
block/blk-map.c
··· 94 94 return PTR_ERR(bio); 95 95 96 96 if (map_data && map_data->null_mapped) 97 - bio->bi_flags |= (1 << BIO_NULL_MAPPED); 97 + bio_set_flag(bio, BIO_NULL_MAPPED); 98 98 99 99 if (bio->bi_iter.bi_size != iter->count) { 100 100 /* ··· 103 103 * normal IO completion path 104 104 */ 105 105 bio_get(bio); 106 - bio_endio(bio, 0); 106 + bio_endio(bio); 107 107 __blk_rq_unmap_user(bio); 108 108 return -EINVAL; 109 109 }
+144 -25
block/blk-merge.c
··· 9 9 10 10 #include "blk.h" 11 11 12 + static struct bio *blk_bio_discard_split(struct request_queue *q, 13 + struct bio *bio, 14 + struct bio_set *bs) 15 + { 16 + unsigned int max_discard_sectors, granularity; 17 + int alignment; 18 + sector_t tmp; 19 + unsigned split_sectors; 20 + 21 + /* Zero-sector (unknown) and one-sector granularities are the same. */ 22 + granularity = max(q->limits.discard_granularity >> 9, 1U); 23 + 24 + max_discard_sectors = min(q->limits.max_discard_sectors, UINT_MAX >> 9); 25 + max_discard_sectors -= max_discard_sectors % granularity; 26 + 27 + if (unlikely(!max_discard_sectors)) { 28 + /* XXX: warn */ 29 + return NULL; 30 + } 31 + 32 + if (bio_sectors(bio) <= max_discard_sectors) 33 + return NULL; 34 + 35 + split_sectors = max_discard_sectors; 36 + 37 + /* 38 + * If the next starting sector would be misaligned, stop the discard at 39 + * the previous aligned sector. 40 + */ 41 + alignment = (q->limits.discard_alignment >> 9) % granularity; 42 + 43 + tmp = bio->bi_iter.bi_sector + split_sectors - alignment; 44 + tmp = sector_div(tmp, granularity); 45 + 46 + if (split_sectors > tmp) 47 + split_sectors -= tmp; 48 + 49 + return bio_split(bio, split_sectors, GFP_NOIO, bs); 50 + } 51 + 52 + static struct bio *blk_bio_write_same_split(struct request_queue *q, 53 + struct bio *bio, 54 + struct bio_set *bs) 55 + { 56 + if (!q->limits.max_write_same_sectors) 57 + return NULL; 58 + 59 + if (bio_sectors(bio) <= q->limits.max_write_same_sectors) 60 + return NULL; 61 + 62 + return bio_split(bio, q->limits.max_write_same_sectors, GFP_NOIO, bs); 63 + } 64 + 65 + static struct bio *blk_bio_segment_split(struct request_queue *q, 66 + struct bio *bio, 67 + struct bio_set *bs) 68 + { 69 + struct bio *split; 70 + struct bio_vec bv, bvprv; 71 + struct bvec_iter iter; 72 + unsigned seg_size = 0, nsegs = 0, sectors = 0; 73 + int prev = 0; 74 + 75 + bio_for_each_segment(bv, bio, iter) { 76 + sectors += bv.bv_len >> 9; 77 + 78 + if (sectors > queue_max_sectors(q)) 79 + goto split; 80 + 81 + /* 82 + * If the queue doesn't support SG gaps and adding this 83 + * offset would create a gap, disallow it. 84 + */ 85 + if (prev && bvec_gap_to_prev(q, &bvprv, bv.bv_offset)) 86 + goto split; 87 + 88 + if (prev && blk_queue_cluster(q)) { 89 + if (seg_size + bv.bv_len > queue_max_segment_size(q)) 90 + goto new_segment; 91 + if (!BIOVEC_PHYS_MERGEABLE(&bvprv, &bv)) 92 + goto new_segment; 93 + if (!BIOVEC_SEG_BOUNDARY(q, &bvprv, &bv)) 94 + goto new_segment; 95 + 96 + seg_size += bv.bv_len; 97 + bvprv = bv; 98 + prev = 1; 99 + continue; 100 + } 101 + new_segment: 102 + if (nsegs == queue_max_segments(q)) 103 + goto split; 104 + 105 + nsegs++; 106 + bvprv = bv; 107 + prev = 1; 108 + seg_size = bv.bv_len; 109 + } 110 + 111 + return NULL; 112 + split: 113 + split = bio_clone_bioset(bio, GFP_NOIO, bs); 114 + 115 + split->bi_iter.bi_size -= iter.bi_size; 116 + bio->bi_iter = iter; 117 + 118 + if (bio_integrity(bio)) { 119 + bio_integrity_advance(bio, split->bi_iter.bi_size); 120 + bio_integrity_trim(split, 0, bio_sectors(split)); 121 + } 122 + 123 + return split; 124 + } 125 + 126 + void blk_queue_split(struct request_queue *q, struct bio **bio, 127 + struct bio_set *bs) 128 + { 129 + struct bio *split; 130 + 131 + if ((*bio)->bi_rw & REQ_DISCARD) 132 + split = blk_bio_discard_split(q, *bio, bs); 133 + else if ((*bio)->bi_rw & REQ_WRITE_SAME) 134 + split = blk_bio_write_same_split(q, *bio, bs); 135 + else 136 + split = blk_bio_segment_split(q, *bio, q->bio_split); 137 + 138 + if (split) { 139 + bio_chain(split, *bio); 140 + generic_make_request(*bio); 141 + *bio = split; 142 + } 143 + } 144 + EXPORT_SYMBOL(blk_queue_split); 145 + 12 146 static unsigned int __blk_recalc_rq_segments(struct request_queue *q, 13 147 struct bio *bio, 14 148 bool no_sg_merge) 15 149 { 16 150 struct bio_vec bv, bvprv = { NULL }; 17 - int cluster, high, highprv = 1; 151 + int cluster, prev = 0; 18 152 unsigned int seg_size, nr_phys_segs; 19 153 struct bio *fbio, *bbio; 20 154 struct bvec_iter iter; ··· 170 36 cluster = blk_queue_cluster(q); 171 37 seg_size = 0; 172 38 nr_phys_segs = 0; 173 - high = 0; 174 39 for_each_bio(bio) { 175 40 bio_for_each_segment(bv, bio, iter) { 176 41 /* ··· 179 46 if (no_sg_merge) 180 47 goto new_segment; 181 48 182 - /* 183 - * the trick here is making sure that a high page is 184 - * never considered part of another segment, since 185 - * that might change with the bounce page. 186 - */ 187 - high = page_to_pfn(bv.bv_page) > queue_bounce_pfn(q); 188 - if (!high && !highprv && cluster) { 49 + if (prev && cluster) { 189 50 if (seg_size + bv.bv_len 190 51 > queue_max_segment_size(q)) 191 52 goto new_segment; ··· 199 72 200 73 nr_phys_segs++; 201 74 bvprv = bv; 75 + prev = 1; 202 76 seg_size = bv.bv_len; 203 - highprv = high; 204 77 } 205 78 bbio = bio; 206 79 } ··· 243 116 bio->bi_next = nxt; 244 117 } 245 118 246 - bio->bi_flags |= (1 << BIO_SEG_VALID); 119 + bio_set_flag(bio, BIO_SEG_VALID); 247 120 } 248 121 EXPORT_SYMBOL(blk_recount_segments); 249 122 ··· 483 356 return !q->mq_ops && req->special; 484 357 } 485 358 486 - static int req_gap_to_prev(struct request *req, struct request *next) 359 + static int req_gap_to_prev(struct request *req, struct bio *next) 487 360 { 488 361 struct bio *prev = req->biotail; 489 362 490 - return bvec_gap_to_prev(&prev->bi_io_vec[prev->bi_vcnt - 1], 491 - next->bio->bi_io_vec[0].bv_offset); 363 + return bvec_gap_to_prev(req->q, &prev->bi_io_vec[prev->bi_vcnt - 1], 364 + next->bi_io_vec[0].bv_offset); 492 365 } 493 366 494 367 static int ll_merge_requests_fn(struct request_queue *q, struct request *req, ··· 505 378 if (req_no_special_merge(req) || req_no_special_merge(next)) 506 379 return 0; 507 380 508 - if (test_bit(QUEUE_FLAG_SG_GAPS, &q->queue_flags) && 509 - req_gap_to_prev(req, next)) 381 + if (req_gap_to_prev(req, next->bio)) 510 382 return 0; 511 383 512 384 /* ··· 690 564 691 565 bool blk_rq_merge_ok(struct request *rq, struct bio *bio) 692 566 { 693 - struct request_queue *q = rq->q; 694 - 695 567 if (!rq_mergeable(rq) || !bio_mergeable(bio)) 696 568 return false; 697 569 ··· 714 590 return false; 715 591 716 592 /* Only check gaps if the bio carries data */ 717 - if (q->queue_flags & (1 << QUEUE_FLAG_SG_GAPS) && bio_has_data(bio)) { 718 - struct bio_vec *bprev; 719 - 720 - bprev = &rq->biotail->bi_io_vec[rq->biotail->bi_vcnt - 1]; 721 - if (bvec_gap_to_prev(bprev, bio->bi_io_vec[0].bv_offset)) 722 - return false; 723 - } 593 + if (bio_has_data(bio) && req_gap_to_prev(rq, bio)) 594 + return false; 724 595 725 596 return true; 726 597 }
+16 -5
block/blk-mq-sysfs.c
··· 141 141 142 142 static ssize_t sysfs_list_show(char *page, struct list_head *list, char *msg) 143 143 { 144 - char *start_page = page; 145 144 struct request *rq; 145 + int len = snprintf(page, PAGE_SIZE - 1, "%s:\n", msg); 146 146 147 - page += sprintf(page, "%s:\n", msg); 147 + list_for_each_entry(rq, list, queuelist) { 148 + const int rq_len = 2 * sizeof(rq) + 2; 148 149 149 - list_for_each_entry(rq, list, queuelist) 150 - page += sprintf(page, "\t%p\n", rq); 150 + /* if the output will be truncated */ 151 + if (PAGE_SIZE - 1 < len + rq_len) { 152 + /* backspacing if it can't hold '\t...\n' */ 153 + if (PAGE_SIZE - 1 < len + 5) 154 + len -= rq_len; 155 + len += snprintf(page + len, PAGE_SIZE - 1 - len, 156 + "\t...\n"); 157 + break; 158 + } 159 + len += snprintf(page + len, PAGE_SIZE - 1 - len, 160 + "\t%p\n", rq); 161 + } 151 162 152 - return page - start_page; 163 + return len; 153 164 } 154 165 155 166 static ssize_t blk_mq_sysfs_rq_list_show(struct blk_mq_ctx *ctx, char *page)
+2 -2
block/blk-mq-tag.c
··· 429 429 for (bit = find_first_bit(&bm->word, bm->depth); 430 430 bit < bm->depth; 431 431 bit = find_next_bit(&bm->word, bm->depth, bit + 1)) { 432 - rq = blk_mq_tag_to_rq(hctx->tags, off + bit); 432 + rq = hctx->tags->rqs[off + bit]; 433 433 if (rq->q == hctx->queue) 434 434 fn(hctx, rq, data, reserved); 435 435 } ··· 453 453 for (bit = find_first_bit(&bm->word, bm->depth); 454 454 bit < bm->depth; 455 455 bit = find_next_bit(&bm->word, bm->depth, bit + 1)) { 456 - rq = blk_mq_tag_to_rq(tags, off + bit); 456 + rq = tags->rqs[off + bit]; 457 457 fn(rq, data, reserved); 458 458 } 459 459
+12
block/blk-mq-tag.h
··· 89 89 __blk_mq_tag_idle(hctx); 90 90 } 91 91 92 + /* 93 + * This helper should only be used for flush request to share tag 94 + * with the request cloned from, and both the two requests can't be 95 + * in flight at the same time. The caller has to make sure the tag 96 + * can't be freed. 97 + */ 98 + static inline void blk_mq_tag_set_rq(struct blk_mq_hw_ctx *hctx, 99 + unsigned int tag, struct request *rq) 100 + { 101 + hctx->tags->rqs[tag] = rq; 102 + } 103 + 92 104 #endif
+8 -18
block/blk-mq.c
··· 559 559 } 560 560 EXPORT_SYMBOL(blk_mq_abort_requeue_list); 561 561 562 - static inline bool is_flush_request(struct request *rq, 563 - struct blk_flush_queue *fq, unsigned int tag) 564 - { 565 - return ((rq->cmd_flags & REQ_FLUSH_SEQ) && 566 - fq->flush_rq->tag == tag); 567 - } 568 - 569 562 struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag) 570 563 { 571 - struct request *rq = tags->rqs[tag]; 572 - /* mq_ctx of flush rq is always cloned from the corresponding req */ 573 - struct blk_flush_queue *fq = blk_get_flush_queue(rq->q, rq->mq_ctx); 574 - 575 - if (!is_flush_request(rq, fq, tag)) 576 - return rq; 577 - 578 - return fq->flush_rq; 564 + return tags->rqs[tag]; 579 565 } 580 566 EXPORT_SYMBOL(blk_mq_tag_to_rq); 581 567 ··· 1185 1199 struct blk_mq_alloc_data alloc_data; 1186 1200 1187 1201 if (unlikely(blk_mq_queue_enter(q, GFP_KERNEL))) { 1188 - bio_endio(bio, -EIO); 1202 + bio_io_error(bio); 1189 1203 return NULL; 1190 1204 } 1191 1205 ··· 1269 1283 blk_queue_bounce(q, &bio); 1270 1284 1271 1285 if (bio_integrity_enabled(bio) && bio_integrity_prep(bio)) { 1272 - bio_endio(bio, -EIO); 1286 + bio_io_error(bio); 1273 1287 return; 1274 1288 } 1289 + 1290 + blk_queue_split(q, &bio, q->bio_split); 1275 1291 1276 1292 if (!is_flush_fua && !blk_queue_nomerges(q) && 1277 1293 blk_attempt_plug_merge(q, bio, &request_count, &same_queue_rq)) ··· 1356 1368 blk_queue_bounce(q, &bio); 1357 1369 1358 1370 if (bio_integrity_enabled(bio) && bio_integrity_prep(bio)) { 1359 - bio_endio(bio, -EIO); 1371 + bio_io_error(bio); 1360 1372 return; 1361 1373 } 1374 + 1375 + blk_queue_split(q, &bio, q->bio_split); 1362 1376 1363 1377 if (!is_flush_fua && !blk_queue_nomerges(q) && 1364 1378 blk_attempt_plug_merge(q, bio, &request_count, NULL))
+21 -23
block/blk-settings.c
··· 53 53 } 54 54 EXPORT_SYMBOL(blk_queue_unprep_rq); 55 55 56 - /** 57 - * blk_queue_merge_bvec - set a merge_bvec function for queue 58 - * @q: queue 59 - * @mbfn: merge_bvec_fn 60 - * 61 - * Usually queues have static limitations on the max sectors or segments that 62 - * we can put in a request. Stacking drivers may have some settings that 63 - * are dynamic, and thus we have to query the queue whether it is ok to 64 - * add a new bio_vec to a bio at a given offset or not. If the block device 65 - * has such limitations, it needs to register a merge_bvec_fn to control 66 - * the size of bio's sent to it. Note that a block device *must* allow a 67 - * single page to be added to an empty bio. The block device driver may want 68 - * to use the bio_split() function to deal with these bio's. By default 69 - * no merge_bvec_fn is defined for a queue, and only the fixed limits are 70 - * honored. 71 - */ 72 - void blk_queue_merge_bvec(struct request_queue *q, merge_bvec_fn *mbfn) 73 - { 74 - q->merge_bvec_fn = mbfn; 75 - } 76 - EXPORT_SYMBOL(blk_queue_merge_bvec); 77 - 78 56 void blk_queue_softirq_done(struct request_queue *q, softirq_done_fn *fn) 79 57 { 80 58 q->softirq_done_fn = fn; ··· 89 111 lim->max_segments = BLK_MAX_SEGMENTS; 90 112 lim->max_integrity_segments = 0; 91 113 lim->seg_boundary_mask = BLK_SEG_BOUNDARY_MASK; 114 + lim->virt_boundary_mask = 0; 92 115 lim->max_segment_size = BLK_MAX_SEGMENT_SIZE; 93 116 lim->max_sectors = lim->max_hw_sectors = BLK_SAFE_MAX_SECTORS; 94 117 lim->chunk_sectors = 0; 95 118 lim->max_write_same_sectors = 0; 96 119 lim->max_discard_sectors = 0; 120 + lim->max_hw_discard_sectors = 0; 97 121 lim->discard_granularity = 0; 98 122 lim->discard_alignment = 0; 99 123 lim->discard_misaligned = 0; ··· 237 257 __func__, max_hw_sectors); 238 258 } 239 259 240 - limits->max_sectors = limits->max_hw_sectors = max_hw_sectors; 260 + limits->max_hw_sectors = max_hw_sectors; 261 + limits->max_sectors = min_t(unsigned int, max_hw_sectors, 262 + BLK_DEF_MAX_SECTORS); 241 263 } 242 264 EXPORT_SYMBOL(blk_limits_max_hw_sectors); 243 265 ··· 285 303 void blk_queue_max_discard_sectors(struct request_queue *q, 286 304 unsigned int max_discard_sectors) 287 305 { 306 + q->limits.max_hw_discard_sectors = max_discard_sectors; 288 307 q->limits.max_discard_sectors = max_discard_sectors; 289 308 } 290 309 EXPORT_SYMBOL(blk_queue_max_discard_sectors); ··· 533 550 534 551 t->seg_boundary_mask = min_not_zero(t->seg_boundary_mask, 535 552 b->seg_boundary_mask); 553 + t->virt_boundary_mask = min_not_zero(t->virt_boundary_mask, 554 + b->virt_boundary_mask); 536 555 537 556 t->max_segments = min_not_zero(t->max_segments, b->max_segments); 538 557 t->max_integrity_segments = min_not_zero(t->max_integrity_segments, ··· 626 641 627 642 t->max_discard_sectors = min_not_zero(t->max_discard_sectors, 628 643 b->max_discard_sectors); 644 + t->max_hw_discard_sectors = min_not_zero(t->max_hw_discard_sectors, 645 + b->max_hw_discard_sectors); 629 646 t->discard_granularity = max(t->discard_granularity, 630 647 b->discard_granularity); 631 648 t->discard_alignment = lcm_not_zero(t->discard_alignment, alignment) % ··· 773 786 q->limits.seg_boundary_mask = mask; 774 787 } 775 788 EXPORT_SYMBOL(blk_queue_segment_boundary); 789 + 790 + /** 791 + * blk_queue_virt_boundary - set boundary rules for bio merging 792 + * @q: the request queue for the device 793 + * @mask: the memory boundary mask 794 + **/ 795 + void blk_queue_virt_boundary(struct request_queue *q, unsigned long mask) 796 + { 797 + q->limits.virt_boundary_mask = mask; 798 + } 799 + EXPORT_SYMBOL(blk_queue_virt_boundary); 776 800 777 801 /** 778 802 * blk_queue_dma_alignment - set dma length and memory alignment
+42 -1
block/blk-sysfs.c
··· 145 145 return queue_var_show(q->limits.discard_granularity, page); 146 146 } 147 147 148 + static ssize_t queue_discard_max_hw_show(struct request_queue *q, char *page) 149 + { 150 + unsigned long long val; 151 + 152 + val = q->limits.max_hw_discard_sectors << 9; 153 + return sprintf(page, "%llu\n", val); 154 + } 155 + 148 156 static ssize_t queue_discard_max_show(struct request_queue *q, char *page) 149 157 { 150 158 return sprintf(page, "%llu\n", 151 159 (unsigned long long)q->limits.max_discard_sectors << 9); 160 + } 161 + 162 + static ssize_t queue_discard_max_store(struct request_queue *q, 163 + const char *page, size_t count) 164 + { 165 + unsigned long max_discard; 166 + ssize_t ret = queue_var_store(&max_discard, page, count); 167 + 168 + if (ret < 0) 169 + return ret; 170 + 171 + if (max_discard & (q->limits.discard_granularity - 1)) 172 + return -EINVAL; 173 + 174 + max_discard >>= 9; 175 + if (max_discard > UINT_MAX) 176 + return -EINVAL; 177 + 178 + if (max_discard > q->limits.max_hw_discard_sectors) 179 + max_discard = q->limits.max_hw_discard_sectors; 180 + 181 + q->limits.max_discard_sectors = max_discard; 182 + return ret; 152 183 } 153 184 154 185 static ssize_t queue_discard_zeroes_data_show(struct request_queue *q, char *page) ··· 391 360 .show = queue_discard_granularity_show, 392 361 }; 393 362 363 + static struct queue_sysfs_entry queue_discard_max_hw_entry = { 364 + .attr = {.name = "discard_max_hw_bytes", .mode = S_IRUGO }, 365 + .show = queue_discard_max_hw_show, 366 + }; 367 + 394 368 static struct queue_sysfs_entry queue_discard_max_entry = { 395 - .attr = {.name = "discard_max_bytes", .mode = S_IRUGO }, 369 + .attr = {.name = "discard_max_bytes", .mode = S_IRUGO | S_IWUSR }, 396 370 .show = queue_discard_max_show, 371 + .store = queue_discard_max_store, 397 372 }; 398 373 399 374 static struct queue_sysfs_entry queue_discard_zeroes_data_entry = { ··· 458 421 &queue_io_opt_entry.attr, 459 422 &queue_discard_granularity_entry.attr, 460 423 &queue_discard_max_entry.attr, 424 + &queue_discard_max_hw_entry.attr, 461 425 &queue_discard_zeroes_data_entry.attr, 462 426 &queue_write_same_max_entry.attr, 463 427 &queue_nonrot_entry.attr, ··· 560 522 blk_mq_release(q); 561 523 562 524 blk_trace_shutdown(q); 525 + 526 + if (q->bio_split) 527 + bioset_free(q->bio_split); 563 528 564 529 ida_simple_remove(&blk_queue_ida, q->id); 565 530 call_rcu(&q->rcu_head, blk_free_queue_rcu);
+6
block/blk.h
··· 22 22 struct list_head flush_queue[2]; 23 23 struct list_head flush_data_in_flight; 24 24 struct request *flush_rq; 25 + 26 + /* 27 + * flush_rq shares tag with this rq, both can't be active 28 + * at the same time 29 + */ 30 + struct request *orig_rq; 25 31 spinlock_t mq_flush_lock; 26 32 }; 27 33
+15 -14
block/bounce.c
··· 123 123 } 124 124 } 125 125 126 - static void bounce_end_io(struct bio *bio, mempool_t *pool, int err) 126 + static void bounce_end_io(struct bio *bio, mempool_t *pool) 127 127 { 128 128 struct bio *bio_orig = bio->bi_private; 129 129 struct bio_vec *bvec, *org_vec; ··· 141 141 mempool_free(bvec->bv_page, pool); 142 142 } 143 143 144 - bio_endio(bio_orig, err); 144 + bio_orig->bi_error = bio->bi_error; 145 + bio_endio(bio_orig); 145 146 bio_put(bio); 146 147 } 147 148 148 - static void bounce_end_io_write(struct bio *bio, int err) 149 + static void bounce_end_io_write(struct bio *bio) 149 150 { 150 - bounce_end_io(bio, page_pool, err); 151 + bounce_end_io(bio, page_pool); 151 152 } 152 153 153 - static void bounce_end_io_write_isa(struct bio *bio, int err) 154 + static void bounce_end_io_write_isa(struct bio *bio) 154 155 { 155 156 156 - bounce_end_io(bio, isa_page_pool, err); 157 + bounce_end_io(bio, isa_page_pool); 157 158 } 158 159 159 - static void __bounce_end_io_read(struct bio *bio, mempool_t *pool, int err) 160 + static void __bounce_end_io_read(struct bio *bio, mempool_t *pool) 160 161 { 161 162 struct bio *bio_orig = bio->bi_private; 162 163 163 - if (test_bit(BIO_UPTODATE, &bio->bi_flags)) 164 + if (!bio->bi_error) 164 165 copy_to_high_bio_irq(bio_orig, bio); 165 166 166 - bounce_end_io(bio, pool, err); 167 + bounce_end_io(bio, pool); 167 168 } 168 169 169 - static void bounce_end_io_read(struct bio *bio, int err) 170 + static void bounce_end_io_read(struct bio *bio) 170 171 { 171 - __bounce_end_io_read(bio, page_pool, err); 172 + __bounce_end_io_read(bio, page_pool); 172 173 } 173 174 174 - static void bounce_end_io_read_isa(struct bio *bio, int err) 175 + static void bounce_end_io_read_isa(struct bio *bio) 175 176 { 176 - __bounce_end_io_read(bio, isa_page_pool, err); 177 + __bounce_end_io_read(bio, isa_page_pool); 177 178 } 178 179 179 180 #ifdef CONFIG_NEED_BOUNCE_POOL ··· 186 185 if (!bdi_cap_stable_pages_required(&q->backing_dev_info)) 187 186 return 0; 188 187 189 - return test_bit(BIO_SNAP_STABLE, &bio->bi_flags); 188 + return bio_flagged(bio, BIO_SNAP_STABLE); 190 189 } 191 190 #else 192 191 static int must_snapshot_stable_pages(struct request_queue *q, struct bio *bio)
+6 -3
block/genhd.c
··· 1110 1110 disk_release_events(disk); 1111 1111 kfree(disk->random); 1112 1112 disk_replace_part_tbl(disk, NULL); 1113 - free_part_stats(&disk->part0); 1114 - free_part_info(&disk->part0); 1113 + hd_free_part(&disk->part0); 1115 1114 if (disk->queue) 1116 1115 blk_put_queue(disk->queue); 1117 1116 kfree(disk); ··· 1284 1285 * converted to make use of bd_mutex and sequence counters. 1285 1286 */ 1286 1287 seqcount_init(&disk->part0.nr_sects_seq); 1287 - hd_ref_init(&disk->part0); 1288 + if (hd_ref_init(&disk->part0)) { 1289 + hd_free_part(&disk->part0); 1290 + kfree(disk); 1291 + return NULL; 1292 + } 1288 1293 1289 1294 disk->minors = minors; 1290 1295 rand_initialize_disk(disk);
+6 -6
block/partition-generic.c
··· 212 212 { 213 213 struct hd_struct *p = dev_to_part(dev); 214 214 blk_free_devt(dev->devt); 215 - free_part_stats(p); 216 - free_part_info(p); 215 + hd_free_part(p); 217 216 kfree(p); 218 217 } 219 218 ··· 232 233 put_device(part_to_dev(part)); 233 234 } 234 235 235 - void __delete_partition(struct hd_struct *part) 236 + void __delete_partition(struct percpu_ref *ref) 236 237 { 238 + struct hd_struct *part = container_of(ref, struct hd_struct, ref); 237 239 call_rcu(&part->rcu_head, delete_partition_rcu_cb); 238 240 } 239 241 ··· 255 255 kobject_put(part->holder_dir); 256 256 device_del(part_to_dev(part)); 257 257 258 - hd_struct_put(part); 258 + hd_struct_kill(part); 259 259 } 260 260 261 261 static ssize_t whole_disk_show(struct device *dev, ··· 356 356 if (!dev_get_uevent_suppress(ddev)) 357 357 kobject_uevent(&pdev->kobj, KOBJ_ADD); 358 358 359 - hd_ref_init(p); 360 - return p; 359 + if (!hd_ref_init(p)) 360 + return p; 361 361 362 362 out_free_info: 363 363 free_part_info(p);
+1 -1
drivers/block/aoe/aoeblk.c
··· 395 395 WARN_ON(d->flags & DEVFL_TKILL); 396 396 WARN_ON(d->gd); 397 397 WARN_ON(d->flags & DEVFL_UP); 398 - blk_queue_max_hw_sectors(q, 1024); 398 + blk_queue_max_hw_sectors(q, BLK_DEF_MAX_SECTORS); 399 399 q->backing_dev_info.name = "aoe"; 400 400 q->backing_dev_info.ra_pages = READ_AHEAD / PAGE_CACHE_SIZE; 401 401 d->bufpool = mp;
+5 -5
drivers/block/aoe/aoecmd.c
··· 1110 1110 d->ip.rq = NULL; 1111 1111 do { 1112 1112 bio = rq->bio; 1113 - bok = !fastfail && test_bit(BIO_UPTODATE, &bio->bi_flags); 1113 + bok = !fastfail && !bio->bi_error; 1114 1114 } while (__blk_end_request(rq, bok ? 0 : -EIO, bio->bi_iter.bi_size)); 1115 1115 1116 1116 /* cf. http://lkml.org/lkml/2006/10/31/28 */ ··· 1172 1172 ahout->cmdstat, ahin->cmdstat, 1173 1173 d->aoemajor, d->aoeminor); 1174 1174 noskb: if (buf) 1175 - clear_bit(BIO_UPTODATE, &buf->bio->bi_flags); 1175 + buf->bio->bi_error = -EIO; 1176 1176 goto out; 1177 1177 } 1178 1178 ··· 1185 1185 "aoe: runt data size in read from", 1186 1186 (long) d->aoemajor, d->aoeminor, 1187 1187 skb->len, n); 1188 - clear_bit(BIO_UPTODATE, &buf->bio->bi_flags); 1188 + buf->bio->bi_error = -EIO; 1189 1189 break; 1190 1190 } 1191 1191 if (n > f->iter.bi_size) { ··· 1193 1193 "aoe: too-large data size in read from", 1194 1194 (long) d->aoemajor, d->aoeminor, 1195 1195 n, f->iter.bi_size); 1196 - clear_bit(BIO_UPTODATE, &buf->bio->bi_flags); 1196 + buf->bio->bi_error = -EIO; 1197 1197 break; 1198 1198 } 1199 1199 bvcpy(skb, f->buf->bio, f->iter, n); ··· 1695 1695 if (buf == NULL) 1696 1696 return; 1697 1697 buf->iter.bi_size = 0; 1698 - clear_bit(BIO_UPTODATE, &buf->bio->bi_flags); 1698 + buf->bio->bi_error = -EIO; 1699 1699 if (buf->nframesout == 0) 1700 1700 aoe_end_buf(d, buf); 1701 1701 }
+1 -1
drivers/block/aoe/aoedev.c
··· 170 170 if (rq == NULL) 171 171 return; 172 172 while ((bio = d->ip.nxbio)) { 173 - clear_bit(BIO_UPTODATE, &bio->bi_flags); 173 + bio->bi_error = -EIO; 174 174 d->ip.nxbio = bio->bi_next; 175 175 n = (unsigned long) rq->special; 176 176 rq->special = (void *) --n;
+9 -6
drivers/block/brd.c
··· 331 331 struct bio_vec bvec; 332 332 sector_t sector; 333 333 struct bvec_iter iter; 334 - int err = -EIO; 335 334 336 335 sector = bio->bi_iter.bi_sector; 337 336 if (bio_end_sector(bio) > get_capacity(bdev->bd_disk)) 338 - goto out; 337 + goto io_error; 339 338 340 339 if (unlikely(bio->bi_rw & REQ_DISCARD)) { 341 - err = 0; 342 340 discard_from_brd(brd, sector, bio->bi_iter.bi_size); 343 341 goto out; 344 342 } ··· 347 349 348 350 bio_for_each_segment(bvec, bio, iter) { 349 351 unsigned int len = bvec.bv_len; 352 + int err; 353 + 350 354 err = brd_do_bvec(brd, bvec.bv_page, len, 351 355 bvec.bv_offset, rw, sector); 352 356 if (err) 353 - break; 357 + goto io_error; 354 358 sector += len >> SECTOR_SHIFT; 355 359 } 356 360 357 361 out: 358 - bio_endio(bio, err); 362 + bio_endio(bio); 363 + return; 364 + io_error: 365 + bio_io_error(bio); 359 366 } 360 367 361 368 static int brd_rw_page(struct block_device *bdev, sector_t sector, ··· 503 500 blk_queue_physical_block_size(brd->brd_queue, PAGE_SIZE); 504 501 505 502 brd->brd_queue->limits.discard_granularity = PAGE_SIZE; 506 - brd->brd_queue->limits.max_discard_sectors = UINT_MAX; 503 + blk_queue_max_discard_sectors(brd->brd_queue, UINT_MAX); 507 504 brd->brd_queue->limits.discard_zeroes_data = 1; 508 505 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, brd->brd_queue); 509 506
+2 -2
drivers/block/drbd/drbd_actlog.c
··· 175 175 atomic_inc(&device->md_io.in_use); /* drbd_md_put_buffer() is in the completion handler */ 176 176 device->md_io.submit_jif = jiffies; 177 177 if (drbd_insert_fault(device, (rw & WRITE) ? DRBD_FAULT_MD_WR : DRBD_FAULT_MD_RD)) 178 - bio_endio(bio, -EIO); 178 + bio_io_error(bio); 179 179 else 180 180 submit_bio(rw, bio); 181 181 wait_until_done_or_force_detached(device, bdev, &device->md_io.done); 182 - if (bio_flagged(bio, BIO_UPTODATE)) 182 + if (!bio->bi_error) 183 183 err = device->md_io.error; 184 184 185 185 out:
+5 -14
drivers/block/drbd/drbd_bitmap.c
··· 941 941 } 942 942 943 943 /* bv_page may be a copy, or may be the original */ 944 - static void drbd_bm_endio(struct bio *bio, int error) 944 + static void drbd_bm_endio(struct bio *bio) 945 945 { 946 946 struct drbd_bm_aio_ctx *ctx = bio->bi_private; 947 947 struct drbd_device *device = ctx->device; 948 948 struct drbd_bitmap *b = device->bitmap; 949 949 unsigned int idx = bm_page_to_idx(bio->bi_io_vec[0].bv_page); 950 - int uptodate = bio_flagged(bio, BIO_UPTODATE); 951 - 952 - 953 - /* strange behavior of some lower level drivers... 954 - * fail the request by clearing the uptodate flag, 955 - * but do not return any error?! 956 - * do we want to WARN() on this? */ 957 - if (!error && !uptodate) 958 - error = -EIO; 959 950 960 951 if ((ctx->flags & BM_AIO_COPY_PAGES) == 0 && 961 952 !bm_test_page_unchanged(b->bm_pages[idx])) 962 953 drbd_warn(device, "bitmap page idx %u changed during IO!\n", idx); 963 954 964 - if (error) { 955 + if (bio->bi_error) { 965 956 /* ctx error will hold the completed-last non-zero error code, 966 957 * in case error codes differ. */ 967 - ctx->error = error; 958 + ctx->error = bio->bi_error; 968 959 bm_set_page_io_err(b->bm_pages[idx]); 969 960 /* Not identical to on disk version of it. 970 961 * Is BM_PAGE_IO_ERROR enough? */ 971 962 if (__ratelimit(&drbd_ratelimit_state)) 972 963 drbd_err(device, "IO ERROR %d on bitmap page idx %u\n", 973 - error, idx); 964 + bio->bi_error, idx); 974 965 } else { 975 966 bm_clear_page_io_err(b->bm_pages[idx]); 976 967 dynamic_drbd_dbg(device, "bitmap page idx %u completed\n", idx); ··· 1022 1031 1023 1032 if (drbd_insert_fault(device, (rw & WRITE) ? DRBD_FAULT_MD_WR : DRBD_FAULT_MD_RD)) { 1024 1033 bio->bi_rw |= rw; 1025 - bio_endio(bio, -EIO); 1034 + bio_io_error(bio); 1026 1035 } else { 1027 1036 submit_bio(rw, bio); 1028 1037 /* this should not count as user activity and cause the
+6 -6
drivers/block/drbd/drbd_int.h
··· 1450 1450 extern void __drbd_make_request(struct drbd_device *, struct bio *, unsigned long); 1451 1451 extern void drbd_make_request(struct request_queue *q, struct bio *bio); 1452 1452 extern int drbd_read_remote(struct drbd_device *device, struct drbd_request *req); 1453 - extern int drbd_merge_bvec(struct request_queue *q, struct bvec_merge_data *bvm, struct bio_vec *bvec); 1454 1453 extern int is_valid_ar_handle(struct drbd_request *, sector_t); 1455 1454 1456 1455 ··· 1480 1481 1481 1482 /* drbd_worker.c */ 1482 1483 /* bi_end_io handlers */ 1483 - extern void drbd_md_endio(struct bio *bio, int error); 1484 - extern void drbd_peer_request_endio(struct bio *bio, int error); 1485 - extern void drbd_request_endio(struct bio *bio, int error); 1484 + extern void drbd_md_endio(struct bio *bio); 1485 + extern void drbd_peer_request_endio(struct bio *bio); 1486 + extern void drbd_request_endio(struct bio *bio); 1486 1487 extern int drbd_worker(struct drbd_thread *thi); 1487 1488 enum drbd_ret_code drbd_resync_after_valid(struct drbd_device *device, int o_minor); 1488 1489 void drbd_resync_after_changed(struct drbd_device *device); ··· 1603 1604 __release(local); 1604 1605 if (!bio->bi_bdev) { 1605 1606 drbd_err(device, "drbd_generic_make_request: bio->bi_bdev == NULL\n"); 1606 - bio_endio(bio, -ENODEV); 1607 + bio->bi_error = -ENODEV; 1608 + bio_endio(bio); 1607 1609 return; 1608 1610 } 1609 1611 1610 1612 if (drbd_insert_fault(device, fault_type)) 1611 - bio_endio(bio, -EIO); 1613 + bio_io_error(bio); 1612 1614 else 1613 1615 generic_make_request(bio); 1614 1616 }
-1
drivers/block/drbd/drbd_main.c
··· 2774 2774 This triggers a max_bio_size message upon first attach or connect */ 2775 2775 blk_queue_max_hw_sectors(q, DRBD_MAX_BIO_SIZE_SAFE >> 8); 2776 2776 blk_queue_bounce_limit(q, BLK_BOUNCE_ANY); 2777 - blk_queue_merge_bvec(q, drbd_merge_bvec); 2778 2777 q->queue_lock = &resource->req_lock; 2779 2778 2780 2779 device->md_io.page = alloc_page(GFP_KERNEL);
+2 -2
drivers/block/drbd/drbd_nl.c
··· 1156 1156 /* For now, don't allow more than one activity log extent worth of data 1157 1157 * to be discarded in one go. We may need to rework drbd_al_begin_io() 1158 1158 * to allow for even larger discard ranges */ 1159 - q->limits.max_discard_sectors = DRBD_MAX_DISCARD_SECTORS; 1159 + blk_queue_max_discard_sectors(q, DRBD_MAX_DISCARD_SECTORS); 1160 1160 1161 1161 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); 1162 1162 /* REALLY? Is stacking secdiscard "legal"? */ 1163 1163 if (blk_queue_secdiscard(b)) 1164 1164 queue_flag_set_unlocked(QUEUE_FLAG_SECDISCARD, q); 1165 1165 } else { 1166 - q->limits.max_discard_sectors = 0; 1166 + blk_queue_max_discard_sectors(q, 0); 1167 1167 queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, q); 1168 1168 queue_flag_clear_unlocked(QUEUE_FLAG_SECDISCARD, q); 1169 1169 }
+8 -39
drivers/block/drbd/drbd_req.c
··· 201 201 void complete_master_bio(struct drbd_device *device, 202 202 struct bio_and_error *m) 203 203 { 204 - bio_endio(m->bio, m->error); 204 + m->bio->bi_error = m->error; 205 + bio_endio(m->bio); 205 206 dec_ap_bio(device); 206 207 } 207 208 ··· 1154 1153 rw == WRITE ? DRBD_FAULT_DT_WR 1155 1154 : rw == READ ? DRBD_FAULT_DT_RD 1156 1155 : DRBD_FAULT_DT_RA)) 1157 - bio_endio(bio, -EIO); 1156 + bio_io_error(bio); 1158 1157 else 1159 1158 generic_make_request(bio); 1160 1159 put_ldev(device); 1161 1160 } else 1162 - bio_endio(bio, -EIO); 1161 + bio_io_error(bio); 1163 1162 } 1164 1163 1165 1164 static void drbd_queue_write(struct drbd_device *device, struct drbd_request *req) ··· 1192 1191 /* only pass the error to the upper layers. 1193 1192 * if user cannot handle io errors, that's not our business. */ 1194 1193 drbd_err(device, "could not kmalloc() req\n"); 1195 - bio_endio(bio, -ENOMEM); 1194 + bio->bi_error = -ENOMEM; 1195 + bio_endio(bio); 1196 1196 return ERR_PTR(-ENOMEM); 1197 1197 } 1198 1198 req->start_jif = start_jif; ··· 1499 1497 struct drbd_device *device = (struct drbd_device *) q->queuedata; 1500 1498 unsigned long start_jif; 1501 1499 1500 + blk_queue_split(q, &bio, q->bio_split); 1501 + 1502 1502 start_jif = jiffies; 1503 1503 1504 1504 /* ··· 1510 1506 1511 1507 inc_ap_bio(device); 1512 1508 __drbd_make_request(device, bio, start_jif); 1513 - } 1514 - 1515 - /* This is called by bio_add_page(). 1516 - * 1517 - * q->max_hw_sectors and other global limits are already enforced there. 1518 - * 1519 - * We need to call down to our lower level device, 1520 - * in case it has special restrictions. 1521 - * 1522 - * We also may need to enforce configured max-bio-bvecs limits. 1523 - * 1524 - * As long as the BIO is empty we have to allow at least one bvec, 1525 - * regardless of size and offset, so no need to ask lower levels. 1526 - */ 1527 - int drbd_merge_bvec(struct request_queue *q, struct bvec_merge_data *bvm, struct bio_vec *bvec) 1528 - { 1529 - struct drbd_device *device = (struct drbd_device *) q->queuedata; 1530 - unsigned int bio_size = bvm->bi_size; 1531 - int limit = DRBD_MAX_BIO_SIZE; 1532 - int backing_limit; 1533 - 1534 - if (bio_size && get_ldev(device)) { 1535 - unsigned int max_hw_sectors = queue_max_hw_sectors(q); 1536 - struct request_queue * const b = 1537 - device->ldev->backing_bdev->bd_disk->queue; 1538 - if (b->merge_bvec_fn) { 1539 - bvm->bi_bdev = device->ldev->backing_bdev; 1540 - backing_limit = b->merge_bvec_fn(b, bvm, bvec); 1541 - limit = min(limit, backing_limit); 1542 - } 1543 - put_ldev(device); 1544 - if ((limit >> 9) > max_hw_sectors) 1545 - limit = max_hw_sectors << 9; 1546 - } 1547 - return limit; 1548 1509 } 1549 1510 1550 1511 void request_timer_fn(unsigned long data)
+11 -33
drivers/block/drbd/drbd_worker.c
··· 65 65 /* used for synchronous meta data and bitmap IO 66 66 * submitted by drbd_md_sync_page_io() 67 67 */ 68 - void drbd_md_endio(struct bio *bio, int error) 68 + void drbd_md_endio(struct bio *bio) 69 69 { 70 70 struct drbd_device *device; 71 71 72 72 device = bio->bi_private; 73 - device->md_io.error = error; 73 + device->md_io.error = bio->bi_error; 74 74 75 75 /* We grabbed an extra reference in _drbd_md_sync_page_io() to be able 76 76 * to timeout on the lower level device, and eventually detach from it. ··· 170 170 /* writes on behalf of the partner, or resync writes, 171 171 * "submitted" by the receiver. 172 172 */ 173 - void drbd_peer_request_endio(struct bio *bio, int error) 173 + void drbd_peer_request_endio(struct bio *bio) 174 174 { 175 175 struct drbd_peer_request *peer_req = bio->bi_private; 176 176 struct drbd_device *device = peer_req->peer_device->device; 177 - int uptodate = bio_flagged(bio, BIO_UPTODATE); 178 177 int is_write = bio_data_dir(bio) == WRITE; 179 178 int is_discard = !!(bio->bi_rw & REQ_DISCARD); 180 179 181 - if (error && __ratelimit(&drbd_ratelimit_state)) 180 + if (bio->bi_error && __ratelimit(&drbd_ratelimit_state)) 182 181 drbd_warn(device, "%s: error=%d s=%llus\n", 183 182 is_write ? (is_discard ? "discard" : "write") 184 - : "read", error, 183 + : "read", bio->bi_error, 185 184 (unsigned long long)peer_req->i.sector); 186 - if (!error && !uptodate) { 187 - if (__ratelimit(&drbd_ratelimit_state)) 188 - drbd_warn(device, "%s: setting error to -EIO s=%llus\n", 189 - is_write ? "write" : "read", 190 - (unsigned long long)peer_req->i.sector); 191 - /* strange behavior of some lower level drivers... 192 - * fail the request by clearing the uptodate flag, 193 - * but do not return any error?! */ 194 - error = -EIO; 195 - } 196 185 197 - if (error) 186 + if (bio->bi_error) 198 187 set_bit(__EE_WAS_ERROR, &peer_req->flags); 199 188 200 189 bio_put(bio); /* no need for the bio anymore */ ··· 197 208 198 209 /* read, readA or write requests on R_PRIMARY coming from drbd_make_request 199 210 */ 200 - void drbd_request_endio(struct bio *bio, int error) 211 + void drbd_request_endio(struct bio *bio) 201 212 { 202 213 unsigned long flags; 203 214 struct drbd_request *req = bio->bi_private; 204 215 struct drbd_device *device = req->device; 205 216 struct bio_and_error m; 206 217 enum drbd_req_event what; 207 - int uptodate = bio_flagged(bio, BIO_UPTODATE); 208 - 209 - if (!error && !uptodate) { 210 - drbd_warn(device, "p %s: setting error to -EIO\n", 211 - bio_data_dir(bio) == WRITE ? "write" : "read"); 212 - /* strange behavior of some lower level drivers... 213 - * fail the request by clearing the uptodate flag, 214 - * but do not return any error?! */ 215 - error = -EIO; 216 - } 217 - 218 218 219 219 /* If this request was aborted locally before, 220 220 * but now was completed "successfully", ··· 237 259 if (__ratelimit(&drbd_ratelimit_state)) 238 260 drbd_emerg(device, "delayed completion of aborted local request; disk-timeout may be too aggressive\n"); 239 261 240 - if (!error) 262 + if (!bio->bi_error) 241 263 panic("possible random memory corruption caused by delayed completion of aborted local request\n"); 242 264 } 243 265 244 266 /* to avoid recursion in __req_mod */ 245 - if (unlikely(error)) { 267 + if (unlikely(bio->bi_error)) { 246 268 if (bio->bi_rw & REQ_DISCARD) 247 - what = (error == -EOPNOTSUPP) 269 + what = (bio->bi_error == -EOPNOTSUPP) 248 270 ? DISCARD_COMPLETED_NOTSUPP 249 271 : DISCARD_COMPLETED_WITH_ERROR; 250 272 else ··· 257 279 what = COMPLETED_OK; 258 280 259 281 bio_put(req->private_bio); 260 - req->private_bio = ERR_PTR(error); 282 + req->private_bio = ERR_PTR(bio->bi_error); 261 283 262 284 /* not req_mod(), we need irqsave here! */ 263 285 spin_lock_irqsave(&device->resource->req_lock, flags);
+4 -3
drivers/block/floppy.c
··· 3771 3771 struct completion complete; 3772 3772 }; 3773 3773 3774 - static void floppy_rb0_cb(struct bio *bio, int err) 3774 + static void floppy_rb0_cb(struct bio *bio) 3775 3775 { 3776 3776 struct rb0_cbdata *cbdata = (struct rb0_cbdata *)bio->bi_private; 3777 3777 int drive = cbdata->drive; 3778 3778 3779 - if (err) { 3780 - pr_info("floppy: error %d while reading block 0\n", err); 3779 + if (bio->bi_error) { 3780 + pr_info("floppy: error %d while reading block 0\n", 3781 + bio->bi_error); 3781 3782 set_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags); 3782 3783 } 3783 3784 complete(&cbdata->complete);
+2 -2
drivers/block/loop.c
··· 675 675 lo->lo_encrypt_key_size) { 676 676 q->limits.discard_granularity = 0; 677 677 q->limits.discard_alignment = 0; 678 - q->limits.max_discard_sectors = 0; 678 + blk_queue_max_discard_sectors(q, 0); 679 679 q->limits.discard_zeroes_data = 0; 680 680 queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, q); 681 681 return; ··· 683 683 684 684 q->limits.discard_granularity = inode->i_sb->s_blocksize; 685 685 q->limits.discard_alignment = 0; 686 - q->limits.max_discard_sectors = UINT_MAX >> 9; 686 + blk_queue_max_discard_sectors(q, UINT_MAX >> 9); 687 687 q->limits.discard_zeroes_data = 1; 688 688 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); 689 689 }
+1 -1
drivers/block/nbd.c
··· 822 822 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, disk->queue); 823 823 queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, disk->queue); 824 824 disk->queue->limits.discard_granularity = 512; 825 - disk->queue->limits.max_discard_sectors = UINT_MAX; 825 + blk_queue_max_discard_sectors(disk->queue, UINT_MAX); 826 826 disk->queue->limits.discard_zeroes_data = 0; 827 827 blk_queue_max_hw_sectors(disk->queue, 65536); 828 828 disk->queue->limits.max_sectors = 256;
+1 -1
drivers/block/null_blk.c
··· 222 222 blk_end_request_all(cmd->rq, 0); 223 223 break; 224 224 case NULL_Q_BIO: 225 - bio_endio(cmd->bio, 0); 225 + bio_endio(cmd->bio); 226 226 break; 227 227 } 228 228
+2 -2
drivers/block/nvme-core.c
··· 1935 1935 ns->queue->limits.discard_zeroes_data = 0; 1936 1936 ns->queue->limits.discard_alignment = logical_block_size; 1937 1937 ns->queue->limits.discard_granularity = logical_block_size; 1938 - ns->queue->limits.max_discard_sectors = 0xffffffff; 1938 + blk_queue_max_discard_sectors(ns->queue, 0xffffffff); 1939 1939 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, ns->queue); 1940 1940 } 1941 1941 ··· 2067 2067 goto out_free_ns; 2068 2068 queue_flag_set_unlocked(QUEUE_FLAG_NOMERGES, ns->queue); 2069 2069 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, ns->queue); 2070 - queue_flag_set_unlocked(QUEUE_FLAG_SG_GAPS, ns->queue); 2071 2070 ns->dev = dev; 2072 2071 ns->queue->queuedata = ns; 2073 2072 ··· 2086 2087 blk_queue_chunk_sectors(ns->queue, dev->stripe_size >> 9); 2087 2088 if (dev->vwc & NVME_CTRL_VWC_PRESENT) 2088 2089 blk_queue_flush(ns->queue, REQ_FLUSH | REQ_FUA); 2090 + blk_queue_virt_boundary(ns->queue, dev->page_size - 1); 2089 2091 2090 2092 disk->major = nvme_major; 2091 2093 disk->first_minor = 0;
+20 -39
drivers/block/pktcdvd.c
··· 977 977 } 978 978 } 979 979 980 - static void pkt_end_io_read(struct bio *bio, int err) 980 + static void pkt_end_io_read(struct bio *bio) 981 981 { 982 982 struct packet_data *pkt = bio->bi_private; 983 983 struct pktcdvd_device *pd = pkt->pd; ··· 985 985 986 986 pkt_dbg(2, pd, "bio=%p sec0=%llx sec=%llx err=%d\n", 987 987 bio, (unsigned long long)pkt->sector, 988 - (unsigned long long)bio->bi_iter.bi_sector, err); 988 + (unsigned long long)bio->bi_iter.bi_sector, bio->bi_error); 989 989 990 - if (err) 990 + if (bio->bi_error) 991 991 atomic_inc(&pkt->io_errors); 992 992 if (atomic_dec_and_test(&pkt->io_wait)) { 993 993 atomic_inc(&pkt->run_sm); ··· 996 996 pkt_bio_finished(pd); 997 997 } 998 998 999 - static void pkt_end_io_packet_write(struct bio *bio, int err) 999 + static void pkt_end_io_packet_write(struct bio *bio) 1000 1000 { 1001 1001 struct packet_data *pkt = bio->bi_private; 1002 1002 struct pktcdvd_device *pd = pkt->pd; 1003 1003 BUG_ON(!pd); 1004 1004 1005 - pkt_dbg(2, pd, "id=%d, err=%d\n", pkt->id, err); 1005 + pkt_dbg(2, pd, "id=%d, err=%d\n", pkt->id, bio->bi_error); 1006 1006 1007 1007 pd->stats.pkt_ended++; 1008 1008 ··· 1340 1340 pkt_queue_bio(pd, pkt->w_bio); 1341 1341 } 1342 1342 1343 - static void pkt_finish_packet(struct packet_data *pkt, int uptodate) 1343 + static void pkt_finish_packet(struct packet_data *pkt, int error) 1344 1344 { 1345 1345 struct bio *bio; 1346 1346 1347 - if (!uptodate) 1347 + if (error) 1348 1348 pkt->cache_valid = 0; 1349 1349 1350 1350 /* Finish all bios corresponding to this packet */ 1351 - while ((bio = bio_list_pop(&pkt->orig_bios))) 1352 - bio_endio(bio, uptodate ? 0 : -EIO); 1351 + while ((bio = bio_list_pop(&pkt->orig_bios))) { 1352 + bio->bi_error = error; 1353 + bio_endio(bio); 1354 + } 1353 1355 } 1354 1356 1355 1357 static void pkt_run_state_machine(struct pktcdvd_device *pd, struct packet_data *pkt) 1356 1358 { 1357 - int uptodate; 1358 - 1359 1359 pkt_dbg(2, pd, "pkt %d\n", pkt->id); 1360 1360 1361 1361 for (;;) { ··· 1384 1384 if (atomic_read(&pkt->io_wait) > 0) 1385 1385 return; 1386 1386 1387 - if (test_bit(BIO_UPTODATE, &pkt->w_bio->bi_flags)) { 1387 + if (!pkt->w_bio->bi_error) { 1388 1388 pkt_set_state(pkt, PACKET_FINISHED_STATE); 1389 1389 } else { 1390 1390 pkt_set_state(pkt, PACKET_RECOVERY_STATE); ··· 1401 1401 break; 1402 1402 1403 1403 case PACKET_FINISHED_STATE: 1404 - uptodate = test_bit(BIO_UPTODATE, &pkt->w_bio->bi_flags); 1405 - pkt_finish_packet(pkt, uptodate); 1404 + pkt_finish_packet(pkt, pkt->w_bio->bi_error); 1406 1405 return; 1407 1406 1408 1407 default: ··· 2331 2332 } 2332 2333 2333 2334 2334 - static void pkt_end_io_read_cloned(struct bio *bio, int err) 2335 + static void pkt_end_io_read_cloned(struct bio *bio) 2335 2336 { 2336 2337 struct packet_stacked_data *psd = bio->bi_private; 2337 2338 struct pktcdvd_device *pd = psd->pd; 2338 2339 2340 + psd->bio->bi_error = bio->bi_error; 2339 2341 bio_put(bio); 2340 - bio_endio(psd->bio, err); 2342 + bio_endio(psd->bio); 2341 2343 mempool_free(psd, psd_pool); 2342 2344 pkt_bio_finished(pd); 2343 2345 } ··· 2447 2447 char b[BDEVNAME_SIZE]; 2448 2448 struct bio *split; 2449 2449 2450 + blk_queue_bounce(q, &bio); 2451 + 2452 + blk_queue_split(q, &bio, q->bio_split); 2453 + 2450 2454 pd = q->queuedata; 2451 2455 if (!pd) { 2452 2456 pr_err("%s incorrect request queue\n", ··· 2481 2477 goto end_io; 2482 2478 } 2483 2479 2484 - blk_queue_bounce(q, &bio); 2485 - 2486 2480 do { 2487 2481 sector_t zone = get_zone(bio->bi_iter.bi_sector, pd); 2488 2482 sector_t last_zone = get_zone(bio_end_sector(bio) - 1, pd); ··· 2506 2504 2507 2505 2508 2506 2509 - static int pkt_merge_bvec(struct request_queue *q, struct bvec_merge_data *bmd, 2510 - struct bio_vec *bvec) 2511 - { 2512 - struct pktcdvd_device *pd = q->queuedata; 2513 - sector_t zone = get_zone(bmd->bi_sector, pd); 2514 - int used = ((bmd->bi_sector - zone) << 9) + bmd->bi_size; 2515 - int remaining = (pd->settings.size << 9) - used; 2516 - int remaining2; 2517 - 2518 - /* 2519 - * A bio <= PAGE_SIZE must be allowed. If it crosses a packet 2520 - * boundary, pkt_make_request() will split the bio. 2521 - */ 2522 - remaining2 = PAGE_SIZE - bmd->bi_size; 2523 - remaining = max(remaining, remaining2); 2524 - 2525 - BUG_ON(remaining < 0); 2526 - return remaining; 2527 - } 2528 - 2529 2507 static void pkt_init_queue(struct pktcdvd_device *pd) 2530 2508 { 2531 2509 struct request_queue *q = pd->disk->queue; ··· 2513 2531 blk_queue_make_request(q, pkt_make_request); 2514 2532 blk_queue_logical_block_size(q, CD_FRAMESIZE); 2515 2533 blk_queue_max_hw_sectors(q, PACKET_MAX_SECTORS); 2516 - blk_queue_merge_bvec(q, pkt_merge_bvec); 2517 2534 q->queuedata = pd; 2518 2535 } 2519 2536
+4 -1
drivers/block/ps3vram.c
··· 593 593 next = bio_list_peek(&priv->list); 594 594 spin_unlock_irq(&priv->lock); 595 595 596 - bio_endio(bio, error); 596 + bio->bi_error = error; 597 + bio_endio(bio); 597 598 return next; 598 599 } 599 600 ··· 605 604 int busy; 606 605 607 606 dev_dbg(&dev->core, "%s\n", __func__); 607 + 608 + blk_queue_split(q, &bio, q->bio_split); 608 609 609 610 spin_lock_irq(&priv->lock); 610 611 busy = !bio_list_empty(&priv->list);
+1 -48
drivers/block/rbd.c
··· 3474 3474 return BLK_MQ_RQ_QUEUE_OK; 3475 3475 } 3476 3476 3477 - /* 3478 - * a queue callback. Makes sure that we don't create a bio that spans across 3479 - * multiple osd objects. One exception would be with a single page bios, 3480 - * which we handle later at bio_chain_clone_range() 3481 - */ 3482 - static int rbd_merge_bvec(struct request_queue *q, struct bvec_merge_data *bmd, 3483 - struct bio_vec *bvec) 3484 - { 3485 - struct rbd_device *rbd_dev = q->queuedata; 3486 - sector_t sector_offset; 3487 - sector_t sectors_per_obj; 3488 - sector_t obj_sector_offset; 3489 - int ret; 3490 - 3491 - /* 3492 - * Find how far into its rbd object the partition-relative 3493 - * bio start sector is to offset relative to the enclosing 3494 - * device. 3495 - */ 3496 - sector_offset = get_start_sect(bmd->bi_bdev) + bmd->bi_sector; 3497 - sectors_per_obj = 1 << (rbd_dev->header.obj_order - SECTOR_SHIFT); 3498 - obj_sector_offset = sector_offset & (sectors_per_obj - 1); 3499 - 3500 - /* 3501 - * Compute the number of bytes from that offset to the end 3502 - * of the object. Account for what's already used by the bio. 3503 - */ 3504 - ret = (int) (sectors_per_obj - obj_sector_offset) << SECTOR_SHIFT; 3505 - if (ret > bmd->bi_size) 3506 - ret -= bmd->bi_size; 3507 - else 3508 - ret = 0; 3509 - 3510 - /* 3511 - * Don't send back more than was asked for. And if the bio 3512 - * was empty, let the whole thing through because: "Note 3513 - * that a block device *must* allow a single page to be 3514 - * added to an empty bio." 3515 - */ 3516 - rbd_assert(bvec->bv_len <= PAGE_SIZE); 3517 - if (ret > (int) bvec->bv_len || !bmd->bi_size) 3518 - ret = (int) bvec->bv_len; 3519 - 3520 - return ret; 3521 - } 3522 - 3523 3477 static void rbd_free_disk(struct rbd_device *rbd_dev) 3524 3478 { 3525 3479 struct gendisk *disk = rbd_dev->disk; ··· 3769 3815 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); 3770 3816 q->limits.discard_granularity = segment_size; 3771 3817 q->limits.discard_alignment = segment_size; 3772 - q->limits.max_discard_sectors = segment_size / SECTOR_SIZE; 3818 + blk_queue_max_discard_sectors(q, segment_size / SECTOR_SIZE); 3773 3819 q->limits.discard_zeroes_data = 1; 3774 3820 3775 - blk_queue_merge_bvec(q, rbd_merge_bvec); 3776 3821 disk->queue = q; 3777 3822 3778 3823 q->queuedata = rbd_dev;
+9 -2
drivers/block/rsxx/dev.c
··· 137 137 if (!card->eeh_state && card->gendisk) 138 138 disk_stats_complete(card, meta->bio, meta->start_time); 139 139 140 - bio_endio(meta->bio, atomic_read(&meta->error) ? -EIO : 0); 140 + if (atomic_read(&meta->error)) 141 + bio_io_error(meta->bio); 142 + else 143 + bio_endio(meta->bio); 141 144 kmem_cache_free(bio_meta_pool, meta); 142 145 } 143 146 } ··· 150 147 struct rsxx_cardinfo *card = q->queuedata; 151 148 struct rsxx_bio_meta *bio_meta; 152 149 int st = -EINVAL; 150 + 151 + blk_queue_split(q, &bio, q->bio_split); 153 152 154 153 might_sleep(); 155 154 ··· 204 199 queue_err: 205 200 kmem_cache_free(bio_meta_pool, bio_meta); 206 201 req_err: 207 - bio_endio(bio, st); 202 + if (st) 203 + bio->bi_error = st; 204 + bio_endio(bio); 208 205 } 209 206 210 207 /*----------------- Device Setup -------------------*/
+1 -1
drivers/block/skd_main.c
··· 4422 4422 /* DISCARD Flag initialization. */ 4423 4423 q->limits.discard_granularity = 8192; 4424 4424 q->limits.discard_alignment = 0; 4425 - q->limits.max_discard_sectors = UINT_MAX >> 9; 4425 + blk_queue_max_discard_sectors(q, UINT_MAX >> 9); 4426 4426 q->limits.discard_zeroes_data = 1; 4427 4427 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); 4428 4428 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q);
+4 -2
drivers/block/umem.c
··· 456 456 PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); 457 457 if (control & DMASCR_HARD_ERROR) { 458 458 /* error */ 459 - clear_bit(BIO_UPTODATE, &bio->bi_flags); 459 + bio->bi_error = -EIO; 460 460 dev_printk(KERN_WARNING, &card->dev->dev, 461 461 "I/O error on sector %d/%d\n", 462 462 le32_to_cpu(desc->local_addr)>>9, ··· 505 505 506 506 return_bio = bio->bi_next; 507 507 bio->bi_next = NULL; 508 - bio_endio(bio, 0); 508 + bio_endio(bio); 509 509 } 510 510 } 511 511 ··· 530 530 pr_debug("mm_make_request %llu %u\n", 531 531 (unsigned long long)bio->bi_iter.bi_sector, 532 532 bio->bi_iter.bi_size); 533 + 534 + blk_queue_split(q, &bio, q->bio_split); 533 535 534 536 spin_lock_irq(&card->lock); 535 537 *card->biotail = bio;
+2 -2
drivers/block/xen-blkback/blkback.c
··· 1078 1078 /* 1079 1079 * bio callback. 1080 1080 */ 1081 - static void end_block_io_op(struct bio *bio, int error) 1081 + static void end_block_io_op(struct bio *bio) 1082 1082 { 1083 - __end_block_io_op(bio->bi_private, error); 1083 + __end_block_io_op(bio->bi_private, bio->bi_error); 1084 1084 bio_put(bio); 1085 1085 } 1086 1086
+3 -6
drivers/block/xen-blkfront.c
··· 82 82 struct split_bio { 83 83 struct bio *bio; 84 84 atomic_t pending; 85 - int err; 86 85 }; 87 86 88 87 static DEFINE_MUTEX(blkfront_mutex); ··· 1480 1481 return 0; 1481 1482 } 1482 1483 1483 - static void split_bio_end(struct bio *bio, int error) 1484 + static void split_bio_end(struct bio *bio) 1484 1485 { 1485 1486 struct split_bio *split_bio = bio->bi_private; 1486 1487 1487 - if (error) 1488 - split_bio->err = error; 1489 - 1490 1488 if (atomic_dec_and_test(&split_bio->pending)) { 1491 1489 split_bio->bio->bi_phys_segments = 0; 1492 - bio_endio(split_bio->bio, split_bio->err); 1490 + split_bio->bio->bi_error = bio->bi_error; 1491 + bio_endio(split_bio->bio); 1493 1492 kfree(split_bio); 1494 1493 } 1495 1494 bio_put(bio);
+5 -4
drivers/block/zram/zram_drv.c
··· 848 848 849 849 if (unlikely(bio->bi_rw & REQ_DISCARD)) { 850 850 zram_bio_discard(zram, index, offset, bio); 851 - bio_endio(bio, 0); 851 + bio_endio(bio); 852 852 return; 853 853 } 854 854 ··· 881 881 update_position(&index, &offset, &bvec); 882 882 } 883 883 884 - set_bit(BIO_UPTODATE, &bio->bi_flags); 885 - bio_endio(bio, 0); 884 + bio_endio(bio); 886 885 return; 887 886 888 887 out: ··· 897 898 898 899 if (unlikely(!zram_meta_get(zram))) 899 900 goto error; 901 + 902 + blk_queue_split(queue, &bio, queue->bio_split); 900 903 901 904 if (!valid_io_request(zram, bio->bi_iter.bi_sector, 902 905 bio->bi_iter.bi_size)) { ··· 1243 1242 blk_queue_io_min(zram->disk->queue, PAGE_SIZE); 1244 1243 blk_queue_io_opt(zram->disk->queue, PAGE_SIZE); 1245 1244 zram->disk->queue->limits.discard_granularity = PAGE_SIZE; 1246 - zram->disk->queue->limits.max_discard_sectors = UINT_MAX; 1245 + blk_queue_max_discard_sectors(zram->disk->queue, UINT_MAX); 1247 1246 /* 1248 1247 * zram_bio_discard() will clear all logical blocks if logical block 1249 1248 * size is identical with physical block size(PAGE_SIZE). But if it is
-18
drivers/md/bcache/bcache.h
··· 243 243 DECLARE_ARRAY_ALLOCATOR(struct keybuf_key, freelist, KEYBUF_NR); 244 244 }; 245 245 246 - struct bio_split_pool { 247 - struct bio_set *bio_split; 248 - mempool_t *bio_split_hook; 249 - }; 250 - 251 - struct bio_split_hook { 252 - struct closure cl; 253 - struct bio_split_pool *p; 254 - struct bio *bio; 255 - bio_end_io_t *bi_end_io; 256 - void *bi_private; 257 - }; 258 - 259 246 struct bcache_device { 260 247 struct closure cl; 261 248 ··· 275 288 int (*cache_miss)(struct btree *, struct search *, 276 289 struct bio *, unsigned); 277 290 int (*ioctl) (struct bcache_device *, fmode_t, unsigned, unsigned long); 278 - 279 - struct bio_split_pool bio_split_hook; 280 291 }; 281 292 282 293 struct io { ··· 439 454 atomic_long_t meta_sectors_written; 440 455 atomic_long_t btree_sectors_written; 441 456 atomic_long_t sectors_written; 442 - 443 - struct bio_split_pool bio_split_hook; 444 457 }; 445 458 446 459 struct gc_stat { ··· 856 873 void bch_bbio_free(struct bio *, struct cache_set *); 857 874 struct bio *bch_bbio_alloc(struct cache_set *); 858 875 859 - void bch_generic_make_request(struct bio *, struct bio_split_pool *); 860 876 void __bch_submit_bbio(struct bio *, struct cache_set *); 861 877 void bch_submit_bbio(struct bio *, struct cache_set *, struct bkey *, unsigned); 862 878
+5 -5
drivers/md/bcache/btree.c
··· 278 278 goto out; 279 279 } 280 280 281 - static void btree_node_read_endio(struct bio *bio, int error) 281 + static void btree_node_read_endio(struct bio *bio) 282 282 { 283 283 struct closure *cl = bio->bi_private; 284 284 closure_put(cl); ··· 305 305 bch_submit_bbio(bio, b->c, &b->key, 0); 306 306 closure_sync(&cl); 307 307 308 - if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) 308 + if (bio->bi_error) 309 309 set_btree_node_io_error(b); 310 310 311 311 bch_bbio_free(bio, b->c); ··· 371 371 __btree_node_write_done(cl); 372 372 } 373 373 374 - static void btree_node_write_endio(struct bio *bio, int error) 374 + static void btree_node_write_endio(struct bio *bio) 375 375 { 376 376 struct closure *cl = bio->bi_private; 377 377 struct btree *b = container_of(cl, struct btree, io); 378 378 379 - if (error) 379 + if (bio->bi_error) 380 380 set_btree_node_io_error(b); 381 381 382 - bch_bbio_count_io_errors(b->c, bio, error, "writing btree"); 382 + bch_bbio_count_io_errors(b->c, bio, bio->bi_error, "writing btree"); 383 383 closure_put(cl); 384 384 } 385 385
+1 -1
drivers/md/bcache/closure.h
··· 38 38 * they are running owned by the thread that is running them. Otherwise, suppose 39 39 * you submit some bios and wish to have a function run when they all complete: 40 40 * 41 - * foo_endio(struct bio *bio, int error) 41 + * foo_endio(struct bio *bio) 42 42 * { 43 43 * closure_put(cl); 44 44 * }
+1 -100
drivers/md/bcache/io.c
··· 11 11 12 12 #include <linux/blkdev.h> 13 13 14 - static unsigned bch_bio_max_sectors(struct bio *bio) 15 - { 16 - struct request_queue *q = bdev_get_queue(bio->bi_bdev); 17 - struct bio_vec bv; 18 - struct bvec_iter iter; 19 - unsigned ret = 0, seg = 0; 20 - 21 - if (bio->bi_rw & REQ_DISCARD) 22 - return min(bio_sectors(bio), q->limits.max_discard_sectors); 23 - 24 - bio_for_each_segment(bv, bio, iter) { 25 - struct bvec_merge_data bvm = { 26 - .bi_bdev = bio->bi_bdev, 27 - .bi_sector = bio->bi_iter.bi_sector, 28 - .bi_size = ret << 9, 29 - .bi_rw = bio->bi_rw, 30 - }; 31 - 32 - if (seg == min_t(unsigned, BIO_MAX_PAGES, 33 - queue_max_segments(q))) 34 - break; 35 - 36 - if (q->merge_bvec_fn && 37 - q->merge_bvec_fn(q, &bvm, &bv) < (int) bv.bv_len) 38 - break; 39 - 40 - seg++; 41 - ret += bv.bv_len >> 9; 42 - } 43 - 44 - ret = min(ret, queue_max_sectors(q)); 45 - 46 - WARN_ON(!ret); 47 - ret = max_t(int, ret, bio_iovec(bio).bv_len >> 9); 48 - 49 - return ret; 50 - } 51 - 52 - static void bch_bio_submit_split_done(struct closure *cl) 53 - { 54 - struct bio_split_hook *s = container_of(cl, struct bio_split_hook, cl); 55 - 56 - s->bio->bi_end_io = s->bi_end_io; 57 - s->bio->bi_private = s->bi_private; 58 - bio_endio(s->bio, 0); 59 - 60 - closure_debug_destroy(&s->cl); 61 - mempool_free(s, s->p->bio_split_hook); 62 - } 63 - 64 - static void bch_bio_submit_split_endio(struct bio *bio, int error) 65 - { 66 - struct closure *cl = bio->bi_private; 67 - struct bio_split_hook *s = container_of(cl, struct bio_split_hook, cl); 68 - 69 - if (error) 70 - clear_bit(BIO_UPTODATE, &s->bio->bi_flags); 71 - 72 - bio_put(bio); 73 - closure_put(cl); 74 - } 75 - 76 - void bch_generic_make_request(struct bio *bio, struct bio_split_pool *p) 77 - { 78 - struct bio_split_hook *s; 79 - struct bio *n; 80 - 81 - if (!bio_has_data(bio) && !(bio->bi_rw & REQ_DISCARD)) 82 - goto submit; 83 - 84 - if (bio_sectors(bio) <= bch_bio_max_sectors(bio)) 85 - goto submit; 86 - 87 - s = mempool_alloc(p->bio_split_hook, GFP_NOIO); 88 - closure_init(&s->cl, NULL); 89 - 90 - s->bio = bio; 91 - s->p = p; 92 - s->bi_end_io = bio->bi_end_io; 93 - s->bi_private = bio->bi_private; 94 - bio_get(bio); 95 - 96 - do { 97 - n = bio_next_split(bio, bch_bio_max_sectors(bio), 98 - GFP_NOIO, s->p->bio_split); 99 - 100 - n->bi_end_io = bch_bio_submit_split_endio; 101 - n->bi_private = &s->cl; 102 - 103 - closure_get(&s->cl); 104 - generic_make_request(n); 105 - } while (n != bio); 106 - 107 - continue_at(&s->cl, bch_bio_submit_split_done, NULL); 108 - return; 109 - submit: 110 - generic_make_request(bio); 111 - } 112 - 113 14 /* Bios with headers */ 114 15 115 16 void bch_bbio_free(struct bio *bio, struct cache_set *c) ··· 40 139 bio->bi_bdev = PTR_CACHE(c, &b->key, 0)->bdev; 41 140 42 141 b->submit_time_us = local_clock_us(); 43 - closure_bio_submit(bio, bio->bi_private, PTR_CACHE(c, &b->key, 0)); 142 + closure_bio_submit(bio, bio->bi_private); 44 143 } 45 144 46 145 void bch_submit_bbio(struct bio *bio, struct cache_set *c,
+6 -6
drivers/md/bcache/journal.c
··· 24 24 * bit. 25 25 */ 26 26 27 - static void journal_read_endio(struct bio *bio, int error) 27 + static void journal_read_endio(struct bio *bio) 28 28 { 29 29 struct closure *cl = bio->bi_private; 30 30 closure_put(cl); ··· 61 61 bio->bi_private = &cl; 62 62 bch_bio_map(bio, data); 63 63 64 - closure_bio_submit(bio, &cl, ca); 64 + closure_bio_submit(bio, &cl); 65 65 closure_sync(&cl); 66 66 67 67 /* This function could be simpler now since we no longer write ··· 401 401 402 402 #define last_seq(j) ((j)->seq - fifo_used(&(j)->pin) + 1) 403 403 404 - static void journal_discard_endio(struct bio *bio, int error) 404 + static void journal_discard_endio(struct bio *bio) 405 405 { 406 406 struct journal_device *ja = 407 407 container_of(bio, struct journal_device, discard_bio); ··· 547 547 pr_debug("journal_pin full (%zu)", fifo_used(&j->pin)); 548 548 } 549 549 550 - static void journal_write_endio(struct bio *bio, int error) 550 + static void journal_write_endio(struct bio *bio) 551 551 { 552 552 struct journal_write *w = bio->bi_private; 553 553 554 - cache_set_err_on(error, w->c, "journal io error"); 554 + cache_set_err_on(bio->bi_error, w->c, "journal io error"); 555 555 closure_put(&w->c->journal.io); 556 556 } 557 557 ··· 648 648 spin_unlock(&c->journal.lock); 649 649 650 650 while ((bio = bio_list_pop(&list))) 651 - closure_bio_submit(bio, cl, c->cache[0]); 651 + closure_bio_submit(bio, cl); 652 652 653 653 continue_at(cl, journal_write_done, NULL); 654 654 }
+4 -4
drivers/md/bcache/movinggc.c
··· 60 60 closure_return_with_destructor(cl, moving_io_destructor); 61 61 } 62 62 63 - static void read_moving_endio(struct bio *bio, int error) 63 + static void read_moving_endio(struct bio *bio) 64 64 { 65 65 struct bbio *b = container_of(bio, struct bbio, bio); 66 66 struct moving_io *io = container_of(bio->bi_private, 67 67 struct moving_io, cl); 68 68 69 - if (error) 70 - io->op.error = error; 69 + if (bio->bi_error) 70 + io->op.error = bio->bi_error; 71 71 else if (!KEY_DIRTY(&b->key) && 72 72 ptr_stale(io->op.c, &b->key, 0)) { 73 73 io->op.error = -EINTR; 74 74 } 75 75 76 - bch_bbio_endio(io->op.c, bio, error, "reading data to move"); 76 + bch_bbio_endio(io->op.c, bio, bio->bi_error, "reading data to move"); 77 77 } 78 78 79 79 static void moving_init(struct moving_io *io)
+22 -21
drivers/md/bcache/request.c
··· 173 173 bch_data_insert_keys(cl); 174 174 } 175 175 176 - static void bch_data_insert_endio(struct bio *bio, int error) 176 + static void bch_data_insert_endio(struct bio *bio) 177 177 { 178 178 struct closure *cl = bio->bi_private; 179 179 struct data_insert_op *op = container_of(cl, struct data_insert_op, cl); 180 180 181 - if (error) { 181 + if (bio->bi_error) { 182 182 /* TODO: We could try to recover from this. */ 183 183 if (op->writeback) 184 - op->error = error; 184 + op->error = bio->bi_error; 185 185 else if (!op->replace) 186 186 set_closure_fn(cl, bch_data_insert_error, op->wq); 187 187 else 188 188 set_closure_fn(cl, NULL, NULL); 189 189 } 190 190 191 - bch_bbio_endio(op->c, bio, error, "writing data to cache"); 191 + bch_bbio_endio(op->c, bio, bio->bi_error, "writing data to cache"); 192 192 } 193 193 194 194 static void bch_data_insert_start(struct closure *cl) ··· 477 477 struct data_insert_op iop; 478 478 }; 479 479 480 - static void bch_cache_read_endio(struct bio *bio, int error) 480 + static void bch_cache_read_endio(struct bio *bio) 481 481 { 482 482 struct bbio *b = container_of(bio, struct bbio, bio); 483 483 struct closure *cl = bio->bi_private; ··· 490 490 * from the backing device. 491 491 */ 492 492 493 - if (error) 494 - s->iop.error = error; 493 + if (bio->bi_error) 494 + s->iop.error = bio->bi_error; 495 495 else if (!KEY_DIRTY(&b->key) && 496 496 ptr_stale(s->iop.c, &b->key, 0)) { 497 497 atomic_long_inc(&s->iop.c->cache_read_races); 498 498 s->iop.error = -EINTR; 499 499 } 500 500 501 - bch_bbio_endio(s->iop.c, bio, error, "reading from cache"); 501 + bch_bbio_endio(s->iop.c, bio, bio->bi_error, "reading from cache"); 502 502 } 503 503 504 504 /* ··· 591 591 592 592 /* Common code for the make_request functions */ 593 593 594 - static void request_endio(struct bio *bio, int error) 594 + static void request_endio(struct bio *bio) 595 595 { 596 596 struct closure *cl = bio->bi_private; 597 597 598 - if (error) { 598 + if (bio->bi_error) { 599 599 struct search *s = container_of(cl, struct search, cl); 600 - s->iop.error = error; 600 + s->iop.error = bio->bi_error; 601 601 /* Only cache read errors are recoverable */ 602 602 s->recoverable = false; 603 603 } ··· 613 613 &s->d->disk->part0, s->start_time); 614 614 615 615 trace_bcache_request_end(s->d, s->orig_bio); 616 - bio_endio(s->orig_bio, s->iop.error); 616 + s->orig_bio->bi_error = s->iop.error; 617 + bio_endio(s->orig_bio); 617 618 s->orig_bio = NULL; 618 619 } 619 620 } ··· 719 718 720 719 /* XXX: invalidate cache */ 721 720 722 - closure_bio_submit(bio, cl, s->d); 721 + closure_bio_submit(bio, cl); 723 722 } 724 723 725 724 continue_at(cl, cached_dev_cache_miss_done, NULL); ··· 842 841 s->cache_miss = miss; 843 842 s->iop.bio = cache_bio; 844 843 bio_get(cache_bio); 845 - closure_bio_submit(cache_bio, &s->cl, s->d); 844 + closure_bio_submit(cache_bio, &s->cl); 846 845 847 846 return ret; 848 847 out_put: ··· 850 849 out_submit: 851 850 miss->bi_end_io = request_endio; 852 851 miss->bi_private = &s->cl; 853 - closure_bio_submit(miss, &s->cl, s->d); 852 + closure_bio_submit(miss, &s->cl); 854 853 return ret; 855 854 } 856 855 ··· 915 914 916 915 if (!(bio->bi_rw & REQ_DISCARD) || 917 916 blk_queue_discard(bdev_get_queue(dc->bdev))) 918 - closure_bio_submit(bio, cl, s->d); 917 + closure_bio_submit(bio, cl); 919 918 } else if (s->iop.writeback) { 920 919 bch_writeback_add(dc); 921 920 s->iop.bio = bio; ··· 930 929 flush->bi_end_io = request_endio; 931 930 flush->bi_private = cl; 932 931 933 - closure_bio_submit(flush, cl, s->d); 932 + closure_bio_submit(flush, cl); 934 933 } 935 934 } else { 936 935 s->iop.bio = bio_clone_fast(bio, GFP_NOIO, dc->disk.bio_split); 937 936 938 - closure_bio_submit(bio, cl, s->d); 937 + closure_bio_submit(bio, cl); 939 938 } 940 939 941 940 closure_call(&s->iop.cl, bch_data_insert, NULL, cl); ··· 951 950 bch_journal_meta(s->iop.c, cl); 952 951 953 952 /* If it's a flush, we send the flush to the backing device too */ 954 - closure_bio_submit(bio, cl, s->d); 953 + closure_bio_submit(bio, cl); 955 954 956 955 continue_at(cl, cached_dev_bio_complete, NULL); 957 956 } ··· 993 992 } else { 994 993 if ((bio->bi_rw & REQ_DISCARD) && 995 994 !blk_queue_discard(bdev_get_queue(dc->bdev))) 996 - bio_endio(bio, 0); 995 + bio_endio(bio); 997 996 else 998 - bch_generic_make_request(bio, &d->bio_split_hook); 997 + generic_make_request(bio); 999 998 } 1000 999 } 1001 1000
+10 -38
drivers/md/bcache/super.c
··· 59 59 60 60 #define BTREE_MAX_PAGES (256 * 1024 / PAGE_SIZE) 61 61 62 - static void bio_split_pool_free(struct bio_split_pool *p) 63 - { 64 - if (p->bio_split_hook) 65 - mempool_destroy(p->bio_split_hook); 66 - 67 - if (p->bio_split) 68 - bioset_free(p->bio_split); 69 - } 70 - 71 - static int bio_split_pool_init(struct bio_split_pool *p) 72 - { 73 - p->bio_split = bioset_create(4, 0); 74 - if (!p->bio_split) 75 - return -ENOMEM; 76 - 77 - p->bio_split_hook = mempool_create_kmalloc_pool(4, 78 - sizeof(struct bio_split_hook)); 79 - if (!p->bio_split_hook) 80 - return -ENOMEM; 81 - 82 - return 0; 83 - } 84 - 85 62 /* Superblock */ 86 63 87 64 static const char *read_super(struct cache_sb *sb, struct block_device *bdev, ··· 198 221 return err; 199 222 } 200 223 201 - static void write_bdev_super_endio(struct bio *bio, int error) 224 + static void write_bdev_super_endio(struct bio *bio) 202 225 { 203 226 struct cached_dev *dc = bio->bi_private; 204 227 /* XXX: error checking */ ··· 267 290 closure_return_with_destructor(cl, bch_write_bdev_super_unlock); 268 291 } 269 292 270 - static void write_super_endio(struct bio *bio, int error) 293 + static void write_super_endio(struct bio *bio) 271 294 { 272 295 struct cache *ca = bio->bi_private; 273 296 274 - bch_count_io_errors(ca, error, "writing superblock"); 297 + bch_count_io_errors(ca, bio->bi_error, "writing superblock"); 275 298 closure_put(&ca->set->sb_write); 276 299 } 277 300 ··· 316 339 317 340 /* UUID io */ 318 341 319 - static void uuid_endio(struct bio *bio, int error) 342 + static void uuid_endio(struct bio *bio) 320 343 { 321 344 struct closure *cl = bio->bi_private; 322 345 struct cache_set *c = container_of(cl, struct cache_set, uuid_write); 323 346 324 - cache_set_err_on(error, c, "accessing uuids"); 347 + cache_set_err_on(bio->bi_error, c, "accessing uuids"); 325 348 bch_bbio_free(bio, c); 326 349 closure_put(cl); 327 350 } ··· 489 512 * disk. 490 513 */ 491 514 492 - static void prio_endio(struct bio *bio, int error) 515 + static void prio_endio(struct bio *bio) 493 516 { 494 517 struct cache *ca = bio->bi_private; 495 518 496 - cache_set_err_on(error, ca->set, "accessing priorities"); 519 + cache_set_err_on(bio->bi_error, ca->set, "accessing priorities"); 497 520 bch_bbio_free(bio, ca->set); 498 521 closure_put(&ca->prio); 499 522 } ··· 514 537 bio->bi_private = ca; 515 538 bch_bio_map(bio, ca->disk_buckets); 516 539 517 - closure_bio_submit(bio, &ca->prio, ca); 540 + closure_bio_submit(bio, &ca->prio); 518 541 closure_sync(cl); 519 542 } 520 543 ··· 734 757 put_disk(d->disk); 735 758 } 736 759 737 - bio_split_pool_free(&d->bio_split_hook); 738 760 if (d->bio_split) 739 761 bioset_free(d->bio_split); 740 762 kvfree(d->full_dirty_stripes); ··· 780 804 return minor; 781 805 782 806 if (!(d->bio_split = bioset_create(4, offsetof(struct bbio, bio))) || 783 - bio_split_pool_init(&d->bio_split_hook) || 784 807 !(d->disk = alloc_disk(1))) { 785 808 ida_simple_remove(&bcache_minor, minor); 786 809 return -ENOMEM; ··· 805 830 q->limits.max_sectors = UINT_MAX; 806 831 q->limits.max_segment_size = UINT_MAX; 807 832 q->limits.max_segments = BIO_MAX_PAGES; 808 - q->limits.max_discard_sectors = UINT_MAX; 833 + blk_queue_max_discard_sectors(q, UINT_MAX); 809 834 q->limits.discard_granularity = 512; 810 835 q->limits.io_min = block_size; 811 836 q->limits.logical_block_size = block_size; ··· 1768 1793 ca->set->cache[ca->sb.nr_this_dev] = NULL; 1769 1794 } 1770 1795 1771 - bio_split_pool_free(&ca->bio_split_hook); 1772 - 1773 1796 free_pages((unsigned long) ca->disk_buckets, ilog2(bucket_pages(ca))); 1774 1797 kfree(ca->prio_buckets); 1775 1798 vfree(ca->buckets); ··· 1812 1839 ca->sb.nbuckets)) || 1813 1840 !(ca->prio_buckets = kzalloc(sizeof(uint64_t) * prio_buckets(ca) * 1814 1841 2, GFP_KERNEL)) || 1815 - !(ca->disk_buckets = alloc_bucket_pages(GFP_KERNEL, ca)) || 1816 - bio_split_pool_init(&ca->bio_split_hook)) 1842 + !(ca->disk_buckets = alloc_bucket_pages(GFP_KERNEL, ca))) 1817 1843 return -ENOMEM; 1818 1844 1819 1845 ca->prio_last_buckets = ca->prio_buckets + prio_buckets(ca);
+3 -2
drivers/md/bcache/util.h
··· 4 4 5 5 #include <linux/blkdev.h> 6 6 #include <linux/errno.h> 7 + #include <linux/blkdev.h> 7 8 #include <linux/kernel.h> 8 9 #include <linux/llist.h> 9 10 #include <linux/ratelimit.h> ··· 571 570 return bdev->bd_inode->i_size >> 9; 572 571 } 573 572 574 - #define closure_bio_submit(bio, cl, dev) \ 573 + #define closure_bio_submit(bio, cl) \ 575 574 do { \ 576 575 closure_get(cl); \ 577 - bch_generic_make_request(bio, &(dev)->bio_split_hook); \ 576 + generic_make_request(bio); \ 578 577 } while (0) 579 578 580 579 uint64_t bch_crc64_update(uint64_t, const void *, size_t);
+7 -7
drivers/md/bcache/writeback.c
··· 166 166 closure_return_with_destructor(cl, dirty_io_destructor); 167 167 } 168 168 169 - static void dirty_endio(struct bio *bio, int error) 169 + static void dirty_endio(struct bio *bio) 170 170 { 171 171 struct keybuf_key *w = bio->bi_private; 172 172 struct dirty_io *io = w->private; 173 173 174 - if (error) 174 + if (bio->bi_error) 175 175 SET_KEY_DIRTY(&w->key, false); 176 176 177 177 closure_put(&io->cl); ··· 188 188 io->bio.bi_bdev = io->dc->bdev; 189 189 io->bio.bi_end_io = dirty_endio; 190 190 191 - closure_bio_submit(&io->bio, cl, &io->dc->disk); 191 + closure_bio_submit(&io->bio, cl); 192 192 193 193 continue_at(cl, write_dirty_finish, system_wq); 194 194 } 195 195 196 - static void read_dirty_endio(struct bio *bio, int error) 196 + static void read_dirty_endio(struct bio *bio) 197 197 { 198 198 struct keybuf_key *w = bio->bi_private; 199 199 struct dirty_io *io = w->private; 200 200 201 201 bch_count_io_errors(PTR_CACHE(io->dc->disk.c, &w->key, 0), 202 - error, "reading dirty data from cache"); 202 + bio->bi_error, "reading dirty data from cache"); 203 203 204 - dirty_endio(bio, error); 204 + dirty_endio(bio); 205 205 } 206 206 207 207 static void read_dirty_submit(struct closure *cl) 208 208 { 209 209 struct dirty_io *io = container_of(cl, struct dirty_io, cl); 210 210 211 - closure_bio_submit(&io->bio, cl, &io->dc->disk); 211 + closure_bio_submit(&io->bio, cl); 212 212 213 213 continue_at(cl, write_dirty, system_wq); 214 214 }
+4 -2
drivers/md/dm-bio-prison.c
··· 236 236 bio_list_init(&bios); 237 237 dm_cell_release(prison, cell, &bios); 238 238 239 - while ((bio = bio_list_pop(&bios))) 240 - bio_endio(bio, error); 239 + while ((bio = bio_list_pop(&bios))) { 240 + bio->bi_error = error; 241 + bio_endio(bio); 242 + } 241 243 } 242 244 EXPORT_SYMBOL_GPL(dm_cell_error); 243 245
+16 -10
drivers/md/dm-bufio.c
··· 545 545 { 546 546 struct dm_buffer *b = context; 547 547 548 - b->bio.bi_end_io(&b->bio, error ? -EIO : 0); 548 + b->bio.bi_error = error ? -EIO : 0; 549 + b->bio.bi_end_io(&b->bio); 549 550 } 550 551 551 552 static void use_dmio(struct dm_buffer *b, int rw, sector_t block, ··· 576 575 b->bio.bi_end_io = end_io; 577 576 578 577 r = dm_io(&io_req, 1, &region, NULL); 579 - if (r) 580 - end_io(&b->bio, r); 578 + if (r) { 579 + b->bio.bi_error = r; 580 + end_io(&b->bio); 581 + } 581 582 } 582 583 583 - static void inline_endio(struct bio *bio, int error) 584 + static void inline_endio(struct bio *bio) 584 585 { 585 586 bio_end_io_t *end_fn = bio->bi_private; 587 + int error = bio->bi_error; 586 588 587 589 /* 588 590 * Reset the bio to free any attached resources ··· 593 589 */ 594 590 bio_reset(bio); 595 591 596 - end_fn(bio, error); 592 + bio->bi_error = error; 593 + end_fn(bio); 597 594 } 598 595 599 596 static void use_inline_bio(struct dm_buffer *b, int rw, sector_t block, ··· 666 661 * Set the error, clear B_WRITING bit and wake anyone who was waiting on 667 662 * it. 668 663 */ 669 - static void write_endio(struct bio *bio, int error) 664 + static void write_endio(struct bio *bio) 670 665 { 671 666 struct dm_buffer *b = container_of(bio, struct dm_buffer, bio); 672 667 673 - b->write_error = error; 674 - if (unlikely(error)) { 668 + b->write_error = bio->bi_error; 669 + if (unlikely(bio->bi_error)) { 675 670 struct dm_bufio_client *c = b->c; 671 + int error = bio->bi_error; 676 672 (void)cmpxchg(&c->async_write_error, 0, error); 677 673 } 678 674 ··· 1032 1026 * The endio routine for reading: set the error, clear the bit and wake up 1033 1027 * anyone waiting on the buffer. 1034 1028 */ 1035 - static void read_endio(struct bio *bio, int error) 1029 + static void read_endio(struct bio *bio) 1036 1030 { 1037 1031 struct dm_buffer *b = container_of(bio, struct dm_buffer, bio); 1038 1032 1039 - b->read_error = error; 1033 + b->read_error = bio->bi_error; 1040 1034 1041 1035 BUG_ON(!test_bit(B_READING, &b->state)); 1042 1036
+13 -32
drivers/md/dm-cache-target.c
··· 919 919 wake_worker(cache); 920 920 } 921 921 922 - static void writethrough_endio(struct bio *bio, int err) 922 + static void writethrough_endio(struct bio *bio) 923 923 { 924 924 struct per_bio_data *pb = get_per_bio_data(bio, PB_DATA_SIZE_WT); 925 925 926 926 dm_unhook_bio(&pb->hook_info, bio); 927 927 928 - if (err) { 929 - bio_endio(bio, err); 928 + if (bio->bi_error) { 929 + bio_endio(bio); 930 930 return; 931 931 } 932 932 ··· 1231 1231 * The block was promoted via an overwrite, so it's dirty. 1232 1232 */ 1233 1233 set_dirty(cache, mg->new_oblock, mg->cblock); 1234 - bio_endio(mg->new_ocell->holder, 0); 1234 + bio_endio(mg->new_ocell->holder); 1235 1235 cell_defer(cache, mg->new_ocell, false); 1236 1236 } 1237 1237 free_io_migration(mg); ··· 1284 1284 } 1285 1285 } 1286 1286 1287 - static void overwrite_endio(struct bio *bio, int err) 1287 + static void overwrite_endio(struct bio *bio) 1288 1288 { 1289 1289 struct dm_cache_migration *mg = bio->bi_private; 1290 1290 struct cache *cache = mg->cache; ··· 1294 1294 1295 1295 dm_unhook_bio(&pb->hook_info, bio); 1296 1296 1297 - if (err) 1297 + if (bio->bi_error) 1298 1298 mg->err = true; 1299 1299 1300 1300 mg->requeue_holder = false; ··· 1358 1358 b = to_dblock(from_dblock(b) + 1); 1359 1359 } 1360 1360 1361 - bio_endio(bio, 0); 1361 + bio_endio(bio); 1362 1362 cell_defer(mg->cache, mg->new_ocell, false); 1363 1363 free_migration(mg); 1364 1364 } ··· 1631 1631 1632 1632 calc_discard_block_range(cache, bio, &b, &e); 1633 1633 if (b == e) { 1634 - bio_endio(bio, 0); 1634 + bio_endio(bio); 1635 1635 return; 1636 1636 } 1637 1637 ··· 2217 2217 bio_list_merge(&bios, &cache->deferred_bios); 2218 2218 bio_list_init(&cache->deferred_bios); 2219 2219 2220 - while ((bio = bio_list_pop(&bios))) 2221 - bio_endio(bio, DM_ENDIO_REQUEUE); 2220 + while ((bio = bio_list_pop(&bios))) { 2221 + bio->bi_error = DM_ENDIO_REQUEUE; 2222 + bio_endio(bio); 2223 + } 2222 2224 } 2223 2225 2224 2226 static int more_work(struct cache *cache) ··· 3125 3123 * This is a duplicate writethrough io that is no 3126 3124 * longer needed because the block has been demoted. 3127 3125 */ 3128 - bio_endio(bio, 0); 3126 + bio_endio(bio); 3129 3127 // FIXME: remap everything as a miss 3130 3128 cell_defer(cache, cell, false); 3131 3129 r = DM_MAPIO_SUBMITTED; ··· 3780 3778 return r; 3781 3779 } 3782 3780 3783 - /* 3784 - * We assume I/O is going to the origin (which is the volume 3785 - * more likely to have restrictions e.g. by being striped). 3786 - * (Looking up the exact location of the data would be expensive 3787 - * and could always be out of date by the time the bio is submitted.) 3788 - */ 3789 - static int cache_bvec_merge(struct dm_target *ti, 3790 - struct bvec_merge_data *bvm, 3791 - struct bio_vec *biovec, int max_size) 3792 - { 3793 - struct cache *cache = ti->private; 3794 - struct request_queue *q = bdev_get_queue(cache->origin_dev->bdev); 3795 - 3796 - if (!q->merge_bvec_fn) 3797 - return max_size; 3798 - 3799 - bvm->bi_bdev = cache->origin_dev->bdev; 3800 - return min(max_size, q->merge_bvec_fn(q, bvm, biovec)); 3801 - } 3802 - 3803 3781 static void set_discard_limits(struct cache *cache, struct queue_limits *limits) 3804 3782 { 3805 3783 /* ··· 3823 3841 .status = cache_status, 3824 3842 .message = cache_message, 3825 3843 .iterate_devices = cache_iterate_devices, 3826 - .merge = cache_bvec_merge, 3827 3844 .io_hints = cache_io_hints, 3828 3845 }; 3829 3846
+5 -21
drivers/md/dm-crypt.c
··· 1076 1076 if (io->ctx.req) 1077 1077 crypt_free_req(cc, io->ctx.req, base_bio); 1078 1078 1079 - bio_endio(base_bio, error); 1079 + base_bio->bi_error = error; 1080 + bio_endio(base_bio); 1080 1081 } 1081 1082 1082 1083 /* ··· 1097 1096 * The work is done per CPU global for all dm-crypt instances. 1098 1097 * They should not depend on each other and do not block. 1099 1098 */ 1100 - static void crypt_endio(struct bio *clone, int error) 1099 + static void crypt_endio(struct bio *clone) 1101 1100 { 1102 1101 struct dm_crypt_io *io = clone->bi_private; 1103 1102 struct crypt_config *cc = io->cc; 1104 1103 unsigned rw = bio_data_dir(clone); 1105 - 1106 - if (unlikely(!bio_flagged(clone, BIO_UPTODATE) && !error)) 1107 - error = -EIO; 1104 + int error; 1108 1105 1109 1106 /* 1110 1107 * free the processed pages ··· 1110 1111 if (rw == WRITE) 1111 1112 crypt_free_buffer_pages(cc, clone); 1112 1113 1114 + error = clone->bi_error; 1113 1115 bio_put(clone); 1114 1116 1115 1117 if (rw == READ && !error) { ··· 2035 2035 return -EINVAL; 2036 2036 } 2037 2037 2038 - static int crypt_merge(struct dm_target *ti, struct bvec_merge_data *bvm, 2039 - struct bio_vec *biovec, int max_size) 2040 - { 2041 - struct crypt_config *cc = ti->private; 2042 - struct request_queue *q = bdev_get_queue(cc->dev->bdev); 2043 - 2044 - if (!q->merge_bvec_fn) 2045 - return max_size; 2046 - 2047 - bvm->bi_bdev = cc->dev->bdev; 2048 - bvm->bi_sector = cc->start + dm_target_offset(ti, bvm->bi_sector); 2049 - 2050 - return min(max_size, q->merge_bvec_fn(q, bvm, biovec)); 2051 - } 2052 - 2053 2038 static int crypt_iterate_devices(struct dm_target *ti, 2054 2039 iterate_devices_callout_fn fn, void *data) 2055 2040 { ··· 2055 2070 .preresume = crypt_preresume, 2056 2071 .resume = crypt_resume, 2057 2072 .message = crypt_message, 2058 - .merge = crypt_merge, 2059 2073 .iterate_devices = crypt_iterate_devices, 2060 2074 }; 2061 2075
-15
drivers/md/dm-era-target.c
··· 1673 1673 return fn(ti, era->origin_dev, 0, get_dev_size(era->origin_dev), data); 1674 1674 } 1675 1675 1676 - static int era_merge(struct dm_target *ti, struct bvec_merge_data *bvm, 1677 - struct bio_vec *biovec, int max_size) 1678 - { 1679 - struct era *era = ti->private; 1680 - struct request_queue *q = bdev_get_queue(era->origin_dev->bdev); 1681 - 1682 - if (!q->merge_bvec_fn) 1683 - return max_size; 1684 - 1685 - bvm->bi_bdev = era->origin_dev->bdev; 1686 - 1687 - return min(max_size, q->merge_bvec_fn(q, bvm, biovec)); 1688 - } 1689 - 1690 1676 static void era_io_hints(struct dm_target *ti, struct queue_limits *limits) 1691 1677 { 1692 1678 struct era *era = ti->private; ··· 1703 1717 .status = era_status, 1704 1718 .message = era_message, 1705 1719 .iterate_devices = era_iterate_devices, 1706 - .merge = era_merge, 1707 1720 .io_hints = era_io_hints 1708 1721 }; 1709 1722
+1 -17
drivers/md/dm-flakey.c
··· 296 296 * Drop writes? 297 297 */ 298 298 if (test_bit(DROP_WRITES, &fc->flags)) { 299 - bio_endio(bio, 0); 299 + bio_endio(bio); 300 300 return DM_MAPIO_SUBMITTED; 301 301 } 302 302 ··· 387 387 return r ? : __blkdev_driver_ioctl(dev->bdev, dev->mode, cmd, arg); 388 388 } 389 389 390 - static int flakey_merge(struct dm_target *ti, struct bvec_merge_data *bvm, 391 - struct bio_vec *biovec, int max_size) 392 - { 393 - struct flakey_c *fc = ti->private; 394 - struct request_queue *q = bdev_get_queue(fc->dev->bdev); 395 - 396 - if (!q->merge_bvec_fn) 397 - return max_size; 398 - 399 - bvm->bi_bdev = fc->dev->bdev; 400 - bvm->bi_sector = flakey_map_sector(ti, bvm->bi_sector); 401 - 402 - return min(max_size, q->merge_bvec_fn(q, bvm, biovec)); 403 - } 404 - 405 390 static int flakey_iterate_devices(struct dm_target *ti, iterate_devices_callout_fn fn, void *data) 406 391 { 407 392 struct flakey_c *fc = ti->private; ··· 404 419 .end_io = flakey_end_io, 405 420 .status = flakey_status, 406 421 .ioctl = flakey_ioctl, 407 - .merge = flakey_merge, 408 422 .iterate_devices = flakey_iterate_devices, 409 423 }; 410 424
+5 -3
drivers/md/dm-io.c
··· 134 134 complete_io(io); 135 135 } 136 136 137 - static void endio(struct bio *bio, int error) 137 + static void endio(struct bio *bio) 138 138 { 139 139 struct io *io; 140 140 unsigned region; 141 + int error; 141 142 142 - if (error && bio_data_dir(bio) == READ) 143 + if (bio->bi_error && bio_data_dir(bio) == READ) 143 144 zero_fill_bio(bio); 144 145 145 146 /* ··· 148 147 */ 149 148 retrieve_io_and_region_from_bio(bio, &io, &region); 150 149 150 + error = bio->bi_error; 151 151 bio_put(bio); 152 152 153 153 dec_count(io, region, error); ··· 316 314 if ((rw & REQ_DISCARD) || (rw & REQ_WRITE_SAME)) 317 315 num_bvecs = 1; 318 316 else 319 - num_bvecs = min_t(int, bio_get_nr_vecs(where->bdev), 317 + num_bvecs = min_t(int, BIO_MAX_PAGES, 320 318 dm_sector_div_up(remaining, (PAGE_SIZE >> SECTOR_SHIFT))); 321 319 322 320 bio = bio_alloc_bioset(GFP_NOIO, num_bvecs, io->client->bios);
-16
drivers/md/dm-linear.c
··· 130 130 return r ? : __blkdev_driver_ioctl(dev->bdev, dev->mode, cmd, arg); 131 131 } 132 132 133 - static int linear_merge(struct dm_target *ti, struct bvec_merge_data *bvm, 134 - struct bio_vec *biovec, int max_size) 135 - { 136 - struct linear_c *lc = ti->private; 137 - struct request_queue *q = bdev_get_queue(lc->dev->bdev); 138 - 139 - if (!q->merge_bvec_fn) 140 - return max_size; 141 - 142 - bvm->bi_bdev = lc->dev->bdev; 143 - bvm->bi_sector = linear_map_sector(ti, bvm->bi_sector); 144 - 145 - return min(max_size, q->merge_bvec_fn(q, bvm, biovec)); 146 - } 147 - 148 133 static int linear_iterate_devices(struct dm_target *ti, 149 134 iterate_devices_callout_fn fn, void *data) 150 135 { ··· 147 162 .map = linear_map, 148 163 .status = linear_status, 149 164 .ioctl = linear_ioctl, 150 - .merge = linear_merge, 151 165 .iterate_devices = linear_iterate_devices, 152 166 }; 153 167
+4 -23
drivers/md/dm-log-writes.c
··· 146 146 } 147 147 } 148 148 149 - static void log_end_io(struct bio *bio, int err) 149 + static void log_end_io(struct bio *bio) 150 150 { 151 151 struct log_writes_c *lc = bio->bi_private; 152 152 struct bio_vec *bvec; 153 153 int i; 154 154 155 - if (err) { 155 + if (bio->bi_error) { 156 156 unsigned long flags; 157 157 158 - DMERR("Error writing log block, error=%d", err); 158 + DMERR("Error writing log block, error=%d", bio->bi_error); 159 159 spin_lock_irqsave(&lc->blocks_lock, flags); 160 160 lc->logging_enabled = false; 161 161 spin_unlock_irqrestore(&lc->blocks_lock, flags); ··· 205 205 bio->bi_bdev = lc->logdev->bdev; 206 206 bio->bi_end_io = log_end_io; 207 207 bio->bi_private = lc; 208 - set_bit(BIO_UPTODATE, &bio->bi_flags); 209 208 210 209 page = alloc_page(GFP_KERNEL); 211 210 if (!page) { ··· 269 270 bio->bi_bdev = lc->logdev->bdev; 270 271 bio->bi_end_io = log_end_io; 271 272 bio->bi_private = lc; 272 - set_bit(BIO_UPTODATE, &bio->bi_flags); 273 273 274 274 for (i = 0; i < block->vec_cnt; i++) { 275 275 /* ··· 290 292 bio->bi_bdev = lc->logdev->bdev; 291 293 bio->bi_end_io = log_end_io; 292 294 bio->bi_private = lc; 293 - set_bit(BIO_UPTODATE, &bio->bi_flags); 294 295 295 296 ret = bio_add_page(bio, block->vecs[i].bv_page, 296 297 block->vecs[i].bv_len, 0); ··· 603 606 WARN_ON(flush_bio || fua_bio); 604 607 if (lc->device_supports_discard) 605 608 goto map_bio; 606 - bio_endio(bio, 0); 609 + bio_endio(bio); 607 610 return DM_MAPIO_SUBMITTED; 608 611 } 609 612 ··· 725 728 return r ? : __blkdev_driver_ioctl(dev->bdev, dev->mode, cmd, arg); 726 729 } 727 730 728 - static int log_writes_merge(struct dm_target *ti, struct bvec_merge_data *bvm, 729 - struct bio_vec *biovec, int max_size) 730 - { 731 - struct log_writes_c *lc = ti->private; 732 - struct request_queue *q = bdev_get_queue(lc->dev->bdev); 733 - 734 - if (!q->merge_bvec_fn) 735 - return max_size; 736 - 737 - bvm->bi_bdev = lc->dev->bdev; 738 - bvm->bi_sector = dm_target_offset(ti, bvm->bi_sector); 739 - 740 - return min(max_size, q->merge_bvec_fn(q, bvm, biovec)); 741 - } 742 - 743 731 static int log_writes_iterate_devices(struct dm_target *ti, 744 732 iterate_devices_callout_fn fn, 745 733 void *data) ··· 778 796 .end_io = normal_end_io, 779 797 .status = log_writes_status, 780 798 .ioctl = log_writes_ioctl, 781 - .merge = log_writes_merge, 782 799 .message = log_writes_message, 783 800 .iterate_devices = log_writes_iterate_devices, 784 801 .io_hints = log_writes_io_hints,
-19
drivers/md/dm-raid.c
··· 1717 1717 mddev_resume(&rs->md); 1718 1718 } 1719 1719 1720 - static int raid_merge(struct dm_target *ti, struct bvec_merge_data *bvm, 1721 - struct bio_vec *biovec, int max_size) 1722 - { 1723 - struct raid_set *rs = ti->private; 1724 - struct md_personality *pers = rs->md.pers; 1725 - 1726 - if (pers && pers->mergeable_bvec) 1727 - return min(max_size, pers->mergeable_bvec(&rs->md, bvm, biovec)); 1728 - 1729 - /* 1730 - * In case we can't request the personality because 1731 - * the raid set is not running yet 1732 - * 1733 - * -> return safe minimum 1734 - */ 1735 - return rs->md.chunk_sectors; 1736 - } 1737 - 1738 1720 static struct target_type raid_target = { 1739 1721 .name = "raid", 1740 1722 .version = {1, 7, 0}, ··· 1731 1749 .presuspend = raid_presuspend, 1732 1750 .postsuspend = raid_postsuspend, 1733 1751 .resume = raid_resume, 1734 - .merge = raid_merge, 1735 1752 }; 1736 1753 1737 1754 static int __init dm_raid_init(void)
+13 -11
drivers/md/dm-raid1.c
··· 490 490 * If device is suspended, complete the bio. 491 491 */ 492 492 if (dm_noflush_suspending(ms->ti)) 493 - bio_endio(bio, DM_ENDIO_REQUEUE); 493 + bio->bi_error = DM_ENDIO_REQUEUE; 494 494 else 495 - bio_endio(bio, -EIO); 495 + bio->bi_error = -EIO; 496 + 497 + bio_endio(bio); 496 498 return; 497 499 } 498 500 ··· 517 515 bio_set_m(bio, NULL); 518 516 519 517 if (likely(!error)) { 520 - bio_endio(bio, 0); 518 + bio_endio(bio); 521 519 return; 522 520 } 523 521 ··· 533 531 534 532 DMERR_LIMIT("Read failure on mirror device %s. Failing I/O.", 535 533 m->dev->name); 536 - bio_endio(bio, -EIO); 534 + bio_io_error(bio); 537 535 } 538 536 539 537 /* Asynchronous read. */ ··· 582 580 if (likely(m)) 583 581 read_async_bio(m, bio); 584 582 else 585 - bio_endio(bio, -EIO); 583 + bio_io_error(bio); 586 584 } 587 585 } 588 586 ··· 600 598 601 599 static void write_callback(unsigned long error, void *context) 602 600 { 603 - unsigned i, ret = 0; 601 + unsigned i; 604 602 struct bio *bio = (struct bio *) context; 605 603 struct mirror_set *ms; 606 604 int should_wake = 0; ··· 616 614 * regions with the same code. 617 615 */ 618 616 if (likely(!error)) { 619 - bio_endio(bio, ret); 617 + bio_endio(bio); 620 618 return; 621 619 } 622 620 ··· 625 623 * degrade the array. 626 624 */ 627 625 if (bio->bi_rw & REQ_DISCARD) { 628 - bio_endio(bio, -EOPNOTSUPP); 626 + bio->bi_error = -EOPNOTSUPP; 627 + bio_endio(bio); 629 628 return; 630 629 } 631 630 ··· 831 828 * be wrong if the failed leg returned after reboot and 832 829 * got replicated back to the good legs.) 833 830 */ 834 - 835 831 if (unlikely(!get_valid_mirror(ms) || (keep_log(ms) && ms->log_failure))) 836 - bio_endio(bio, -EIO); 832 + bio_io_error(bio); 837 833 else if (errors_handled(ms) && !keep_log(ms)) 838 834 hold_bio(ms, bio); 839 835 else 840 - bio_endio(bio, 0); 836 + bio_endio(bio); 841 837 } 842 838 } 843 839
+3 -18
drivers/md/dm-snap.c
··· 1490 1490 error_bios(snapshot_bios); 1491 1491 } else { 1492 1492 if (full_bio) 1493 - bio_endio(full_bio, 0); 1493 + bio_endio(full_bio); 1494 1494 flush_bios(snapshot_bios); 1495 1495 } 1496 1496 ··· 1580 1580 dm_kcopyd_copy(s->kcopyd_client, &src, 1, &dest, 0, copy_callback, pe); 1581 1581 } 1582 1582 1583 - static void full_bio_end_io(struct bio *bio, int error) 1583 + static void full_bio_end_io(struct bio *bio) 1584 1584 { 1585 1585 void *callback_data = bio->bi_private; 1586 1586 1587 - dm_kcopyd_do_callback(callback_data, 0, error ? 1 : 0); 1587 + dm_kcopyd_do_callback(callback_data, 0, bio->bi_error ? 1 : 0); 1588 1588 } 1589 1589 1590 1590 static void start_full_bio(struct dm_snap_pending_exception *pe, ··· 2330 2330 } 2331 2331 } 2332 2332 2333 - static int origin_merge(struct dm_target *ti, struct bvec_merge_data *bvm, 2334 - struct bio_vec *biovec, int max_size) 2335 - { 2336 - struct dm_origin *o = ti->private; 2337 - struct request_queue *q = bdev_get_queue(o->dev->bdev); 2338 - 2339 - if (!q->merge_bvec_fn) 2340 - return max_size; 2341 - 2342 - bvm->bi_bdev = o->dev->bdev; 2343 - 2344 - return min(max_size, q->merge_bvec_fn(q, bvm, biovec)); 2345 - } 2346 - 2347 2333 static int origin_iterate_devices(struct dm_target *ti, 2348 2334 iterate_devices_callout_fn fn, void *data) 2349 2335 { ··· 2348 2362 .resume = origin_resume, 2349 2363 .postsuspend = origin_postsuspend, 2350 2364 .status = origin_status, 2351 - .merge = origin_merge, 2352 2365 .iterate_devices = origin_iterate_devices, 2353 2366 }; 2354 2367
+1 -22
drivers/md/dm-stripe.c
··· 273 273 return DM_MAPIO_REMAPPED; 274 274 } else { 275 275 /* The range doesn't map to the target stripe */ 276 - bio_endio(bio, 0); 276 + bio_endio(bio); 277 277 return DM_MAPIO_SUBMITTED; 278 278 } 279 279 } ··· 412 412 blk_limits_io_opt(limits, chunk_size * sc->stripes); 413 413 } 414 414 415 - static int stripe_merge(struct dm_target *ti, struct bvec_merge_data *bvm, 416 - struct bio_vec *biovec, int max_size) 417 - { 418 - struct stripe_c *sc = ti->private; 419 - sector_t bvm_sector = bvm->bi_sector; 420 - uint32_t stripe; 421 - struct request_queue *q; 422 - 423 - stripe_map_sector(sc, bvm_sector, &stripe, &bvm_sector); 424 - 425 - q = bdev_get_queue(sc->stripe[stripe].dev->bdev); 426 - if (!q->merge_bvec_fn) 427 - return max_size; 428 - 429 - bvm->bi_bdev = sc->stripe[stripe].dev->bdev; 430 - bvm->bi_sector = sc->stripe[stripe].physical_start + bvm_sector; 431 - 432 - return min(max_size, q->merge_bvec_fn(q, bvm, biovec)); 433 - } 434 - 435 415 static struct target_type stripe_target = { 436 416 .name = "striped", 437 417 .version = {1, 5, 1}, ··· 423 443 .status = stripe_status, 424 444 .iterate_devices = stripe_iterate_devices, 425 445 .io_hints = stripe_io_hints, 426 - .merge = stripe_merge, 427 446 }; 428 447 429 448 int __init dm_stripe_init(void)
-21
drivers/md/dm-table.c
··· 440 440 q->limits.alignment_offset, 441 441 (unsigned long long) start << SECTOR_SHIFT); 442 442 443 - /* 444 - * Check if merge fn is supported. 445 - * If not we'll force DM to use PAGE_SIZE or 446 - * smaller I/O, just to be safe. 447 - */ 448 - if (dm_queue_merge_is_compulsory(q) && !ti->type->merge) 449 - blk_limits_max_hw_sectors(limits, 450 - (unsigned int) (PAGE_SIZE >> 9)); 451 443 return 0; 452 444 } 453 445 ··· 1380 1388 return q && !test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags); 1381 1389 } 1382 1390 1383 - static int queue_supports_sg_gaps(struct dm_target *ti, struct dm_dev *dev, 1384 - sector_t start, sector_t len, void *data) 1385 - { 1386 - struct request_queue *q = bdev_get_queue(dev->bdev); 1387 - 1388 - return q && !test_bit(QUEUE_FLAG_SG_GAPS, &q->queue_flags); 1389 - } 1390 - 1391 1391 static bool dm_table_all_devices_attribute(struct dm_table *t, 1392 1392 iterate_devices_callout_fn func) 1393 1393 { ··· 1499 1515 queue_flag_clear_unlocked(QUEUE_FLAG_NO_SG_MERGE, q); 1500 1516 else 1501 1517 queue_flag_set_unlocked(QUEUE_FLAG_NO_SG_MERGE, q); 1502 - 1503 - if (dm_table_all_devices_attribute(t, queue_supports_sg_gaps)) 1504 - queue_flag_clear_unlocked(QUEUE_FLAG_SG_GAPS, q); 1505 - else 1506 - queue_flag_set_unlocked(QUEUE_FLAG_SG_GAPS, q); 1507 1518 1508 1519 dm_table_set_integrity(t); 1509 1520
+23 -49
drivers/md/dm-thin.c
··· 615 615 { 616 616 struct bio *bio; 617 617 618 - while ((bio = bio_list_pop(bios))) 619 - bio_endio(bio, error); 618 + while ((bio = bio_list_pop(bios))) { 619 + bio->bi_error = error; 620 + bio_endio(bio); 621 + } 620 622 } 621 623 622 624 static void error_thin_bio_list(struct thin_c *tc, struct bio_list *master, int error) ··· 872 870 complete_mapping_preparation(m); 873 871 } 874 872 875 - static void overwrite_endio(struct bio *bio, int err) 873 + static void overwrite_endio(struct bio *bio) 876 874 { 877 875 struct dm_thin_endio_hook *h = dm_per_bio_data(bio, sizeof(struct dm_thin_endio_hook)); 878 876 struct dm_thin_new_mapping *m = h->overwrite_mapping; 879 877 880 878 bio->bi_end_io = m->saved_bi_end_io; 881 879 882 - m->err = err; 880 + m->err = bio->bi_error; 883 881 complete_mapping_preparation(m); 884 882 } 885 883 ··· 1004 1002 */ 1005 1003 if (bio) { 1006 1004 inc_remap_and_issue_cell(tc, m->cell, m->data_block); 1007 - bio_endio(bio, 0); 1005 + bio_endio(bio); 1008 1006 } else { 1009 1007 inc_all_io_entry(tc->pool, m->cell->holder); 1010 1008 remap_and_issue(tc, m->cell->holder, m->data_block); ··· 1034 1032 1035 1033 static void process_prepared_discard_success(struct dm_thin_new_mapping *m) 1036 1034 { 1037 - bio_endio(m->bio, 0); 1035 + bio_endio(m->bio); 1038 1036 free_discard_mapping(m); 1039 1037 } 1040 1038 ··· 1048 1046 metadata_operation_failed(tc->pool, "dm_thin_remove_range", r); 1049 1047 bio_io_error(m->bio); 1050 1048 } else 1051 - bio_endio(m->bio, 0); 1049 + bio_endio(m->bio); 1052 1050 1053 1051 cell_defer_no_holder(tc, m->cell); 1054 1052 mempool_free(m, tc->pool->mapping_pool); ··· 1119 1117 * Even if r is set, there could be sub discards in flight that we 1120 1118 * need to wait for. 1121 1119 */ 1122 - bio_endio(m->bio, r); 1120 + m->bio->bi_error = r; 1121 + bio_endio(m->bio); 1123 1122 cell_defer_no_holder(tc, m->cell); 1124 1123 mempool_free(m, pool->mapping_pool); 1125 1124 } ··· 1496 1493 { 1497 1494 int error = should_error_unserviceable_bio(pool); 1498 1495 1499 - if (error) 1500 - bio_endio(bio, error); 1501 - else 1496 + if (error) { 1497 + bio->bi_error = error; 1498 + bio_endio(bio); 1499 + } else 1502 1500 retry_on_resume(bio); 1503 1501 } 1504 1502 ··· 1635 1631 * will prevent completion until the sub range discards have 1636 1632 * completed. 1637 1633 */ 1638 - bio_endio(bio, 0); 1634 + bio_endio(bio); 1639 1635 } 1640 1636 1641 1637 static void process_discard_bio(struct thin_c *tc, struct bio *bio) ··· 1649 1645 /* 1650 1646 * The discard covers less than a block. 1651 1647 */ 1652 - bio_endio(bio, 0); 1648 + bio_endio(bio); 1653 1649 return; 1654 1650 } 1655 1651 ··· 1794 1790 if (bio_data_dir(bio) == READ) { 1795 1791 zero_fill_bio(bio); 1796 1792 cell_defer_no_holder(tc, cell); 1797 - bio_endio(bio, 0); 1793 + bio_endio(bio); 1798 1794 return; 1799 1795 } 1800 1796 ··· 1859 1855 1860 1856 } else { 1861 1857 zero_fill_bio(bio); 1862 - bio_endio(bio, 0); 1858 + bio_endio(bio); 1863 1859 } 1864 1860 } else 1865 1861 provision_block(tc, bio, block, cell); ··· 1930 1926 } 1931 1927 1932 1928 zero_fill_bio(bio); 1933 - bio_endio(bio, 0); 1929 + bio_endio(bio); 1934 1930 break; 1935 1931 1936 1932 default: ··· 1955 1951 1956 1952 static void process_bio_success(struct thin_c *tc, struct bio *bio) 1957 1953 { 1958 - bio_endio(bio, 0); 1954 + bio_endio(bio); 1959 1955 } 1960 1956 1961 1957 static void process_bio_fail(struct thin_c *tc, struct bio *bio) ··· 2604 2600 thin_hook_bio(tc, bio); 2605 2601 2606 2602 if (tc->requeue_mode) { 2607 - bio_endio(bio, DM_ENDIO_REQUEUE); 2603 + bio->bi_error = DM_ENDIO_REQUEUE; 2604 + bio_endio(bio); 2608 2605 return DM_MAPIO_SUBMITTED; 2609 2606 } 2610 2607 ··· 3880 3875 return fn(ti, pt->data_dev, 0, ti->len, data); 3881 3876 } 3882 3877 3883 - static int pool_merge(struct dm_target *ti, struct bvec_merge_data *bvm, 3884 - struct bio_vec *biovec, int max_size) 3885 - { 3886 - struct pool_c *pt = ti->private; 3887 - struct request_queue *q = bdev_get_queue(pt->data_dev->bdev); 3888 - 3889 - if (!q->merge_bvec_fn) 3890 - return max_size; 3891 - 3892 - bvm->bi_bdev = pt->data_dev->bdev; 3893 - 3894 - return min(max_size, q->merge_bvec_fn(q, bvm, biovec)); 3895 - } 3896 - 3897 3878 static void pool_io_hints(struct dm_target *ti, struct queue_limits *limits) 3898 3879 { 3899 3880 struct pool_c *pt = ti->private; ··· 3956 3965 .resume = pool_resume, 3957 3966 .message = pool_message, 3958 3967 .status = pool_status, 3959 - .merge = pool_merge, 3960 3968 .iterate_devices = pool_iterate_devices, 3961 3969 .io_hints = pool_io_hints, 3962 3970 }; ··· 4282 4292 DMEMIT("Error"); 4283 4293 } 4284 4294 4285 - static int thin_merge(struct dm_target *ti, struct bvec_merge_data *bvm, 4286 - struct bio_vec *biovec, int max_size) 4287 - { 4288 - struct thin_c *tc = ti->private; 4289 - struct request_queue *q = bdev_get_queue(tc->pool_dev->bdev); 4290 - 4291 - if (!q->merge_bvec_fn) 4292 - return max_size; 4293 - 4294 - bvm->bi_bdev = tc->pool_dev->bdev; 4295 - bvm->bi_sector = dm_target_offset(ti, bvm->bi_sector); 4296 - 4297 - return min(max_size, q->merge_bvec_fn(q, bvm, biovec)); 4298 - } 4299 - 4300 4295 static int thin_iterate_devices(struct dm_target *ti, 4301 4296 iterate_devices_callout_fn fn, void *data) 4302 4297 { ··· 4325 4350 .presuspend = thin_presuspend, 4326 4351 .postsuspend = thin_postsuspend, 4327 4352 .status = thin_status, 4328 - .merge = thin_merge, 4329 4353 .iterate_devices = thin_iterate_devices, 4330 4354 .io_hints = thin_io_hints, 4331 4355 };
+5 -20
drivers/md/dm-verity.c
··· 458 458 459 459 bio->bi_end_io = io->orig_bi_end_io; 460 460 bio->bi_private = io->orig_bi_private; 461 + bio->bi_error = error; 461 462 462 - bio_endio(bio, error); 463 + bio_endio(bio); 463 464 } 464 465 465 466 static void verity_work(struct work_struct *w) ··· 470 469 verity_finish_io(io, verity_verify_io(io)); 471 470 } 472 471 473 - static void verity_end_io(struct bio *bio, int error) 472 + static void verity_end_io(struct bio *bio) 474 473 { 475 474 struct dm_verity_io *io = bio->bi_private; 476 475 477 - if (error) { 478 - verity_finish_io(io, error); 476 + if (bio->bi_error) { 477 + verity_finish_io(io, bio->bi_error); 479 478 return; 480 479 } 481 480 ··· 647 646 648 647 return r ? : __blkdev_driver_ioctl(v->data_dev->bdev, v->data_dev->mode, 649 648 cmd, arg); 650 - } 651 - 652 - static int verity_merge(struct dm_target *ti, struct bvec_merge_data *bvm, 653 - struct bio_vec *biovec, int max_size) 654 - { 655 - struct dm_verity *v = ti->private; 656 - struct request_queue *q = bdev_get_queue(v->data_dev->bdev); 657 - 658 - if (!q->merge_bvec_fn) 659 - return max_size; 660 - 661 - bvm->bi_bdev = v->data_dev->bdev; 662 - bvm->bi_sector = verity_map_sector(v, bvm->bi_sector); 663 - 664 - return min(max_size, q->merge_bvec_fn(q, bvm, biovec)); 665 649 } 666 650 667 651 static int verity_iterate_devices(struct dm_target *ti, ··· 981 995 .map = verity_map, 982 996 .status = verity_status, 983 997 .ioctl = verity_ioctl, 984 - .merge = verity_merge, 985 998 .iterate_devices = verity_iterate_devices, 986 999 .io_hints = verity_io_hints, 987 1000 };
+1 -1
drivers/md/dm-zero.c
··· 47 47 break; 48 48 } 49 49 50 - bio_endio(bio, 0); 50 + bio_endio(bio); 51 51 52 52 /* accepted bio, don't make new request */ 53 53 return DM_MAPIO_SUBMITTED;
+11 -126
drivers/md/dm.c
··· 124 124 #define DMF_FREEING 3 125 125 #define DMF_DELETING 4 126 126 #define DMF_NOFLUSH_SUSPENDING 5 127 - #define DMF_MERGE_IS_OPTIONAL 6 128 - #define DMF_DEFERRED_REMOVE 7 129 - #define DMF_SUSPENDED_INTERNALLY 8 127 + #define DMF_DEFERRED_REMOVE 6 128 + #define DMF_SUSPENDED_INTERNALLY 7 130 129 131 130 /* 132 131 * A dummy definition to make RCU happy. ··· 943 944 } else { 944 945 /* done with normal IO or empty flush */ 945 946 trace_block_bio_complete(md->queue, bio, io_error); 946 - bio_endio(bio, io_error); 947 + bio->bi_error = io_error; 948 + bio_endio(bio); 947 949 } 948 950 } 949 951 } ··· 957 957 limits->max_write_same_sectors = 0; 958 958 } 959 959 960 - static void clone_endio(struct bio *bio, int error) 960 + static void clone_endio(struct bio *bio) 961 961 { 962 + int error = bio->bi_error; 962 963 int r = error; 963 964 struct dm_target_io *tio = container_of(bio, struct dm_target_io, clone); 964 965 struct dm_io *io = tio->io; 965 966 struct mapped_device *md = tio->io->md; 966 967 dm_endio_fn endio = tio->ti->type->end_io; 967 - 968 - if (!bio_flagged(bio, BIO_UPTODATE) && !error) 969 - error = -EIO; 970 968 971 969 if (endio) { 972 970 r = endio(tio->ti, bio, error); ··· 994 996 /* 995 997 * Partial completion handling for request-based dm 996 998 */ 997 - static void end_clone_bio(struct bio *clone, int error) 999 + static void end_clone_bio(struct bio *clone) 998 1000 { 999 1001 struct dm_rq_clone_bio_info *info = 1000 1002 container_of(clone, struct dm_rq_clone_bio_info, clone); ··· 1011 1013 * the remainder. 1012 1014 */ 1013 1015 return; 1014 - else if (error) { 1016 + else if (bio->bi_error) { 1015 1017 /* 1016 1018 * Don't notice the error to the upper layer yet. 1017 1019 * The error handling decision is made by the target driver, 1018 1020 * when the request is completed. 1019 1021 */ 1020 - tio->error = error; 1022 + tio->error = bio->bi_error; 1021 1023 return; 1022 1024 } 1023 1025 ··· 1720 1722 * CRUD END 1721 1723 *---------------------------------------------------------------*/ 1722 1724 1723 - static int dm_merge_bvec(struct request_queue *q, 1724 - struct bvec_merge_data *bvm, 1725 - struct bio_vec *biovec) 1726 - { 1727 - struct mapped_device *md = q->queuedata; 1728 - struct dm_table *map = dm_get_live_table_fast(md); 1729 - struct dm_target *ti; 1730 - sector_t max_sectors; 1731 - int max_size = 0; 1732 - 1733 - if (unlikely(!map)) 1734 - goto out; 1735 - 1736 - ti = dm_table_find_target(map, bvm->bi_sector); 1737 - if (!dm_target_is_valid(ti)) 1738 - goto out; 1739 - 1740 - /* 1741 - * Find maximum amount of I/O that won't need splitting 1742 - */ 1743 - max_sectors = min(max_io_len(bvm->bi_sector, ti), 1744 - (sector_t) BIO_MAX_SECTORS); 1745 - max_size = (max_sectors << SECTOR_SHIFT) - bvm->bi_size; 1746 - if (max_size < 0) 1747 - max_size = 0; 1748 - 1749 - /* 1750 - * merge_bvec_fn() returns number of bytes 1751 - * it can accept at this offset 1752 - * max is precomputed maximal io size 1753 - */ 1754 - if (max_size && ti->type->merge) 1755 - max_size = ti->type->merge(ti, bvm, biovec, max_size); 1756 - /* 1757 - * If the target doesn't support merge method and some of the devices 1758 - * provided their merge_bvec method (we know this by looking at 1759 - * queue_max_hw_sectors), then we can't allow bios with multiple vector 1760 - * entries. So always set max_size to 0, and the code below allows 1761 - * just one page. 1762 - */ 1763 - else if (queue_max_hw_sectors(q) <= PAGE_SIZE >> 9) 1764 - max_size = 0; 1765 - 1766 - out: 1767 - dm_put_live_table_fast(md); 1768 - /* 1769 - * Always allow an entire first page 1770 - */ 1771 - if (max_size <= biovec->bv_len && !(bvm->bi_size >> SECTOR_SHIFT)) 1772 - max_size = biovec->bv_len; 1773 - 1774 - return max_size; 1775 - } 1776 - 1777 1725 /* 1778 1726 * The request function that just remaps the bio built up by 1779 1727 * dm_merge_bvec. ··· 1732 1788 struct dm_table *map; 1733 1789 1734 1790 map = dm_get_live_table(md, &srcu_idx); 1791 + 1792 + blk_queue_split(q, &bio, q->bio_split); 1735 1793 1736 1794 generic_start_io_acct(rw, bio_sectors(bio), &dm_disk(md)->part0); 1737 1795 ··· 2442 2496 } 2443 2497 2444 2498 /* 2445 - * Return 1 if the queue has a compulsory merge_bvec_fn function. 2446 - * 2447 - * If this function returns 0, then the device is either a non-dm 2448 - * device without a merge_bvec_fn, or it is a dm device that is 2449 - * able to split any bios it receives that are too big. 2450 - */ 2451 - int dm_queue_merge_is_compulsory(struct request_queue *q) 2452 - { 2453 - struct mapped_device *dev_md; 2454 - 2455 - if (!q->merge_bvec_fn) 2456 - return 0; 2457 - 2458 - if (q->make_request_fn == dm_make_request) { 2459 - dev_md = q->queuedata; 2460 - if (test_bit(DMF_MERGE_IS_OPTIONAL, &dev_md->flags)) 2461 - return 0; 2462 - } 2463 - 2464 - return 1; 2465 - } 2466 - 2467 - static int dm_device_merge_is_compulsory(struct dm_target *ti, 2468 - struct dm_dev *dev, sector_t start, 2469 - sector_t len, void *data) 2470 - { 2471 - struct block_device *bdev = dev->bdev; 2472 - struct request_queue *q = bdev_get_queue(bdev); 2473 - 2474 - return dm_queue_merge_is_compulsory(q); 2475 - } 2476 - 2477 - /* 2478 - * Return 1 if it is acceptable to ignore merge_bvec_fn based 2479 - * on the properties of the underlying devices. 2480 - */ 2481 - static int dm_table_merge_is_optional(struct dm_table *table) 2482 - { 2483 - unsigned i = 0; 2484 - struct dm_target *ti; 2485 - 2486 - while (i < dm_table_get_num_targets(table)) { 2487 - ti = dm_table_get_target(table, i++); 2488 - 2489 - if (ti->type->iterate_devices && 2490 - ti->type->iterate_devices(ti, dm_device_merge_is_compulsory, NULL)) 2491 - return 0; 2492 - } 2493 - 2494 - return 1; 2495 - } 2496 - 2497 - /* 2498 2499 * Returns old map, which caller must destroy. 2499 2500 */ 2500 2501 static struct dm_table *__bind(struct mapped_device *md, struct dm_table *t, ··· 2450 2557 struct dm_table *old_map; 2451 2558 struct request_queue *q = md->queue; 2452 2559 sector_t size; 2453 - int merge_is_optional; 2454 2560 2455 2561 size = dm_table_get_size(t); 2456 2562 ··· 2475 2583 2476 2584 __bind_mempools(md, t); 2477 2585 2478 - merge_is_optional = dm_table_merge_is_optional(t); 2479 - 2480 2586 old_map = rcu_dereference_protected(md->map, lockdep_is_held(&md->suspend_lock)); 2481 2587 rcu_assign_pointer(md->map, t); 2482 2588 md->immutable_target_type = dm_table_get_immutable_target_type(t); 2483 2589 2484 2590 dm_table_set_restrictions(t, q, limits); 2485 - if (merge_is_optional) 2486 - set_bit(DMF_MERGE_IS_OPTIONAL, &md->flags); 2487 - else 2488 - clear_bit(DMF_MERGE_IS_OPTIONAL, &md->flags); 2489 2591 if (old_map) 2490 2592 dm_sync_table(md); 2491 2593 ··· 2760 2874 case DM_TYPE_BIO_BASED: 2761 2875 dm_init_old_md_queue(md); 2762 2876 blk_queue_make_request(md->queue, dm_make_request); 2763 - blk_queue_merge_bvec(md->queue, dm_merge_bvec); 2764 2877 break; 2765 2878 } 2766 2879
-2
drivers/md/dm.h
··· 78 78 void dm_table_free_md_mempools(struct dm_table *t); 79 79 struct dm_md_mempools *dm_table_get_md_mempools(struct dm_table *t); 80 80 81 - int dm_queue_merge_is_compulsory(struct request_queue *q); 82 - 83 81 void dm_lock_md_type(struct mapped_device *md); 84 82 void dm_unlock_md_type(struct mapped_device *md); 85 83 void dm_set_md_type(struct mapped_device *md, unsigned type);
+2 -2
drivers/md/faulty.c
··· 70 70 #include <linux/seq_file.h> 71 71 72 72 73 - static void faulty_fail(struct bio *bio, int error) 73 + static void faulty_fail(struct bio *bio) 74 74 { 75 75 struct bio *b = bio->bi_private; 76 76 ··· 181 181 /* special case - don't decrement, don't generic_make_request, 182 182 * just fail immediately 183 183 */ 184 - bio_endio(bio, -EIO); 184 + bio_io_error(bio); 185 185 return; 186 186 } 187 187
+1 -44
drivers/md/linear.c
··· 52 52 return conf->disks + lo; 53 53 } 54 54 55 - /** 56 - * linear_mergeable_bvec -- tell bio layer if two requests can be merged 57 - * @q: request queue 58 - * @bvm: properties of new bio 59 - * @biovec: the request that could be merged to it. 60 - * 61 - * Return amount of bytes we can take at this offset 62 - */ 63 - static int linear_mergeable_bvec(struct mddev *mddev, 64 - struct bvec_merge_data *bvm, 65 - struct bio_vec *biovec) 66 - { 67 - struct dev_info *dev0; 68 - unsigned long maxsectors, bio_sectors = bvm->bi_size >> 9; 69 - sector_t sector = bvm->bi_sector + get_start_sect(bvm->bi_bdev); 70 - int maxbytes = biovec->bv_len; 71 - struct request_queue *subq; 72 - 73 - dev0 = which_dev(mddev, sector); 74 - maxsectors = dev0->end_sector - sector; 75 - subq = bdev_get_queue(dev0->rdev->bdev); 76 - if (subq->merge_bvec_fn) { 77 - bvm->bi_bdev = dev0->rdev->bdev; 78 - bvm->bi_sector -= dev0->end_sector - dev0->rdev->sectors; 79 - maxbytes = min(maxbytes, subq->merge_bvec_fn(subq, bvm, 80 - biovec)); 81 - } 82 - 83 - if (maxsectors < bio_sectors) 84 - maxsectors = 0; 85 - else 86 - maxsectors -= bio_sectors; 87 - 88 - if (maxsectors <= (PAGE_SIZE >> 9 ) && bio_sectors == 0) 89 - return maxbytes; 90 - 91 - if (maxsectors > (maxbytes >> 9)) 92 - return maxbytes; 93 - else 94 - return maxsectors << 9; 95 - } 96 - 97 55 static int linear_congested(struct mddev *mddev, int bits) 98 56 { 99 57 struct linear_conf *conf; ··· 255 297 if (unlikely((split->bi_rw & REQ_DISCARD) && 256 298 !blk_queue_discard(bdev_get_queue(split->bi_bdev)))) { 257 299 /* Just ignore it */ 258 - bio_endio(split, 0); 300 + bio_endio(split); 259 301 } else 260 302 generic_make_request(split); 261 303 } while (split != bio); ··· 296 338 .size = linear_size, 297 339 .quiesce = linear_quiesce, 298 340 .congested = linear_congested, 299 - .mergeable_bvec = linear_mergeable_bvec, 300 341 }; 301 342 302 343 static int __init linear_init (void)
+11 -35
drivers/md/md.c
··· 257 257 unsigned int sectors; 258 258 int cpu; 259 259 260 + blk_queue_split(q, &bio, q->bio_split); 261 + 260 262 if (mddev == NULL || mddev->pers == NULL 261 263 || !mddev->ready) { 262 264 bio_io_error(bio); 263 265 return; 264 266 } 265 267 if (mddev->ro == 1 && unlikely(rw == WRITE)) { 266 - bio_endio(bio, bio_sectors(bio) == 0 ? 0 : -EROFS); 268 + if (bio_sectors(bio) != 0) 269 + bio->bi_error = -EROFS; 270 + bio_endio(bio); 267 271 return; 268 272 } 269 273 smp_rmb(); /* Ensure implications of 'active' are visible */ ··· 354 350 return mddev_congested(mddev, bits); 355 351 } 356 352 357 - static int md_mergeable_bvec(struct request_queue *q, 358 - struct bvec_merge_data *bvm, 359 - struct bio_vec *biovec) 360 - { 361 - struct mddev *mddev = q->queuedata; 362 - int ret; 363 - rcu_read_lock(); 364 - if (mddev->suspended) { 365 - /* Must always allow one vec */ 366 - if (bvm->bi_size == 0) 367 - ret = biovec->bv_len; 368 - else 369 - ret = 0; 370 - } else { 371 - struct md_personality *pers = mddev->pers; 372 - if (pers && pers->mergeable_bvec) 373 - ret = pers->mergeable_bvec(mddev, bvm, biovec); 374 - else 375 - ret = biovec->bv_len; 376 - } 377 - rcu_read_unlock(); 378 - return ret; 379 - } 380 353 /* 381 354 * Generic flush handling for md 382 355 */ 383 356 384 - static void md_end_flush(struct bio *bio, int err) 357 + static void md_end_flush(struct bio *bio) 385 358 { 386 359 struct md_rdev *rdev = bio->bi_private; 387 360 struct mddev *mddev = rdev->mddev; ··· 414 433 415 434 if (bio->bi_iter.bi_size == 0) 416 435 /* an empty barrier - all done */ 417 - bio_endio(bio, 0); 436 + bio_endio(bio); 418 437 else { 419 438 bio->bi_rw &= ~REQ_FLUSH; 420 439 mddev->pers->make_request(mddev, bio); ··· 709 728 } 710 729 EXPORT_SYMBOL_GPL(md_rdev_clear); 711 730 712 - static void super_written(struct bio *bio, int error) 731 + static void super_written(struct bio *bio) 713 732 { 714 733 struct md_rdev *rdev = bio->bi_private; 715 734 struct mddev *mddev = rdev->mddev; 716 735 717 - if (error || !test_bit(BIO_UPTODATE, &bio->bi_flags)) { 718 - printk("md: super_written gets error=%d, uptodate=%d\n", 719 - error, test_bit(BIO_UPTODATE, &bio->bi_flags)); 720 - WARN_ON(test_bit(BIO_UPTODATE, &bio->bi_flags)); 736 + if (bio->bi_error) { 737 + printk("md: super_written gets error=%d\n", bio->bi_error); 721 738 md_error(mddev, rdev); 722 739 } 723 740 ··· 770 791 bio_add_page(bio, page, size, 0); 771 792 submit_bio_wait(rw, bio); 772 793 773 - ret = test_bit(BIO_UPTODATE, &bio->bi_flags); 794 + ret = !bio->bi_error; 774 795 bio_put(bio); 775 796 return ret; 776 797 } ··· 5165 5186 if (mddev->queue) { 5166 5187 mddev->queue->backing_dev_info.congested_data = mddev; 5167 5188 mddev->queue->backing_dev_info.congested_fn = md_congested; 5168 - blk_queue_merge_bvec(mddev->queue, md_mergeable_bvec); 5169 5189 } 5170 5190 if (pers->sync_request) { 5171 5191 if (mddev->kobj.sd && ··· 5293 5315 mddev->degraded = 0; 5294 5316 mddev->safemode = 0; 5295 5317 mddev->private = NULL; 5296 - mddev->merge_check_needed = 0; 5297 5318 mddev->bitmap_info.offset = 0; 5298 5319 mddev->bitmap_info.default_offset = 0; 5299 5320 mddev->bitmap_info.default_space = 0; ··· 5491 5514 5492 5515 __md_stop_writes(mddev); 5493 5516 __md_stop(mddev); 5494 - mddev->queue->merge_bvec_fn = NULL; 5495 5517 mddev->queue->backing_dev_info.congested_fn = NULL; 5496 5518 5497 5519 /* tell userspace to handle 'inactive' */
-12
drivers/md/md.h
··· 134 134 Bitmap_sync, /* ..actually, not quite In_sync. Need a 135 135 * bitmap-based recovery to get fully in sync 136 136 */ 137 - Unmerged, /* device is being added to array and should 138 - * be considerred for bvec_merge_fn but not 139 - * yet for actual IO 140 - */ 141 137 WriteMostly, /* Avoid reading if at all possible */ 142 138 AutoDetected, /* added by auto-detect */ 143 139 Blocked, /* An error occurred but has not yet ··· 370 374 int degraded; /* whether md should consider 371 375 * adding a spare 372 376 */ 373 - int merge_check_needed; /* at least one 374 - * member device 375 - * has a 376 - * merge_bvec_fn */ 377 377 378 378 atomic_t recovery_active; /* blocks scheduled, but not written */ 379 379 wait_queue_head_t recovery_wait; ··· 524 532 /* congested implements bdi.congested_fn(). 525 533 * Will not be called while array is 'suspended' */ 526 534 int (*congested)(struct mddev *mddev, int bits); 527 - /* mergeable_bvec is use to implement ->merge_bvec_fn */ 528 - int (*mergeable_bvec)(struct mddev *mddev, 529 - struct bvec_merge_data *bvm, 530 - struct bio_vec *biovec); 531 535 }; 532 536 533 537 struct md_sysfs_entry {
+6 -27
drivers/md/multipath.c
··· 77 77 struct bio *bio = mp_bh->master_bio; 78 78 struct mpconf *conf = mp_bh->mddev->private; 79 79 80 - bio_endio(bio, err); 80 + bio->bi_error = err; 81 + bio_endio(bio); 81 82 mempool_free(mp_bh, conf->pool); 82 83 } 83 84 84 - static void multipath_end_request(struct bio *bio, int error) 85 + static void multipath_end_request(struct bio *bio) 85 86 { 86 - int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 87 87 struct multipath_bh *mp_bh = bio->bi_private; 88 88 struct mpconf *conf = mp_bh->mddev->private; 89 89 struct md_rdev *rdev = conf->multipaths[mp_bh->path].rdev; 90 90 91 - if (uptodate) 91 + if (!bio->bi_error) 92 92 multipath_end_bh_io(mp_bh, 0); 93 93 else if (!(bio->bi_rw & REQ_RAHEAD)) { 94 94 /* ··· 101 101 (unsigned long long)bio->bi_iter.bi_sector); 102 102 multipath_reschedule_retry(mp_bh); 103 103 } else 104 - multipath_end_bh_io(mp_bh, error); 104 + multipath_end_bh_io(mp_bh, bio->bi_error); 105 105 rdev_dec_pending(rdev, conf->mddev); 106 106 } 107 107 ··· 123 123 124 124 mp_bh->path = multipath_map(conf); 125 125 if (mp_bh->path < 0) { 126 - bio_endio(bio, -EIO); 126 + bio_io_error(bio); 127 127 mempool_free(mp_bh, conf->pool); 128 128 return; 129 129 } ··· 256 256 q = rdev->bdev->bd_disk->queue; 257 257 disk_stack_limits(mddev->gendisk, rdev->bdev, 258 258 rdev->data_offset << 9); 259 - 260 - /* as we don't honour merge_bvec_fn, we must never risk 261 - * violating it, so limit ->max_segments to one, lying 262 - * within a single page. 263 - * (Note: it is very unlikely that a device with 264 - * merge_bvec_fn will be involved in multipath.) 265 - */ 266 - if (q->merge_bvec_fn) { 267 - blk_queue_max_segments(mddev->queue, 1); 268 - blk_queue_segment_boundary(mddev->queue, 269 - PAGE_CACHE_SIZE - 1); 270 - } 271 259 272 260 spin_lock_irq(&conf->device_lock); 273 261 mddev->degraded--; ··· 419 431 disk->rdev = rdev; 420 432 disk_stack_limits(mddev->gendisk, rdev->bdev, 421 433 rdev->data_offset << 9); 422 - 423 - /* as we don't honour merge_bvec_fn, we must never risk 424 - * violating it, not that we ever expect a device with 425 - * a merge_bvec_fn to be involved in multipath */ 426 - if (rdev->bdev->bd_disk->queue->merge_bvec_fn) { 427 - blk_queue_max_segments(mddev->queue, 1); 428 - blk_queue_segment_boundary(mddev->queue, 429 - PAGE_CACHE_SIZE - 1); 430 - } 431 434 432 435 if (!test_bit(Faulty, &rdev->flags)) 433 436 working_disks++;
+1 -57
drivers/md/raid0.c
··· 192 192 disk_stack_limits(mddev->gendisk, rdev1->bdev, 193 193 rdev1->data_offset << 9); 194 194 195 - if (rdev1->bdev->bd_disk->queue->merge_bvec_fn) 196 - conf->has_merge_bvec = 1; 197 - 198 195 if (!smallest || (rdev1->sectors < smallest->sectors)) 199 196 smallest = rdev1; 200 197 cnt++; ··· 348 351 + sector_div(sector, zone->nb_dev)]; 349 352 } 350 353 351 - /** 352 - * raid0_mergeable_bvec -- tell bio layer if two requests can be merged 353 - * @mddev: the md device 354 - * @bvm: properties of new bio 355 - * @biovec: the request that could be merged to it. 356 - * 357 - * Return amount of bytes we can accept at this offset 358 - */ 359 - static int raid0_mergeable_bvec(struct mddev *mddev, 360 - struct bvec_merge_data *bvm, 361 - struct bio_vec *biovec) 362 - { 363 - struct r0conf *conf = mddev->private; 364 - sector_t sector = bvm->bi_sector + get_start_sect(bvm->bi_bdev); 365 - sector_t sector_offset = sector; 366 - int max; 367 - unsigned int chunk_sectors = mddev->chunk_sectors; 368 - unsigned int bio_sectors = bvm->bi_size >> 9; 369 - struct strip_zone *zone; 370 - struct md_rdev *rdev; 371 - struct request_queue *subq; 372 - 373 - if (is_power_of_2(chunk_sectors)) 374 - max = (chunk_sectors - ((sector & (chunk_sectors-1)) 375 - + bio_sectors)) << 9; 376 - else 377 - max = (chunk_sectors - (sector_div(sector, chunk_sectors) 378 - + bio_sectors)) << 9; 379 - if (max < 0) 380 - max = 0; /* bio_add cannot handle a negative return */ 381 - if (max <= biovec->bv_len && bio_sectors == 0) 382 - return biovec->bv_len; 383 - if (max < biovec->bv_len) 384 - /* too small already, no need to check further */ 385 - return max; 386 - if (!conf->has_merge_bvec) 387 - return max; 388 - 389 - /* May need to check subordinate device */ 390 - sector = sector_offset; 391 - zone = find_zone(mddev->private, &sector_offset); 392 - rdev = map_sector(mddev, zone, sector, &sector_offset); 393 - subq = bdev_get_queue(rdev->bdev); 394 - if (subq->merge_bvec_fn) { 395 - bvm->bi_bdev = rdev->bdev; 396 - bvm->bi_sector = sector_offset + zone->dev_start + 397 - rdev->data_offset; 398 - return min(max, subq->merge_bvec_fn(subq, bvm, biovec)); 399 - } else 400 - return max; 401 - } 402 - 403 354 static sector_t raid0_size(struct mddev *mddev, sector_t sectors, int raid_disks) 404 355 { 405 356 sector_t array_sectors = 0; ··· 488 543 if (unlikely((split->bi_rw & REQ_DISCARD) && 489 544 !blk_queue_discard(bdev_get_queue(split->bi_bdev)))) { 490 545 /* Just ignore it */ 491 - bio_endio(split, 0); 546 + bio_endio(split); 492 547 } else 493 548 generic_make_request(split); 494 549 } while (split != bio); ··· 672 727 .takeover = raid0_takeover, 673 728 .quiesce = raid0_quiesce, 674 729 .congested = raid0_congested, 675 - .mergeable_bvec = raid0_mergeable_bvec, 676 730 }; 677 731 678 732 static int __init raid0_init (void)
-2
drivers/md/raid0.h
··· 12 12 struct md_rdev **devlist; /* lists of rdevs, pointed to 13 13 * by strip_zone->dev */ 14 14 int nr_strip_zones; 15 - int has_merge_bvec; /* at least one member has 16 - * a merge_bvec_fn */ 17 15 }; 18 16 19 17 #endif
+29 -86
drivers/md/raid1.c
··· 255 255 done = 1; 256 256 257 257 if (!test_bit(R1BIO_Uptodate, &r1_bio->state)) 258 - clear_bit(BIO_UPTODATE, &bio->bi_flags); 258 + bio->bi_error = -EIO; 259 + 259 260 if (done) { 260 - bio_endio(bio, 0); 261 + bio_endio(bio); 261 262 /* 262 263 * Wake up any possible resync thread that waits for the device 263 264 * to go idle. ··· 313 312 return mirror; 314 313 } 315 314 316 - static void raid1_end_read_request(struct bio *bio, int error) 315 + static void raid1_end_read_request(struct bio *bio) 317 316 { 318 - int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 317 + int uptodate = !bio->bi_error; 319 318 struct r1bio *r1_bio = bio->bi_private; 320 319 int mirror; 321 320 struct r1conf *conf = r1_bio->mddev->private; ··· 398 397 } 399 398 } 400 399 401 - static void raid1_end_write_request(struct bio *bio, int error) 400 + static void raid1_end_write_request(struct bio *bio) 402 401 { 403 - int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 404 402 struct r1bio *r1_bio = bio->bi_private; 405 403 int mirror, behind = test_bit(R1BIO_BehindIO, &r1_bio->state); 406 404 struct r1conf *conf = r1_bio->mddev->private; ··· 410 410 /* 411 411 * 'one mirror IO has finished' event handler: 412 412 */ 413 - if (!uptodate) { 413 + if (bio->bi_error) { 414 414 set_bit(WriteErrorSeen, 415 415 &conf->mirrors[mirror].rdev->flags); 416 416 if (!test_and_set_bit(WantReplacement, ··· 557 557 rdev = rcu_dereference(conf->mirrors[disk].rdev); 558 558 if (r1_bio->bios[disk] == IO_BLOCKED 559 559 || rdev == NULL 560 - || test_bit(Unmerged, &rdev->flags) 561 560 || test_bit(Faulty, &rdev->flags)) 562 561 continue; 563 562 if (!test_bit(In_sync, &rdev->flags) && ··· 707 708 return best_disk; 708 709 } 709 710 710 - static int raid1_mergeable_bvec(struct mddev *mddev, 711 - struct bvec_merge_data *bvm, 712 - struct bio_vec *biovec) 713 - { 714 - struct r1conf *conf = mddev->private; 715 - sector_t sector = bvm->bi_sector + get_start_sect(bvm->bi_bdev); 716 - int max = biovec->bv_len; 717 - 718 - if (mddev->merge_check_needed) { 719 - int disk; 720 - rcu_read_lock(); 721 - for (disk = 0; disk < conf->raid_disks * 2; disk++) { 722 - struct md_rdev *rdev = rcu_dereference( 723 - conf->mirrors[disk].rdev); 724 - if (rdev && !test_bit(Faulty, &rdev->flags)) { 725 - struct request_queue *q = 726 - bdev_get_queue(rdev->bdev); 727 - if (q->merge_bvec_fn) { 728 - bvm->bi_sector = sector + 729 - rdev->data_offset; 730 - bvm->bi_bdev = rdev->bdev; 731 - max = min(max, q->merge_bvec_fn( 732 - q, bvm, biovec)); 733 - } 734 - } 735 - } 736 - rcu_read_unlock(); 737 - } 738 - return max; 739 - 740 - } 741 - 742 711 static int raid1_congested(struct mddev *mddev, int bits) 743 712 { 744 713 struct r1conf *conf = mddev->private; ··· 760 793 if (unlikely((bio->bi_rw & REQ_DISCARD) && 761 794 !blk_queue_discard(bdev_get_queue(bio->bi_bdev)))) 762 795 /* Just ignore it */ 763 - bio_endio(bio, 0); 796 + bio_endio(bio); 764 797 else 765 798 generic_make_request(bio); 766 799 bio = next; ··· 1035 1068 if (unlikely((bio->bi_rw & REQ_DISCARD) && 1036 1069 !blk_queue_discard(bdev_get_queue(bio->bi_bdev)))) 1037 1070 /* Just ignore it */ 1038 - bio_endio(bio, 0); 1071 + bio_endio(bio); 1039 1072 else 1040 1073 generic_make_request(bio); 1041 1074 bio = next; ··· 1125 1158 * non-zero, then it is the number of not-completed requests. 1126 1159 */ 1127 1160 bio->bi_phys_segments = 0; 1128 - clear_bit(BIO_SEG_VALID, &bio->bi_flags); 1161 + bio_clear_flag(bio, BIO_SEG_VALID); 1129 1162 1130 1163 if (rw == READ) { 1131 1164 /* ··· 1236 1269 break; 1237 1270 } 1238 1271 r1_bio->bios[i] = NULL; 1239 - if (!rdev || test_bit(Faulty, &rdev->flags) 1240 - || test_bit(Unmerged, &rdev->flags)) { 1272 + if (!rdev || test_bit(Faulty, &rdev->flags)) { 1241 1273 if (i < conf->raid_disks) 1242 1274 set_bit(R1BIO_Degraded, &r1_bio->state); 1243 1275 continue; ··· 1583 1617 struct raid1_info *p; 1584 1618 int first = 0; 1585 1619 int last = conf->raid_disks - 1; 1586 - struct request_queue *q = bdev_get_queue(rdev->bdev); 1587 1620 1588 1621 if (mddev->recovery_disabled == conf->recovery_disabled) 1589 1622 return -EBUSY; 1590 1623 1591 1624 if (rdev->raid_disk >= 0) 1592 1625 first = last = rdev->raid_disk; 1593 - 1594 - if (q->merge_bvec_fn) { 1595 - set_bit(Unmerged, &rdev->flags); 1596 - mddev->merge_check_needed = 1; 1597 - } 1598 1626 1599 1627 for (mirror = first; mirror <= last; mirror++) { 1600 1628 p = conf->mirrors+mirror; ··· 1620 1660 rcu_assign_pointer(p[conf->raid_disks].rdev, rdev); 1621 1661 break; 1622 1662 } 1623 - } 1624 - if (err == 0 && test_bit(Unmerged, &rdev->flags)) { 1625 - /* Some requests might not have seen this new 1626 - * merge_bvec_fn. We must wait for them to complete 1627 - * before merging the device fully. 1628 - * First we make sure any code which has tested 1629 - * our function has submitted the request, then 1630 - * we wait for all outstanding requests to complete. 1631 - */ 1632 - synchronize_sched(); 1633 - freeze_array(conf, 0); 1634 - unfreeze_array(conf); 1635 - clear_bit(Unmerged, &rdev->flags); 1636 1663 } 1637 1664 md_integrity_add_rdev(rdev, mddev); 1638 1665 if (mddev->queue && blk_queue_discard(bdev_get_queue(rdev->bdev))) ··· 1684 1737 return err; 1685 1738 } 1686 1739 1687 - static void end_sync_read(struct bio *bio, int error) 1740 + static void end_sync_read(struct bio *bio) 1688 1741 { 1689 1742 struct r1bio *r1_bio = bio->bi_private; 1690 1743 ··· 1695 1748 * or re-read if the read failed. 1696 1749 * We don't do much here, just schedule handling by raid1d 1697 1750 */ 1698 - if (test_bit(BIO_UPTODATE, &bio->bi_flags)) 1751 + if (!bio->bi_error) 1699 1752 set_bit(R1BIO_Uptodate, &r1_bio->state); 1700 1753 1701 1754 if (atomic_dec_and_test(&r1_bio->remaining)) 1702 1755 reschedule_retry(r1_bio); 1703 1756 } 1704 1757 1705 - static void end_sync_write(struct bio *bio, int error) 1758 + static void end_sync_write(struct bio *bio) 1706 1759 { 1707 - int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 1760 + int uptodate = !bio->bi_error; 1708 1761 struct r1bio *r1_bio = bio->bi_private; 1709 1762 struct mddev *mddev = r1_bio->mddev; 1710 1763 struct r1conf *conf = mddev->private; ··· 1891 1944 idx ++; 1892 1945 } 1893 1946 set_bit(R1BIO_Uptodate, &r1_bio->state); 1894 - set_bit(BIO_UPTODATE, &bio->bi_flags); 1947 + bio->bi_error = 0; 1895 1948 return 1; 1896 1949 } 1897 1950 ··· 1915 1968 for (i = 0; i < conf->raid_disks * 2; i++) { 1916 1969 int j; 1917 1970 int size; 1918 - int uptodate; 1971 + int error; 1919 1972 struct bio *b = r1_bio->bios[i]; 1920 1973 if (b->bi_end_io != end_sync_read) 1921 1974 continue; 1922 - /* fixup the bio for reuse, but preserve BIO_UPTODATE */ 1923 - uptodate = test_bit(BIO_UPTODATE, &b->bi_flags); 1975 + /* fixup the bio for reuse, but preserve errno */ 1976 + error = b->bi_error; 1924 1977 bio_reset(b); 1925 - if (!uptodate) 1926 - clear_bit(BIO_UPTODATE, &b->bi_flags); 1978 + b->bi_error = error; 1927 1979 b->bi_vcnt = vcnt; 1928 1980 b->bi_iter.bi_size = r1_bio->sectors << 9; 1929 1981 b->bi_iter.bi_sector = r1_bio->sector + ··· 1945 1999 } 1946 2000 for (primary = 0; primary < conf->raid_disks * 2; primary++) 1947 2001 if (r1_bio->bios[primary]->bi_end_io == end_sync_read && 1948 - test_bit(BIO_UPTODATE, &r1_bio->bios[primary]->bi_flags)) { 2002 + !r1_bio->bios[primary]->bi_error) { 1949 2003 r1_bio->bios[primary]->bi_end_io = NULL; 1950 2004 rdev_dec_pending(conf->mirrors[primary].rdev, mddev); 1951 2005 break; ··· 1955 2009 int j; 1956 2010 struct bio *pbio = r1_bio->bios[primary]; 1957 2011 struct bio *sbio = r1_bio->bios[i]; 1958 - int uptodate = test_bit(BIO_UPTODATE, &sbio->bi_flags); 2012 + int error = sbio->bi_error; 1959 2013 1960 2014 if (sbio->bi_end_io != end_sync_read) 1961 2015 continue; 1962 - /* Now we can 'fixup' the BIO_UPTODATE flag */ 1963 - set_bit(BIO_UPTODATE, &sbio->bi_flags); 2016 + /* Now we can 'fixup' the error value */ 2017 + sbio->bi_error = 0; 1964 2018 1965 - if (uptodate) { 2019 + if (!error) { 1966 2020 for (j = vcnt; j-- ; ) { 1967 2021 struct page *p, *s; 1968 2022 p = pbio->bi_io_vec[j].bv_page; ··· 1977 2031 if (j >= 0) 1978 2032 atomic64_add(r1_bio->sectors, &mddev->resync_mismatches); 1979 2033 if (j < 0 || (test_bit(MD_RECOVERY_CHECK, &mddev->recovery) 1980 - && uptodate)) { 2034 + && !error)) { 1981 2035 /* No need to write to this device. */ 1982 2036 sbio->bi_end_io = NULL; 1983 2037 rdev_dec_pending(conf->mirrors[i].rdev, mddev); ··· 2218 2272 struct bio *bio = r1_bio->bios[m]; 2219 2273 if (bio->bi_end_io == NULL) 2220 2274 continue; 2221 - if (test_bit(BIO_UPTODATE, &bio->bi_flags) && 2275 + if (!bio->bi_error && 2222 2276 test_bit(R1BIO_MadeGood, &r1_bio->state)) { 2223 2277 rdev_clear_badblocks(rdev, r1_bio->sector, s, 0); 2224 2278 } 2225 - if (!test_bit(BIO_UPTODATE, &bio->bi_flags) && 2279 + if (bio->bi_error && 2226 2280 test_bit(R1BIO_WriteError, &r1_bio->state)) { 2227 2281 if (!rdev_set_badblocks(rdev, r1_bio->sector, s, 0)) 2228 2282 md_error(conf->mddev, rdev); ··· 2661 2715 /* remove last page from this bio */ 2662 2716 bio->bi_vcnt--; 2663 2717 bio->bi_iter.bi_size -= len; 2664 - __clear_bit(BIO_SEG_VALID, &bio->bi_flags); 2718 + bio_clear_flag(bio, BIO_SEG_VALID); 2665 2719 } 2666 2720 goto bio_full; 2667 2721 } ··· 2756 2810 goto abort; 2757 2811 disk->rdev = rdev; 2758 2812 q = bdev_get_queue(rdev->bdev); 2759 - if (q->merge_bvec_fn) 2760 - mddev->merge_check_needed = 1; 2761 2813 2762 2814 disk->head_position = 0; 2763 2815 disk->seq_start = MaxSector; ··· 3120 3176 .quiesce = raid1_quiesce, 3121 3177 .takeover = raid1_takeover, 3122 3178 .congested = raid1_congested, 3123 - .mergeable_bvec = raid1_mergeable_bvec, 3124 3179 }; 3125 3180 3126 3181 static int __init raid_init(void)
+31 -151
drivers/md/raid10.c
··· 101 101 static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr, 102 102 int *skipped); 103 103 static void reshape_request_write(struct mddev *mddev, struct r10bio *r10_bio); 104 - static void end_reshape_write(struct bio *bio, int error); 104 + static void end_reshape_write(struct bio *bio); 105 105 static void end_reshape(struct r10conf *conf); 106 106 107 107 static void * r10bio_pool_alloc(gfp_t gfp_flags, void *data) ··· 307 307 } else 308 308 done = 1; 309 309 if (!test_bit(R10BIO_Uptodate, &r10_bio->state)) 310 - clear_bit(BIO_UPTODATE, &bio->bi_flags); 310 + bio->bi_error = -EIO; 311 311 if (done) { 312 - bio_endio(bio, 0); 312 + bio_endio(bio); 313 313 /* 314 314 * Wake up any possible resync thread that waits for the device 315 315 * to go idle. ··· 358 358 return r10_bio->devs[slot].devnum; 359 359 } 360 360 361 - static void raid10_end_read_request(struct bio *bio, int error) 361 + static void raid10_end_read_request(struct bio *bio) 362 362 { 363 - int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 363 + int uptodate = !bio->bi_error; 364 364 struct r10bio *r10_bio = bio->bi_private; 365 365 int slot, dev; 366 366 struct md_rdev *rdev; ··· 438 438 } 439 439 } 440 440 441 - static void raid10_end_write_request(struct bio *bio, int error) 441 + static void raid10_end_write_request(struct bio *bio) 442 442 { 443 - int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 444 443 struct r10bio *r10_bio = bio->bi_private; 445 444 int dev; 446 445 int dec_rdev = 1; ··· 459 460 /* 460 461 * this branch is our 'one mirror IO has finished' event handler: 461 462 */ 462 - if (!uptodate) { 463 + if (bio->bi_error) { 463 464 if (repl) 464 465 /* Never record new bad blocks to replacement, 465 466 * just fail it. ··· 671 672 return (vchunk << geo->chunk_shift) + offset; 672 673 } 673 674 674 - /** 675 - * raid10_mergeable_bvec -- tell bio layer if a two requests can be merged 676 - * @mddev: the md device 677 - * @bvm: properties of new bio 678 - * @biovec: the request that could be merged to it. 679 - * 680 - * Return amount of bytes we can accept at this offset 681 - * This requires checking for end-of-chunk if near_copies != raid_disks, 682 - * and for subordinate merge_bvec_fns if merge_check_needed. 683 - */ 684 - static int raid10_mergeable_bvec(struct mddev *mddev, 685 - struct bvec_merge_data *bvm, 686 - struct bio_vec *biovec) 687 - { 688 - struct r10conf *conf = mddev->private; 689 - sector_t sector = bvm->bi_sector + get_start_sect(bvm->bi_bdev); 690 - int max; 691 - unsigned int chunk_sectors; 692 - unsigned int bio_sectors = bvm->bi_size >> 9; 693 - struct geom *geo = &conf->geo; 694 - 695 - chunk_sectors = (conf->geo.chunk_mask & conf->prev.chunk_mask) + 1; 696 - if (conf->reshape_progress != MaxSector && 697 - ((sector >= conf->reshape_progress) != 698 - conf->mddev->reshape_backwards)) 699 - geo = &conf->prev; 700 - 701 - if (geo->near_copies < geo->raid_disks) { 702 - max = (chunk_sectors - ((sector & (chunk_sectors - 1)) 703 - + bio_sectors)) << 9; 704 - if (max < 0) 705 - /* bio_add cannot handle a negative return */ 706 - max = 0; 707 - if (max <= biovec->bv_len && bio_sectors == 0) 708 - return biovec->bv_len; 709 - } else 710 - max = biovec->bv_len; 711 - 712 - if (mddev->merge_check_needed) { 713 - struct { 714 - struct r10bio r10_bio; 715 - struct r10dev devs[conf->copies]; 716 - } on_stack; 717 - struct r10bio *r10_bio = &on_stack.r10_bio; 718 - int s; 719 - if (conf->reshape_progress != MaxSector) { 720 - /* Cannot give any guidance during reshape */ 721 - if (max <= biovec->bv_len && bio_sectors == 0) 722 - return biovec->bv_len; 723 - return 0; 724 - } 725 - r10_bio->sector = sector; 726 - raid10_find_phys(conf, r10_bio); 727 - rcu_read_lock(); 728 - for (s = 0; s < conf->copies; s++) { 729 - int disk = r10_bio->devs[s].devnum; 730 - struct md_rdev *rdev = rcu_dereference( 731 - conf->mirrors[disk].rdev); 732 - if (rdev && !test_bit(Faulty, &rdev->flags)) { 733 - struct request_queue *q = 734 - bdev_get_queue(rdev->bdev); 735 - if (q->merge_bvec_fn) { 736 - bvm->bi_sector = r10_bio->devs[s].addr 737 - + rdev->data_offset; 738 - bvm->bi_bdev = rdev->bdev; 739 - max = min(max, q->merge_bvec_fn( 740 - q, bvm, biovec)); 741 - } 742 - } 743 - rdev = rcu_dereference(conf->mirrors[disk].replacement); 744 - if (rdev && !test_bit(Faulty, &rdev->flags)) { 745 - struct request_queue *q = 746 - bdev_get_queue(rdev->bdev); 747 - if (q->merge_bvec_fn) { 748 - bvm->bi_sector = r10_bio->devs[s].addr 749 - + rdev->data_offset; 750 - bvm->bi_bdev = rdev->bdev; 751 - max = min(max, q->merge_bvec_fn( 752 - q, bvm, biovec)); 753 - } 754 - } 755 - } 756 - rcu_read_unlock(); 757 - } 758 - return max; 759 - } 760 - 761 675 /* 762 676 * This routine returns the disk from which the requested read should 763 677 * be done. There is a per-array 'next expected sequential IO' sector ··· 733 821 disk = r10_bio->devs[slot].devnum; 734 822 rdev = rcu_dereference(conf->mirrors[disk].replacement); 735 823 if (rdev == NULL || test_bit(Faulty, &rdev->flags) || 736 - test_bit(Unmerged, &rdev->flags) || 737 824 r10_bio->devs[slot].addr + sectors > rdev->recovery_offset) 738 825 rdev = rcu_dereference(conf->mirrors[disk].rdev); 739 826 if (rdev == NULL || 740 - test_bit(Faulty, &rdev->flags) || 741 - test_bit(Unmerged, &rdev->flags)) 827 + test_bit(Faulty, &rdev->flags)) 742 828 continue; 743 829 if (!test_bit(In_sync, &rdev->flags) && 744 830 r10_bio->devs[slot].addr + sectors > rdev->recovery_offset) ··· 867 957 if (unlikely((bio->bi_rw & REQ_DISCARD) && 868 958 !blk_queue_discard(bdev_get_queue(bio->bi_bdev)))) 869 959 /* Just ignore it */ 870 - bio_endio(bio, 0); 960 + bio_endio(bio); 871 961 else 872 962 generic_make_request(bio); 873 963 bio = next; ··· 1043 1133 if (unlikely((bio->bi_rw & REQ_DISCARD) && 1044 1134 !blk_queue_discard(bdev_get_queue(bio->bi_bdev)))) 1045 1135 /* Just ignore it */ 1046 - bio_endio(bio, 0); 1136 + bio_endio(bio); 1047 1137 else 1048 1138 generic_make_request(bio); 1049 1139 bio = next; ··· 1127 1217 * non-zero, then it is the number of not-completed requests. 1128 1218 */ 1129 1219 bio->bi_phys_segments = 0; 1130 - clear_bit(BIO_SEG_VALID, &bio->bi_flags); 1220 + bio_clear_flag(bio, BIO_SEG_VALID); 1131 1221 1132 1222 if (rw == READ) { 1133 1223 /* ··· 1236 1326 blocked_rdev = rrdev; 1237 1327 break; 1238 1328 } 1239 - if (rdev && (test_bit(Faulty, &rdev->flags) 1240 - || test_bit(Unmerged, &rdev->flags))) 1329 + if (rdev && (test_bit(Faulty, &rdev->flags))) 1241 1330 rdev = NULL; 1242 - if (rrdev && (test_bit(Faulty, &rrdev->flags) 1243 - || test_bit(Unmerged, &rrdev->flags))) 1331 + if (rrdev && (test_bit(Faulty, &rrdev->flags))) 1244 1332 rrdev = NULL; 1245 1333 1246 1334 r10_bio->devs[i].bio = NULL; ··· 1685 1777 int mirror; 1686 1778 int first = 0; 1687 1779 int last = conf->geo.raid_disks - 1; 1688 - struct request_queue *q = bdev_get_queue(rdev->bdev); 1689 1780 1690 1781 if (mddev->recovery_cp < MaxSector) 1691 1782 /* only hot-add to in-sync arrays, as recovery is ··· 1696 1789 1697 1790 if (rdev->raid_disk >= 0) 1698 1791 first = last = rdev->raid_disk; 1699 - 1700 - if (q->merge_bvec_fn) { 1701 - set_bit(Unmerged, &rdev->flags); 1702 - mddev->merge_check_needed = 1; 1703 - } 1704 1792 1705 1793 if (rdev->saved_raid_disk >= first && 1706 1794 conf->mirrors[rdev->saved_raid_disk].rdev == NULL) ··· 1734 1832 conf->fullsync = 1; 1735 1833 rcu_assign_pointer(p->rdev, rdev); 1736 1834 break; 1737 - } 1738 - if (err == 0 && test_bit(Unmerged, &rdev->flags)) { 1739 - /* Some requests might not have seen this new 1740 - * merge_bvec_fn. We must wait for them to complete 1741 - * before merging the device fully. 1742 - * First we make sure any code which has tested 1743 - * our function has submitted the request, then 1744 - * we wait for all outstanding requests to complete. 1745 - */ 1746 - synchronize_sched(); 1747 - freeze_array(conf, 0); 1748 - unfreeze_array(conf); 1749 - clear_bit(Unmerged, &rdev->flags); 1750 1835 } 1751 1836 md_integrity_add_rdev(rdev, mddev); 1752 1837 if (mddev->queue && blk_queue_discard(bdev_get_queue(rdev->bdev))) ··· 1805 1916 return err; 1806 1917 } 1807 1918 1808 - static void end_sync_read(struct bio *bio, int error) 1919 + static void end_sync_read(struct bio *bio) 1809 1920 { 1810 1921 struct r10bio *r10_bio = bio->bi_private; 1811 1922 struct r10conf *conf = r10_bio->mddev->private; ··· 1817 1928 } else 1818 1929 d = find_bio_disk(conf, r10_bio, bio, NULL, NULL); 1819 1930 1820 - if (test_bit(BIO_UPTODATE, &bio->bi_flags)) 1931 + if (!bio->bi_error) 1821 1932 set_bit(R10BIO_Uptodate, &r10_bio->state); 1822 1933 else 1823 1934 /* The write handler will notice the lack of ··· 1866 1977 } 1867 1978 } 1868 1979 1869 - static void end_sync_write(struct bio *bio, int error) 1980 + static void end_sync_write(struct bio *bio) 1870 1981 { 1871 - int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 1872 1982 struct r10bio *r10_bio = bio->bi_private; 1873 1983 struct mddev *mddev = r10_bio->mddev; 1874 1984 struct r10conf *conf = mddev->private; ··· 1884 1996 else 1885 1997 rdev = conf->mirrors[d].rdev; 1886 1998 1887 - if (!uptodate) { 1999 + if (bio->bi_error) { 1888 2000 if (repl) 1889 2001 md_error(mddev, rdev); 1890 2002 else { ··· 1932 2044 1933 2045 /* find the first device with a block */ 1934 2046 for (i=0; i<conf->copies; i++) 1935 - if (test_bit(BIO_UPTODATE, &r10_bio->devs[i].bio->bi_flags)) 2047 + if (!r10_bio->devs[i].bio->bi_error) 1936 2048 break; 1937 2049 1938 2050 if (i == conf->copies) ··· 1952 2064 continue; 1953 2065 if (i == first) 1954 2066 continue; 1955 - if (test_bit(BIO_UPTODATE, &r10_bio->devs[i].bio->bi_flags)) { 2067 + if (!r10_bio->devs[i].bio->bi_error) { 1956 2068 /* We know that the bi_io_vec layout is the same for 1957 2069 * both 'first' and 'i', so we just compare them. 1958 2070 * All vec entries are PAGE_SIZE; ··· 2282 2394 d = r10_bio->devs[sl].devnum; 2283 2395 rdev = rcu_dereference(conf->mirrors[d].rdev); 2284 2396 if (rdev && 2285 - !test_bit(Unmerged, &rdev->flags) && 2286 2397 test_bit(In_sync, &rdev->flags) && 2287 2398 is_badblock(rdev, r10_bio->devs[sl].addr + sect, s, 2288 2399 &first_bad, &bad_sectors) == 0) { ··· 2335 2448 d = r10_bio->devs[sl].devnum; 2336 2449 rdev = rcu_dereference(conf->mirrors[d].rdev); 2337 2450 if (!rdev || 2338 - test_bit(Unmerged, &rdev->flags) || 2339 2451 !test_bit(In_sync, &rdev->flags)) 2340 2452 continue; 2341 2453 ··· 2592 2706 rdev = conf->mirrors[dev].rdev; 2593 2707 if (r10_bio->devs[m].bio == NULL) 2594 2708 continue; 2595 - if (test_bit(BIO_UPTODATE, 2596 - &r10_bio->devs[m].bio->bi_flags)) { 2709 + if (!r10_bio->devs[m].bio->bi_error) { 2597 2710 rdev_clear_badblocks( 2598 2711 rdev, 2599 2712 r10_bio->devs[m].addr, ··· 2607 2722 rdev = conf->mirrors[dev].replacement; 2608 2723 if (r10_bio->devs[m].repl_bio == NULL) 2609 2724 continue; 2610 - if (test_bit(BIO_UPTODATE, 2611 - &r10_bio->devs[m].repl_bio->bi_flags)) { 2725 + 2726 + if (!r10_bio->devs[m].repl_bio->bi_error) { 2612 2727 rdev_clear_badblocks( 2613 2728 rdev, 2614 2729 r10_bio->devs[m].addr, ··· 2633 2748 r10_bio->devs[m].addr, 2634 2749 r10_bio->sectors, 0); 2635 2750 rdev_dec_pending(rdev, conf->mddev); 2636 - } else if (bio != NULL && 2637 - !test_bit(BIO_UPTODATE, &bio->bi_flags)) { 2751 + } else if (bio != NULL && bio->bi_error) { 2638 2752 if (!narrow_write_error(r10_bio, m)) { 2639 2753 md_error(conf->mddev, rdev); 2640 2754 set_bit(R10BIO_Degraded, ··· 3147 3263 3148 3264 bio = r10_bio->devs[i].bio; 3149 3265 bio_reset(bio); 3150 - clear_bit(BIO_UPTODATE, &bio->bi_flags); 3266 + bio->bi_error = -EIO; 3151 3267 if (conf->mirrors[d].rdev == NULL || 3152 3268 test_bit(Faulty, &conf->mirrors[d].rdev->flags)) 3153 3269 continue; ··· 3184 3300 /* Need to set up for writing to the replacement */ 3185 3301 bio = r10_bio->devs[i].repl_bio; 3186 3302 bio_reset(bio); 3187 - clear_bit(BIO_UPTODATE, &bio->bi_flags); 3303 + bio->bi_error = -EIO; 3188 3304 3189 3305 sector = r10_bio->devs[i].addr; 3190 3306 atomic_inc(&conf->mirrors[d].rdev->nr_pending); ··· 3241 3357 /* remove last page from this bio */ 3242 3358 bio2->bi_vcnt--; 3243 3359 bio2->bi_iter.bi_size -= len; 3244 - __clear_bit(BIO_SEG_VALID, &bio2->bi_flags); 3360 + bio_clear_flag(bio2, BIO_SEG_VALID); 3245 3361 } 3246 3362 goto bio_full; 3247 3363 } ··· 3261 3377 3262 3378 if (bio->bi_end_io == end_sync_read) { 3263 3379 md_sync_acct(bio->bi_bdev, nr_sectors); 3264 - set_bit(BIO_UPTODATE, &bio->bi_flags); 3380 + bio->bi_error = 0; 3265 3381 generic_make_request(bio); 3266 3382 } 3267 3383 } ··· 3527 3643 disk->rdev = rdev; 3528 3644 } 3529 3645 q = bdev_get_queue(rdev->bdev); 3530 - if (q->merge_bvec_fn) 3531 - mddev->merge_check_needed = 1; 3532 3646 diff = (rdev->new_data_offset - rdev->data_offset); 3533 3647 if (!mddev->reshape_backwards) 3534 3648 diff = -diff; ··· 4264 4382 read_bio->bi_end_io = end_sync_read; 4265 4383 read_bio->bi_rw = READ; 4266 4384 read_bio->bi_flags &= (~0UL << BIO_RESET_BITS); 4267 - __set_bit(BIO_UPTODATE, &read_bio->bi_flags); 4385 + read_bio->bi_error = 0; 4268 4386 read_bio->bi_vcnt = 0; 4269 4387 read_bio->bi_iter.bi_size = 0; 4270 4388 r10_bio->master_bio = read_bio; ··· 4321 4439 /* Remove last page from this bio */ 4322 4440 bio2->bi_vcnt--; 4323 4441 bio2->bi_iter.bi_size -= len; 4324 - __clear_bit(BIO_SEG_VALID, &bio2->bi_flags); 4442 + bio_clear_flag(bio2, BIO_SEG_VALID); 4325 4443 } 4326 4444 goto bio_full; 4327 4445 } ··· 4486 4604 return 0; 4487 4605 } 4488 4606 4489 - static void end_reshape_write(struct bio *bio, int error) 4607 + static void end_reshape_write(struct bio *bio) 4490 4608 { 4491 - int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 4492 4609 struct r10bio *r10_bio = bio->bi_private; 4493 4610 struct mddev *mddev = r10_bio->mddev; 4494 4611 struct r10conf *conf = mddev->private; ··· 4504 4623 rdev = conf->mirrors[d].rdev; 4505 4624 } 4506 4625 4507 - if (!uptodate) { 4626 + if (bio->bi_error) { 4508 4627 /* FIXME should record badblock */ 4509 4628 md_error(mddev, rdev); 4510 4629 } ··· 4581 4700 .start_reshape = raid10_start_reshape, 4582 4701 .finish_reshape = raid10_finish_reshape, 4583 4702 .congested = raid10_congested, 4584 - .mergeable_bvec = raid10_mergeable_bvec, 4585 4703 }; 4586 4704 4587 4705 static int __init raid_init(void)
+61 -86
drivers/md/raid5.c
··· 233 233 bi->bi_iter.bi_size = 0; 234 234 trace_block_bio_complete(bdev_get_queue(bi->bi_bdev), 235 235 bi, 0); 236 - bio_endio(bi, 0); 236 + bio_endio(bi); 237 237 bi = return_bi; 238 238 } 239 239 } ··· 887 887 } 888 888 889 889 static void 890 - raid5_end_read_request(struct bio *bi, int error); 890 + raid5_end_read_request(struct bio *bi); 891 891 static void 892 - raid5_end_write_request(struct bio *bi, int error); 892 + raid5_end_write_request(struct bio *bi); 893 893 894 894 static void ops_run_io(struct stripe_head *sh, struct stripe_head_state *s) 895 895 { ··· 2282 2282 conf->slab_cache = NULL; 2283 2283 } 2284 2284 2285 - static void raid5_end_read_request(struct bio * bi, int error) 2285 + static void raid5_end_read_request(struct bio * bi) 2286 2286 { 2287 2287 struct stripe_head *sh = bi->bi_private; 2288 2288 struct r5conf *conf = sh->raid_conf; 2289 2289 int disks = sh->disks, i; 2290 - int uptodate = test_bit(BIO_UPTODATE, &bi->bi_flags); 2291 2290 char b[BDEVNAME_SIZE]; 2292 2291 struct md_rdev *rdev = NULL; 2293 2292 sector_t s; ··· 2295 2296 if (bi == &sh->dev[i].req) 2296 2297 break; 2297 2298 2298 - pr_debug("end_read_request %llu/%d, count: %d, uptodate %d.\n", 2299 + pr_debug("end_read_request %llu/%d, count: %d, error %d.\n", 2299 2300 (unsigned long long)sh->sector, i, atomic_read(&sh->count), 2300 - uptodate); 2301 + bi->bi_error); 2301 2302 if (i == disks) { 2302 2303 BUG(); 2303 2304 return; ··· 2316 2317 s = sh->sector + rdev->new_data_offset; 2317 2318 else 2318 2319 s = sh->sector + rdev->data_offset; 2319 - if (uptodate) { 2320 + if (!bi->bi_error) { 2320 2321 set_bit(R5_UPTODATE, &sh->dev[i].flags); 2321 2322 if (test_bit(R5_ReadError, &sh->dev[i].flags)) { 2322 2323 /* Note that this cannot happen on a ··· 2404 2405 release_stripe(sh); 2405 2406 } 2406 2407 2407 - static void raid5_end_write_request(struct bio *bi, int error) 2408 + static void raid5_end_write_request(struct bio *bi) 2408 2409 { 2409 2410 struct stripe_head *sh = bi->bi_private; 2410 2411 struct r5conf *conf = sh->raid_conf; 2411 2412 int disks = sh->disks, i; 2412 2413 struct md_rdev *uninitialized_var(rdev); 2413 - int uptodate = test_bit(BIO_UPTODATE, &bi->bi_flags); 2414 2414 sector_t first_bad; 2415 2415 int bad_sectors; 2416 2416 int replacement = 0; ··· 2432 2434 break; 2433 2435 } 2434 2436 } 2435 - pr_debug("end_write_request %llu/%d, count %d, uptodate: %d.\n", 2437 + pr_debug("end_write_request %llu/%d, count %d, error: %d.\n", 2436 2438 (unsigned long long)sh->sector, i, atomic_read(&sh->count), 2437 - uptodate); 2439 + bi->bi_error); 2438 2440 if (i == disks) { 2439 2441 BUG(); 2440 2442 return; 2441 2443 } 2442 2444 2443 2445 if (replacement) { 2444 - if (!uptodate) 2446 + if (bi->bi_error) 2445 2447 md_error(conf->mddev, rdev); 2446 2448 else if (is_badblock(rdev, sh->sector, 2447 2449 STRIPE_SECTORS, 2448 2450 &first_bad, &bad_sectors)) 2449 2451 set_bit(R5_MadeGoodRepl, &sh->dev[i].flags); 2450 2452 } else { 2451 - if (!uptodate) { 2453 + if (bi->bi_error) { 2452 2454 set_bit(STRIPE_DEGRADED, &sh->state); 2453 2455 set_bit(WriteErrorSeen, &rdev->flags); 2454 2456 set_bit(R5_WriteError, &sh->dev[i].flags); ··· 2469 2471 } 2470 2472 rdev_dec_pending(rdev, conf->mddev); 2471 2473 2472 - if (sh->batch_head && !uptodate && !replacement) 2474 + if (sh->batch_head && bi->bi_error && !replacement) 2473 2475 set_bit(STRIPE_BATCH_ERR, &sh->batch_head->state); 2474 2476 2475 2477 if (!test_and_clear_bit(R5_DOUBLE_LOCKED, &sh->dev[i].flags)) ··· 3110 3112 while (bi && bi->bi_iter.bi_sector < 3111 3113 sh->dev[i].sector + STRIPE_SECTORS) { 3112 3114 struct bio *nextbi = r5_next_bio(bi, sh->dev[i].sector); 3113 - clear_bit(BIO_UPTODATE, &bi->bi_flags); 3115 + 3116 + bi->bi_error = -EIO; 3114 3117 if (!raid5_dec_bi_active_stripes(bi)) { 3115 3118 md_write_end(conf->mddev); 3116 3119 bi->bi_next = *return_bi; ··· 3135 3136 while (bi && bi->bi_iter.bi_sector < 3136 3137 sh->dev[i].sector + STRIPE_SECTORS) { 3137 3138 struct bio *bi2 = r5_next_bio(bi, sh->dev[i].sector); 3138 - clear_bit(BIO_UPTODATE, &bi->bi_flags); 3139 + 3140 + bi->bi_error = -EIO; 3139 3141 if (!raid5_dec_bi_active_stripes(bi)) { 3140 3142 md_write_end(conf->mddev); 3141 3143 bi->bi_next = *return_bi; ··· 3161 3161 sh->dev[i].sector + STRIPE_SECTORS) { 3162 3162 struct bio *nextbi = 3163 3163 r5_next_bio(bi, sh->dev[i].sector); 3164 - clear_bit(BIO_UPTODATE, &bi->bi_flags); 3164 + 3165 + bi->bi_error = -EIO; 3165 3166 if (!raid5_dec_bi_active_stripes(bi)) { 3166 3167 bi->bi_next = *return_bi; 3167 3168 *return_bi = bi; ··· 4670 4669 return 0; 4671 4670 } 4672 4671 4673 - /* We want read requests to align with chunks where possible, 4674 - * but write requests don't need to. 4675 - */ 4676 - static int raid5_mergeable_bvec(struct mddev *mddev, 4677 - struct bvec_merge_data *bvm, 4678 - struct bio_vec *biovec) 4679 - { 4680 - sector_t sector = bvm->bi_sector + get_start_sect(bvm->bi_bdev); 4681 - int max; 4682 - unsigned int chunk_sectors = mddev->chunk_sectors; 4683 - unsigned int bio_sectors = bvm->bi_size >> 9; 4684 - 4685 - /* 4686 - * always allow writes to be mergeable, read as well if array 4687 - * is degraded as we'll go through stripe cache anyway. 4688 - */ 4689 - if ((bvm->bi_rw & 1) == WRITE || mddev->degraded) 4690 - return biovec->bv_len; 4691 - 4692 - if (mddev->new_chunk_sectors < mddev->chunk_sectors) 4693 - chunk_sectors = mddev->new_chunk_sectors; 4694 - max = (chunk_sectors - ((sector & (chunk_sectors - 1)) + bio_sectors)) << 9; 4695 - if (max < 0) max = 0; 4696 - if (max <= biovec->bv_len && bio_sectors == 0) 4697 - return biovec->bv_len; 4698 - else 4699 - return max; 4700 - } 4701 - 4702 4672 static int in_chunk_boundary(struct mddev *mddev, struct bio *bio) 4703 4673 { 4704 4674 sector_t sector = bio->bi_iter.bi_sector + get_start_sect(bio->bi_bdev); ··· 4728 4756 * first). 4729 4757 * If the read failed.. 4730 4758 */ 4731 - static void raid5_align_endio(struct bio *bi, int error) 4759 + static void raid5_align_endio(struct bio *bi) 4732 4760 { 4733 4761 struct bio* raid_bi = bi->bi_private; 4734 4762 struct mddev *mddev; 4735 4763 struct r5conf *conf; 4736 - int uptodate = test_bit(BIO_UPTODATE, &bi->bi_flags); 4737 4764 struct md_rdev *rdev; 4765 + int error = bi->bi_error; 4738 4766 4739 4767 bio_put(bi); 4740 4768 ··· 4745 4773 4746 4774 rdev_dec_pending(rdev, conf->mddev); 4747 4775 4748 - if (!error && uptodate) { 4776 + if (!error) { 4749 4777 trace_block_bio_complete(bdev_get_queue(raid_bi->bi_bdev), 4750 4778 raid_bi, 0); 4751 - bio_endio(raid_bi, 0); 4779 + bio_endio(raid_bi); 4752 4780 if (atomic_dec_and_test(&conf->active_aligned_reads)) 4753 4781 wake_up(&conf->wait_for_quiescent); 4754 4782 return; ··· 4759 4787 add_bio_to_retry(raid_bi, conf); 4760 4788 } 4761 4789 4762 - static int bio_fits_rdev(struct bio *bi) 4763 - { 4764 - struct request_queue *q = bdev_get_queue(bi->bi_bdev); 4765 - 4766 - if (bio_sectors(bi) > queue_max_sectors(q)) 4767 - return 0; 4768 - blk_recount_segments(q, bi); 4769 - if (bi->bi_phys_segments > queue_max_segments(q)) 4770 - return 0; 4771 - 4772 - if (q->merge_bvec_fn) 4773 - /* it's too hard to apply the merge_bvec_fn at this stage, 4774 - * just just give up 4775 - */ 4776 - return 0; 4777 - 4778 - return 1; 4779 - } 4780 - 4781 - static int chunk_aligned_read(struct mddev *mddev, struct bio * raid_bio) 4790 + static int raid5_read_one_chunk(struct mddev *mddev, struct bio *raid_bio) 4782 4791 { 4783 4792 struct r5conf *conf = mddev->private; 4784 4793 int dd_idx; ··· 4768 4815 sector_t end_sector; 4769 4816 4770 4817 if (!in_chunk_boundary(mddev, raid_bio)) { 4771 - pr_debug("chunk_aligned_read : non aligned\n"); 4818 + pr_debug("%s: non aligned\n", __func__); 4772 4819 return 0; 4773 4820 } 4774 4821 /* ··· 4810 4857 rcu_read_unlock(); 4811 4858 raid_bio->bi_next = (void*)rdev; 4812 4859 align_bi->bi_bdev = rdev->bdev; 4813 - __clear_bit(BIO_SEG_VALID, &align_bi->bi_flags); 4860 + bio_clear_flag(align_bi, BIO_SEG_VALID); 4814 4861 4815 - if (!bio_fits_rdev(align_bi) || 4816 - is_badblock(rdev, align_bi->bi_iter.bi_sector, 4862 + if (is_badblock(rdev, align_bi->bi_iter.bi_sector, 4817 4863 bio_sectors(align_bi), 4818 4864 &first_bad, &bad_sectors)) { 4819 - /* too big in some way, or has a known bad block */ 4820 4865 bio_put(align_bi); 4821 4866 rdev_dec_pending(rdev, mddev); 4822 4867 return 0; ··· 4841 4890 bio_put(align_bi); 4842 4891 return 0; 4843 4892 } 4893 + } 4894 + 4895 + static struct bio *chunk_aligned_read(struct mddev *mddev, struct bio *raid_bio) 4896 + { 4897 + struct bio *split; 4898 + 4899 + do { 4900 + sector_t sector = raid_bio->bi_iter.bi_sector; 4901 + unsigned chunk_sects = mddev->chunk_sectors; 4902 + unsigned sectors = chunk_sects - (sector & (chunk_sects-1)); 4903 + 4904 + if (sectors < bio_sectors(raid_bio)) { 4905 + split = bio_split(raid_bio, sectors, GFP_NOIO, fs_bio_set); 4906 + bio_chain(split, raid_bio); 4907 + } else 4908 + split = raid_bio; 4909 + 4910 + if (!raid5_read_one_chunk(mddev, split)) { 4911 + if (split != raid_bio) 4912 + generic_make_request(raid_bio); 4913 + return split; 4914 + } 4915 + } while (split != raid_bio); 4916 + 4917 + return NULL; 4844 4918 } 4845 4919 4846 4920 /* __get_priority_stripe - get the next stripe to process ··· 5116 5140 remaining = raid5_dec_bi_active_stripes(bi); 5117 5141 if (remaining == 0) { 5118 5142 md_write_end(mddev); 5119 - bio_endio(bi, 0); 5143 + bio_endio(bi); 5120 5144 } 5121 5145 } 5122 5146 ··· 5145 5169 * data on failed drives. 5146 5170 */ 5147 5171 if (rw == READ && mddev->degraded == 0 && 5148 - mddev->reshape_position == MaxSector && 5149 - chunk_aligned_read(mddev,bi)) 5150 - return; 5172 + mddev->reshape_position == MaxSector) { 5173 + bi = chunk_aligned_read(mddev, bi); 5174 + if (!bi) 5175 + return; 5176 + } 5151 5177 5152 5178 if (unlikely(bi->bi_rw & REQ_DISCARD)) { 5153 5179 make_discard_request(mddev, bi); ··· 5282 5304 release_stripe_plug(mddev, sh); 5283 5305 } else { 5284 5306 /* cannot get stripe for read-ahead, just give-up */ 5285 - clear_bit(BIO_UPTODATE, &bi->bi_flags); 5307 + bi->bi_error = -EIO; 5286 5308 break; 5287 5309 } 5288 5310 } ··· 5296 5318 5297 5319 trace_block_bio_complete(bdev_get_queue(bi->bi_bdev), 5298 5320 bi, 0); 5299 - bio_endio(bi, 0); 5321 + bio_endio(bi); 5300 5322 } 5301 5323 } 5302 5324 ··· 5692 5714 if (remaining == 0) { 5693 5715 trace_block_bio_complete(bdev_get_queue(raid_bio->bi_bdev), 5694 5716 raid_bio, 0); 5695 - bio_endio(raid_bio, 0); 5717 + bio_endio(raid_bio); 5696 5718 } 5697 5719 if (atomic_dec_and_test(&conf->active_aligned_reads)) 5698 5720 wake_up(&conf->wait_for_quiescent); ··· 7757 7779 .quiesce = raid5_quiesce, 7758 7780 .takeover = raid6_takeover, 7759 7781 .congested = raid5_congested, 7760 - .mergeable_bvec = raid5_mergeable_bvec, 7761 7782 }; 7762 7783 static struct md_personality raid5_personality = 7763 7784 { ··· 7780 7803 .quiesce = raid5_quiesce, 7781 7804 .takeover = raid5_takeover, 7782 7805 .congested = raid5_congested, 7783 - .mergeable_bvec = raid5_mergeable_bvec, 7784 7806 }; 7785 7807 7786 7808 static struct md_personality raid4_personality = ··· 7804 7828 .quiesce = raid5_quiesce, 7805 7829 .takeover = raid4_takeover, 7806 7830 .congested = raid5_congested, 7807 - .mergeable_bvec = raid5_mergeable_bvec, 7808 7831 }; 7809 7832 7810 7833 static int __init raid5_init(void)
+1 -1
drivers/mmc/card/queue.c
··· 165 165 return; 166 166 167 167 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); 168 - q->limits.max_discard_sectors = max_discard; 168 + blk_queue_max_discard_sectors(q, max_discard); 169 169 if (card->erased_byte == 0 && !mmc_can_discard(card)) 170 170 q->limits.discard_zeroes_data = 1; 171 171 q->limits.discard_granularity = card->pref_erase << 9;
+1 -1
drivers/mtd/mtd_blkdevs.c
··· 419 419 420 420 if (tr->discard) { 421 421 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, new->rq); 422 - new->rq->limits.max_discard_sectors = UINT_MAX; 422 + blk_queue_max_discard_sectors(new->rq, UINT_MAX); 423 423 } 424 424 425 425 gd->queue = new->rq;
+3 -2
drivers/nvdimm/blk.c
··· 180 180 * another kernel subsystem, and we just pass it through. 181 181 */ 182 182 if (bio_integrity_enabled(bio) && bio_integrity_prep(bio)) { 183 - err = -EIO; 183 + bio->bi_error = -EIO; 184 184 goto out; 185 185 } 186 186 ··· 199 199 "io error in %s sector %lld, len %d,\n", 200 200 (rw == READ) ? "READ" : "WRITE", 201 201 (unsigned long long) iter.bi_sector, len); 202 + bio->bi_error = err; 202 203 break; 203 204 } 204 205 } ··· 207 206 nd_iostat_end(bio, start); 208 207 209 208 out: 210 - bio_endio(bio, err); 209 + bio_endio(bio); 211 210 } 212 211 213 212 static int nd_blk_rw_bytes(struct nd_namespace_common *ndns,
+3 -2
drivers/nvdimm/btt.c
··· 1189 1189 * another kernel subsystem, and we just pass it through. 1190 1190 */ 1191 1191 if (bio_integrity_enabled(bio) && bio_integrity_prep(bio)) { 1192 - err = -EIO; 1192 + bio->bi_error = -EIO; 1193 1193 goto out; 1194 1194 } 1195 1195 ··· 1211 1211 "io error in %s sector %lld, len %d,\n", 1212 1212 (rw == READ) ? "READ" : "WRITE", 1213 1213 (unsigned long long) iter.bi_sector, len); 1214 + bio->bi_error = err; 1214 1215 break; 1215 1216 } 1216 1217 } ··· 1219 1218 nd_iostat_end(bio, start); 1220 1219 1221 1220 out: 1222 - bio_endio(bio, err); 1221 + bio_endio(bio); 1223 1222 } 1224 1223 1225 1224 static int btt_rw_page(struct block_device *bdev, sector_t sector,
+1 -1
drivers/nvdimm/pmem.c
··· 77 77 if (bio_data_dir(bio)) 78 78 wmb_pmem(); 79 79 80 - bio_endio(bio, 0); 80 + bio_endio(bio); 81 81 } 82 82 83 83 static int pmem_rw_page(struct block_device *bdev, sector_t sector,
+3 -1
drivers/s390/block/dcssblk.c
··· 826 826 unsigned long source_addr; 827 827 unsigned long bytes_done; 828 828 829 + blk_queue_split(q, &bio, q->bio_split); 830 + 829 831 bytes_done = 0; 830 832 dev_info = bio->bi_bdev->bd_disk->private_data; 831 833 if (dev_info == NULL) ··· 873 871 } 874 872 bytes_done += bvec.bv_len; 875 873 } 876 - bio_endio(bio, 0); 874 + bio_endio(bio); 877 875 return; 878 876 fail: 879 877 bio_io_error(bio);
+3 -2
drivers/s390/block/xpram.c
··· 190 190 unsigned long page_addr; 191 191 unsigned long bytes; 192 192 193 + blk_queue_split(q, &bio, q->bio_split); 194 + 193 195 if ((bio->bi_iter.bi_sector & 7) != 0 || 194 196 (bio->bi_iter.bi_size & 4095) != 0) 195 197 /* Request is not page-aligned. */ ··· 222 220 index++; 223 221 } 224 222 } 225 - set_bit(BIO_UPTODATE, &bio->bi_flags); 226 - bio_endio(bio, 0); 223 + bio_endio(bio); 227 224 return; 228 225 fail: 229 226 bio_io_error(bio);
+2 -2
drivers/scsi/sd.c
··· 647 647 switch (mode) { 648 648 649 649 case SD_LBP_DISABLE: 650 - q->limits.max_discard_sectors = 0; 650 + blk_queue_max_discard_sectors(q, 0); 651 651 queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, q); 652 652 return; 653 653 ··· 675 675 break; 676 676 } 677 677 678 - q->limits.max_discard_sectors = max_blocks * (logical_block_size >> 9); 678 + blk_queue_max_discard_sectors(q, max_blocks * (logical_block_size >> 9)); 679 679 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); 680 680 } 681 681
+4 -1
drivers/staging/lustre/lustre/llite/lloop.c
··· 340 340 int rw = bio_rw(old_bio); 341 341 int inactive; 342 342 343 + blk_queue_split(q, &old_bio, q->bio_split); 344 + 343 345 if (!lo) 344 346 goto err; 345 347 ··· 378 376 while (bio) { 379 377 struct bio *tmp = bio->bi_next; 380 378 bio->bi_next = NULL; 381 - bio_endio(bio, ret); 379 + bio->bi_error = ret; 380 + bio_endio(bio); 382 381 bio = tmp; 383 382 } 384 383 }
+7 -14
drivers/target/target_core_iblock.c
··· 306 306 kfree(ibr); 307 307 } 308 308 309 - static void iblock_bio_done(struct bio *bio, int err) 309 + static void iblock_bio_done(struct bio *bio) 310 310 { 311 311 struct se_cmd *cmd = bio->bi_private; 312 312 struct iblock_req *ibr = cmd->priv; 313 313 314 - /* 315 - * Set -EIO if !BIO_UPTODATE and the passed is still err=0 316 - */ 317 - if (!test_bit(BIO_UPTODATE, &bio->bi_flags) && !err) 318 - err = -EIO; 319 - 320 - if (err != 0) { 321 - pr_err("test_bit(BIO_UPTODATE) failed for bio: %p," 322 - " err: %d\n", bio, err); 314 + if (bio->bi_error) { 315 + pr_err("bio error: %p, err: %d\n", bio, bio->bi_error); 323 316 /* 324 317 * Bump the ib_bio_err_cnt and release bio. 325 318 */ ··· 363 370 blk_finish_plug(&plug); 364 371 } 365 372 366 - static void iblock_end_io_flush(struct bio *bio, int err) 373 + static void iblock_end_io_flush(struct bio *bio) 367 374 { 368 375 struct se_cmd *cmd = bio->bi_private; 369 376 370 - if (err) 371 - pr_err("IBLOCK: cache flush failed: %d\n", err); 377 + if (bio->bi_error) 378 + pr_err("IBLOCK: cache flush failed: %d\n", bio->bi_error); 372 379 373 380 if (cmd) { 374 - if (err) 381 + if (bio->bi_error) 375 382 target_complete_cmd(cmd, SAM_STAT_CHECK_CONDITION); 376 383 else 377 384 target_complete_cmd(cmd, SAM_STAT_GOOD);
+3 -3
drivers/target/target_core_pscsi.c
··· 852 852 return bl; 853 853 } 854 854 855 - static void pscsi_bi_endio(struct bio *bio, int error) 855 + static void pscsi_bi_endio(struct bio *bio) 856 856 { 857 857 bio_put(bio); 858 858 } ··· 973 973 while (*hbio) { 974 974 bio = *hbio; 975 975 *hbio = (*hbio)->bi_next; 976 - bio_endio(bio, 0); /* XXX: should be error */ 976 + bio_endio(bio); 977 977 } 978 978 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; 979 979 } ··· 1061 1061 while (hbio) { 1062 1062 struct bio *bio = hbio; 1063 1063 hbio = hbio->bi_next; 1064 - bio_endio(bio, 0); /* XXX: should be error */ 1064 + bio_endio(bio); 1065 1065 } 1066 1066 ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; 1067 1067 fail:
+5 -5
fs/btrfs/check-integrity.c
··· 343 343 struct btrfsic_state *state, 344 344 struct btrfsic_block *const block, 345 345 struct btrfs_super_block *const super_hdr); 346 - static void btrfsic_bio_end_io(struct bio *bp, int bio_error_status); 346 + static void btrfsic_bio_end_io(struct bio *bp); 347 347 static void btrfsic_bh_end_io(struct buffer_head *bh, int uptodate); 348 348 static int btrfsic_is_block_ref_by_superblock(const struct btrfsic_state *state, 349 349 const struct btrfsic_block *block, ··· 2207 2207 goto again; 2208 2208 } 2209 2209 2210 - static void btrfsic_bio_end_io(struct bio *bp, int bio_error_status) 2210 + static void btrfsic_bio_end_io(struct bio *bp) 2211 2211 { 2212 2212 struct btrfsic_block *block = (struct btrfsic_block *)bp->bi_private; 2213 2213 int iodone_w_error; ··· 2215 2215 /* mutex is not held! This is not save if IO is not yet completed 2216 2216 * on umount */ 2217 2217 iodone_w_error = 0; 2218 - if (bio_error_status) 2218 + if (bp->bi_error) 2219 2219 iodone_w_error = 1; 2220 2220 2221 2221 BUG_ON(NULL == block); ··· 2230 2230 BTRFSIC_PRINT_MASK_END_IO_BIO_BH)) 2231 2231 printk(KERN_INFO 2232 2232 "bio_end_io(err=%d) for %c @%llu (%s/%llu/%d)\n", 2233 - bio_error_status, 2233 + bp->bi_error, 2234 2234 btrfsic_get_block_type(dev_state->state, block), 2235 2235 block->logical_bytenr, dev_state->name, 2236 2236 block->dev_bytenr, block->mirror_num); ··· 2252 2252 block = next_block; 2253 2253 } while (NULL != block); 2254 2254 2255 - bp->bi_end_io(bp, bio_error_status); 2255 + bp->bi_end_io(bp); 2256 2256 } 2257 2257 2258 2258 static void btrfsic_bh_end_io(struct buffer_head *bh, int uptodate)
+15 -14
fs/btrfs/compression.c
··· 97 97 static struct bio *compressed_bio_alloc(struct block_device *bdev, 98 98 u64 first_byte, gfp_t gfp_flags) 99 99 { 100 - int nr_vecs; 101 - 102 - nr_vecs = bio_get_nr_vecs(bdev); 103 - return btrfs_bio_alloc(bdev, first_byte >> 9, nr_vecs, gfp_flags); 100 + return btrfs_bio_alloc(bdev, first_byte >> 9, BIO_MAX_PAGES, gfp_flags); 104 101 } 105 102 106 103 static int check_compressed_csum(struct inode *inode, ··· 149 152 * The compressed pages are freed here, and it must be run 150 153 * in process context 151 154 */ 152 - static void end_compressed_bio_read(struct bio *bio, int err) 155 + static void end_compressed_bio_read(struct bio *bio) 153 156 { 154 157 struct compressed_bio *cb = bio->bi_private; 155 158 struct inode *inode; ··· 157 160 unsigned long index; 158 161 int ret; 159 162 160 - if (err) 163 + if (bio->bi_error) 161 164 cb->errors = 1; 162 165 163 166 /* if there are more bios still pending for this compressed ··· 207 210 bio_for_each_segment_all(bvec, cb->orig_bio, i) 208 211 SetPageChecked(bvec->bv_page); 209 212 210 - bio_endio(cb->orig_bio, 0); 213 + bio_endio(cb->orig_bio); 211 214 } 212 215 213 216 /* finally free the cb struct */ ··· 263 266 * This also calls the writeback end hooks for the file pages so that 264 267 * metadata and checksums can be updated in the file. 265 268 */ 266 - static void end_compressed_bio_write(struct bio *bio, int err) 269 + static void end_compressed_bio_write(struct bio *bio) 267 270 { 268 271 struct extent_io_tree *tree; 269 272 struct compressed_bio *cb = bio->bi_private; ··· 271 274 struct page *page; 272 275 unsigned long index; 273 276 274 - if (err) 277 + if (bio->bi_error) 275 278 cb->errors = 1; 276 279 277 280 /* if there are more bios still pending for this compressed ··· 290 293 cb->start, 291 294 cb->start + cb->len - 1, 292 295 NULL, 293 - err ? 0 : 1); 296 + bio->bi_error ? 0 : 1); 294 297 cb->compressed_pages[0]->mapping = NULL; 295 298 296 299 end_compressed_writeback(inode, cb); ··· 694 697 695 698 ret = btrfs_map_bio(root, READ, comp_bio, 696 699 mirror_num, 0); 697 - if (ret) 698 - bio_endio(comp_bio, ret); 700 + if (ret) { 701 + bio->bi_error = ret; 702 + bio_endio(comp_bio); 703 + } 699 704 700 705 bio_put(comp_bio); 701 706 ··· 723 724 } 724 725 725 726 ret = btrfs_map_bio(root, READ, comp_bio, mirror_num, 0); 726 - if (ret) 727 - bio_endio(comp_bio, ret); 727 + if (ret) { 728 + bio->bi_error = ret; 729 + bio_endio(comp_bio); 730 + } 728 731 729 732 bio_put(comp_bio); 730 733 return 0;
+19 -16
fs/btrfs/disk-io.c
··· 703 703 return -EIO; /* we fixed nothing */ 704 704 } 705 705 706 - static void end_workqueue_bio(struct bio *bio, int err) 706 + static void end_workqueue_bio(struct bio *bio) 707 707 { 708 708 struct btrfs_end_io_wq *end_io_wq = bio->bi_private; 709 709 struct btrfs_fs_info *fs_info; ··· 711 711 btrfs_work_func_t func; 712 712 713 713 fs_info = end_io_wq->info; 714 - end_io_wq->error = err; 714 + end_io_wq->error = bio->bi_error; 715 715 716 716 if (bio->bi_rw & REQ_WRITE) { 717 717 if (end_io_wq->metadata == BTRFS_WQ_ENDIO_METADATA) { ··· 808 808 809 809 /* If an error occured we just want to clean up the bio and move on */ 810 810 if (async->error) { 811 - bio_endio(async->bio, async->error); 811 + async->bio->bi_error = async->error; 812 + bio_endio(async->bio); 812 813 return; 813 814 } 814 815 ··· 909 908 * submission context. Just jump into btrfs_map_bio 910 909 */ 911 910 ret = btrfs_map_bio(BTRFS_I(inode)->root, rw, bio, mirror_num, 1); 912 - if (ret) 913 - bio_endio(bio, ret); 911 + if (ret) { 912 + bio->bi_error = ret; 913 + bio_endio(bio); 914 + } 914 915 return ret; 915 916 } 916 917 ··· 963 960 __btree_submit_bio_done); 964 961 } 965 962 966 - if (ret) { 963 + if (ret) 964 + goto out_w_error; 965 + return 0; 966 + 967 967 out_w_error: 968 - bio_endio(bio, ret); 969 - } 968 + bio->bi_error = ret; 969 + bio_endio(bio); 970 970 return ret; 971 971 } 972 972 ··· 1741 1735 { 1742 1736 struct bio *bio; 1743 1737 struct btrfs_end_io_wq *end_io_wq; 1744 - int error; 1745 1738 1746 1739 end_io_wq = container_of(work, struct btrfs_end_io_wq, work); 1747 1740 bio = end_io_wq->bio; 1748 1741 1749 - error = end_io_wq->error; 1742 + bio->bi_error = end_io_wq->error; 1750 1743 bio->bi_private = end_io_wq->private; 1751 1744 bio->bi_end_io = end_io_wq->end_io; 1752 1745 kmem_cache_free(btrfs_end_io_wq_cache, end_io_wq); 1753 - bio_endio(bio, error); 1746 + bio_endio(bio); 1754 1747 } 1755 1748 1756 1749 static int cleaner_kthread(void *arg) ··· 3329 3324 * endio for the write_dev_flush, this will wake anyone waiting 3330 3325 * for the barrier when it is done 3331 3326 */ 3332 - static void btrfs_end_empty_barrier(struct bio *bio, int err) 3327 + static void btrfs_end_empty_barrier(struct bio *bio) 3333 3328 { 3334 - if (err) 3335 - clear_bit(BIO_UPTODATE, &bio->bi_flags); 3336 3329 if (bio->bi_private) 3337 3330 complete(bio->bi_private); 3338 3331 bio_put(bio); ··· 3358 3355 3359 3356 wait_for_completion(&device->flush_wait); 3360 3357 3361 - if (!bio_flagged(bio, BIO_UPTODATE)) { 3362 - ret = -EIO; 3358 + if (bio->bi_error) { 3359 + ret = bio->bi_error; 3363 3360 btrfs_dev_stat_inc_and_print(device, 3364 3361 BTRFS_DEV_STAT_FLUSH_ERRS); 3365 3362 }
+14 -25
fs/btrfs/extent_io.c
··· 2486 2486 * Scheduling is not allowed, so the extent state tree is expected 2487 2487 * to have one and only one object corresponding to this IO. 2488 2488 */ 2489 - static void end_bio_extent_writepage(struct bio *bio, int err) 2489 + static void end_bio_extent_writepage(struct bio *bio) 2490 2490 { 2491 2491 struct bio_vec *bvec; 2492 2492 u64 start; ··· 2516 2516 start = page_offset(page); 2517 2517 end = start + bvec->bv_offset + bvec->bv_len - 1; 2518 2518 2519 - if (end_extent_writepage(page, err, start, end)) 2519 + if (end_extent_writepage(page, bio->bi_error, start, end)) 2520 2520 continue; 2521 2521 2522 2522 end_page_writeback(page); ··· 2548 2548 * Scheduling is not allowed, so the extent state tree is expected 2549 2549 * to have one and only one object corresponding to this IO. 2550 2550 */ 2551 - static void end_bio_extent_readpage(struct bio *bio, int err) 2551 + static void end_bio_extent_readpage(struct bio *bio) 2552 2552 { 2553 2553 struct bio_vec *bvec; 2554 - int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 2554 + int uptodate = !bio->bi_error; 2555 2555 struct btrfs_io_bio *io_bio = btrfs_io_bio(bio); 2556 2556 struct extent_io_tree *tree; 2557 2557 u64 offset = 0; ··· 2564 2564 int ret; 2565 2565 int i; 2566 2566 2567 - if (err) 2568 - uptodate = 0; 2569 - 2570 2567 bio_for_each_segment_all(bvec, bio, i) { 2571 2568 struct page *page = bvec->bv_page; 2572 2569 struct inode *inode = page->mapping->host; 2573 2570 2574 2571 pr_debug("end_bio_extent_readpage: bi_sector=%llu, err=%d, " 2575 - "mirror=%u\n", (u64)bio->bi_iter.bi_sector, err, 2576 - io_bio->mirror_num); 2572 + "mirror=%u\n", (u64)bio->bi_iter.bi_sector, 2573 + bio->bi_error, io_bio->mirror_num); 2577 2574 tree = &BTRFS_I(inode)->io_tree; 2578 2575 2579 2576 /* We always issue full-page reads, but if some block ··· 2611 2614 2612 2615 if (tree->ops && tree->ops->readpage_io_failed_hook) { 2613 2616 ret = tree->ops->readpage_io_failed_hook(page, mirror); 2614 - if (!ret && !err && 2615 - test_bit(BIO_UPTODATE, &bio->bi_flags)) 2617 + if (!ret && !bio->bi_error) 2616 2618 uptodate = 1; 2617 2619 } else { 2618 2620 /* ··· 2627 2631 ret = bio_readpage_error(bio, offset, page, start, end, 2628 2632 mirror); 2629 2633 if (ret == 0) { 2630 - uptodate = 2631 - test_bit(BIO_UPTODATE, &bio->bi_flags); 2632 - if (err) 2633 - uptodate = 0; 2634 + uptodate = !bio->bi_error; 2634 2635 offset += len; 2635 2636 continue; 2636 2637 } ··· 2677 2684 endio_readpage_release_extent(tree, extent_start, extent_len, 2678 2685 uptodate); 2679 2686 if (io_bio->end_io) 2680 - io_bio->end_io(io_bio, err); 2687 + io_bio->end_io(io_bio, bio->bi_error); 2681 2688 bio_put(bio); 2682 2689 } 2683 2690 ··· 2795 2802 { 2796 2803 int ret = 0; 2797 2804 struct bio *bio; 2798 - int nr; 2799 2805 int contig = 0; 2800 - int this_compressed = bio_flags & EXTENT_BIO_COMPRESSED; 2801 2806 int old_compressed = prev_bio_flags & EXTENT_BIO_COMPRESSED; 2802 2807 size_t page_size = min_t(size_t, size, PAGE_CACHE_SIZE); 2803 2808 ··· 2820 2829 return 0; 2821 2830 } 2822 2831 } 2823 - if (this_compressed) 2824 - nr = BIO_MAX_PAGES; 2825 - else 2826 - nr = bio_get_nr_vecs(bdev); 2827 2832 2828 - bio = btrfs_bio_alloc(bdev, sector, nr, GFP_NOFS | __GFP_HIGH); 2833 + bio = btrfs_bio_alloc(bdev, sector, BIO_MAX_PAGES, 2834 + GFP_NOFS | __GFP_HIGH); 2829 2835 if (!bio) 2830 2836 return -ENOMEM; 2831 2837 ··· 3684 3696 } 3685 3697 } 3686 3698 3687 - static void end_bio_extent_buffer_writepage(struct bio *bio, int err) 3699 + static void end_bio_extent_buffer_writepage(struct bio *bio) 3688 3700 { 3689 3701 struct bio_vec *bvec; 3690 3702 struct extent_buffer *eb; ··· 3697 3709 BUG_ON(!eb); 3698 3710 done = atomic_dec_and_test(&eb->io_pages); 3699 3711 3700 - if (err || test_bit(EXTENT_BUFFER_WRITE_ERR, &eb->bflags)) { 3712 + if (bio->bi_error || 3713 + test_bit(EXTENT_BUFFER_WRITE_ERR, &eb->bflags)) { 3701 3714 ClearPageUptodate(page); 3702 3715 set_btree_ioerr(page); 3703 3716 }
+27 -26
fs/btrfs/inode.c
··· 1845 1845 int ret; 1846 1846 1847 1847 ret = btrfs_map_bio(root, rw, bio, mirror_num, 1); 1848 - if (ret) 1849 - bio_endio(bio, ret); 1848 + if (ret) { 1849 + bio->bi_error = ret; 1850 + bio_endio(bio); 1851 + } 1850 1852 return ret; 1851 1853 } 1852 1854 ··· 1908 1906 ret = btrfs_map_bio(root, rw, bio, mirror_num, 0); 1909 1907 1910 1908 out: 1911 - if (ret < 0) 1912 - bio_endio(bio, ret); 1909 + if (ret < 0) { 1910 + bio->bi_error = ret; 1911 + bio_endio(bio); 1912 + } 1913 1913 return ret; 1914 1914 } 1915 1915 ··· 7692 7688 int uptodate; 7693 7689 }; 7694 7690 7695 - static void btrfs_retry_endio_nocsum(struct bio *bio, int err) 7691 + static void btrfs_retry_endio_nocsum(struct bio *bio) 7696 7692 { 7697 7693 struct btrfs_retry_complete *done = bio->bi_private; 7698 7694 struct bio_vec *bvec; 7699 7695 int i; 7700 7696 7701 - if (err) 7697 + if (bio->bi_error) 7702 7698 goto end; 7703 7699 7704 7700 done->uptodate = 1; ··· 7747 7743 return 0; 7748 7744 } 7749 7745 7750 - static void btrfs_retry_endio(struct bio *bio, int err) 7746 + static void btrfs_retry_endio(struct bio *bio) 7751 7747 { 7752 7748 struct btrfs_retry_complete *done = bio->bi_private; 7753 7749 struct btrfs_io_bio *io_bio = btrfs_io_bio(bio); ··· 7756 7752 int ret; 7757 7753 int i; 7758 7754 7759 - if (err) 7755 + if (bio->bi_error) 7760 7756 goto end; 7761 7757 7762 7758 uptodate = 1; ··· 7839 7835 } 7840 7836 } 7841 7837 7842 - static void btrfs_endio_direct_read(struct bio *bio, int err) 7838 + static void btrfs_endio_direct_read(struct bio *bio) 7843 7839 { 7844 7840 struct btrfs_dio_private *dip = bio->bi_private; 7845 7841 struct inode *inode = dip->inode; 7846 7842 struct bio *dio_bio; 7847 7843 struct btrfs_io_bio *io_bio = btrfs_io_bio(bio); 7844 + int err = bio->bi_error; 7848 7845 7849 7846 if (dip->flags & BTRFS_DIO_ORIG_BIO_SUBMITTED) 7850 7847 err = btrfs_subio_endio_read(inode, io_bio, err); ··· 7856 7851 7857 7852 kfree(dip); 7858 7853 7859 - /* If we had a csum failure make sure to clear the uptodate flag */ 7860 - if (err) 7861 - clear_bit(BIO_UPTODATE, &dio_bio->bi_flags); 7862 - dio_end_io(dio_bio, err); 7854 + dio_end_io(dio_bio, bio->bi_error); 7863 7855 7864 7856 if (io_bio->end_io) 7865 7857 io_bio->end_io(io_bio, err); 7866 7858 bio_put(bio); 7867 7859 } 7868 7860 7869 - static void btrfs_endio_direct_write(struct bio *bio, int err) 7861 + static void btrfs_endio_direct_write(struct bio *bio) 7870 7862 { 7871 7863 struct btrfs_dio_private *dip = bio->bi_private; 7872 7864 struct inode *inode = dip->inode; ··· 7877 7875 again: 7878 7876 ret = btrfs_dec_test_first_ordered_pending(inode, &ordered, 7879 7877 &ordered_offset, 7880 - ordered_bytes, !err); 7878 + ordered_bytes, 7879 + !bio->bi_error); 7881 7880 if (!ret) 7882 7881 goto out_test; 7883 7882 ··· 7901 7898 7902 7899 kfree(dip); 7903 7900 7904 - /* If we had an error make sure to clear the uptodate flag */ 7905 - if (err) 7906 - clear_bit(BIO_UPTODATE, &dio_bio->bi_flags); 7907 - dio_end_io(dio_bio, err); 7901 + dio_end_io(dio_bio, bio->bi_error); 7908 7902 bio_put(bio); 7909 7903 } 7910 7904 ··· 7916 7916 return 0; 7917 7917 } 7918 7918 7919 - static void btrfs_end_dio_bio(struct bio *bio, int err) 7919 + static void btrfs_end_dio_bio(struct bio *bio) 7920 7920 { 7921 7921 struct btrfs_dio_private *dip = bio->bi_private; 7922 + int err = bio->bi_error; 7922 7923 7923 7924 if (err) 7924 7925 btrfs_warn(BTRFS_I(dip->inode)->root->fs_info, ··· 7948 7947 if (dip->errors) { 7949 7948 bio_io_error(dip->orig_bio); 7950 7949 } else { 7951 - set_bit(BIO_UPTODATE, &dip->dio_bio->bi_flags); 7952 - bio_endio(dip->orig_bio, 0); 7950 + dip->dio_bio->bi_error = 0; 7951 + bio_endio(dip->orig_bio); 7953 7952 } 7954 7953 out: 7955 7954 bio_put(bio); ··· 7958 7957 static struct bio *btrfs_dio_bio_alloc(struct block_device *bdev, 7959 7958 u64 first_sector, gfp_t gfp_flags) 7960 7959 { 7961 - int nr_vecs = bio_get_nr_vecs(bdev); 7962 - return btrfs_bio_alloc(bdev, first_sector, nr_vecs, gfp_flags); 7960 + return btrfs_bio_alloc(bdev, first_sector, BIO_MAX_PAGES, gfp_flags); 7963 7961 } 7964 7962 7965 7963 static inline int btrfs_lookup_and_bind_dio_csum(struct btrfs_root *root, ··· 8219 8219 * callbacks - they require an allocated dip and a clone of dio_bio. 8220 8220 */ 8221 8221 if (io_bio && dip) { 8222 - bio_endio(io_bio, ret); 8222 + io_bio->bi_error = -EIO; 8223 + bio_endio(io_bio); 8223 8224 /* 8224 8225 * The end io callbacks free our dip, do the final put on io_bio 8225 8226 * and all the cleanup and final put for dio_bio (through ··· 8247 8246 unlock_extent(&BTRFS_I(inode)->io_tree, file_offset, 8248 8247 file_offset + dio_bio->bi_iter.bi_size - 1); 8249 8248 } 8250 - clear_bit(BIO_UPTODATE, &dio_bio->bi_flags); 8249 + dio_bio->bi_error = -EIO; 8251 8250 /* 8252 8251 * Releases and cleans up our dio_bio, no need to bio_put() 8253 8252 * nor bio_endio()/bio_io_error() against dio_bio.
+28 -34
fs/btrfs/raid56.c
··· 851 851 * this frees the rbio and runs through all the bios in the 852 852 * bio_list and calls end_io on them 853 853 */ 854 - static void rbio_orig_end_io(struct btrfs_raid_bio *rbio, int err, int uptodate) 854 + static void rbio_orig_end_io(struct btrfs_raid_bio *rbio, int err) 855 855 { 856 856 struct bio *cur = bio_list_get(&rbio->bio_list); 857 857 struct bio *next; ··· 864 864 while (cur) { 865 865 next = cur->bi_next; 866 866 cur->bi_next = NULL; 867 - if (uptodate) 868 - set_bit(BIO_UPTODATE, &cur->bi_flags); 869 - bio_endio(cur, err); 867 + cur->bi_error = err; 868 + bio_endio(cur); 870 869 cur = next; 871 870 } 872 871 } ··· 874 875 * end io function used by finish_rmw. When we finally 875 876 * get here, we've written a full stripe 876 877 */ 877 - static void raid_write_end_io(struct bio *bio, int err) 878 + static void raid_write_end_io(struct bio *bio) 878 879 { 879 880 struct btrfs_raid_bio *rbio = bio->bi_private; 881 + int err = bio->bi_error; 880 882 881 883 if (err) 882 884 fail_bio_stripe(rbio, bio); ··· 893 893 if (atomic_read(&rbio->error) > rbio->bbio->max_errors) 894 894 err = -EIO; 895 895 896 - rbio_orig_end_io(rbio, err, 0); 896 + rbio_orig_end_io(rbio, err); 897 897 return; 898 898 } 899 899 ··· 1071 1071 * devices or if they are not contiguous 1072 1072 */ 1073 1073 if (last_end == disk_start && stripe->dev->bdev && 1074 - test_bit(BIO_UPTODATE, &last->bi_flags) && 1074 + !last->bi_error && 1075 1075 last->bi_bdev == stripe->dev->bdev) { 1076 1076 ret = bio_add_page(last, page, PAGE_CACHE_SIZE, 0); 1077 1077 if (ret == PAGE_CACHE_SIZE) ··· 1087 1087 bio->bi_iter.bi_size = 0; 1088 1088 bio->bi_bdev = stripe->dev->bdev; 1089 1089 bio->bi_iter.bi_sector = disk_start >> 9; 1090 - set_bit(BIO_UPTODATE, &bio->bi_flags); 1091 1090 1092 1091 bio_add_page(bio, page, PAGE_CACHE_SIZE, 0); 1093 1092 bio_list_add(bio_list, bio); ··· 1311 1312 1312 1313 bio->bi_private = rbio; 1313 1314 bio->bi_end_io = raid_write_end_io; 1314 - BUG_ON(!test_bit(BIO_UPTODATE, &bio->bi_flags)); 1315 1315 submit_bio(WRITE, bio); 1316 1316 } 1317 1317 return; 1318 1318 1319 1319 cleanup: 1320 - rbio_orig_end_io(rbio, -EIO, 0); 1320 + rbio_orig_end_io(rbio, -EIO); 1321 1321 } 1322 1322 1323 1323 /* ··· 1439 1441 * This will usually kick off finish_rmw once all the bios are read in, but it 1440 1442 * may trigger parity reconstruction if we had any errors along the way 1441 1443 */ 1442 - static void raid_rmw_end_io(struct bio *bio, int err) 1444 + static void raid_rmw_end_io(struct bio *bio) 1443 1445 { 1444 1446 struct btrfs_raid_bio *rbio = bio->bi_private; 1445 1447 1446 - if (err) 1448 + if (bio->bi_error) 1447 1449 fail_bio_stripe(rbio, bio); 1448 1450 else 1449 1451 set_bio_pages_uptodate(bio); ··· 1453 1455 if (!atomic_dec_and_test(&rbio->stripes_pending)) 1454 1456 return; 1455 1457 1456 - err = 0; 1457 1458 if (atomic_read(&rbio->error) > rbio->bbio->max_errors) 1458 1459 goto cleanup; 1459 1460 ··· 1466 1469 1467 1470 cleanup: 1468 1471 1469 - rbio_orig_end_io(rbio, -EIO, 0); 1472 + rbio_orig_end_io(rbio, -EIO); 1470 1473 } 1471 1474 1472 1475 static void async_rmw_stripe(struct btrfs_raid_bio *rbio) ··· 1569 1572 btrfs_bio_wq_end_io(rbio->fs_info, bio, 1570 1573 BTRFS_WQ_ENDIO_RAID56); 1571 1574 1572 - BUG_ON(!test_bit(BIO_UPTODATE, &bio->bi_flags)); 1573 1575 submit_bio(READ, bio); 1574 1576 } 1575 1577 /* the actual write will happen once the reads are done */ 1576 1578 return 0; 1577 1579 1578 1580 cleanup: 1579 - rbio_orig_end_io(rbio, -EIO, 0); 1581 + rbio_orig_end_io(rbio, -EIO); 1580 1582 return -EIO; 1581 1583 1582 1584 finish: ··· 1960 1964 else 1961 1965 clear_bit(RBIO_CACHE_READY_BIT, &rbio->flags); 1962 1966 1963 - rbio_orig_end_io(rbio, err, err == 0); 1967 + rbio_orig_end_io(rbio, err); 1964 1968 } else if (err == 0) { 1965 1969 rbio->faila = -1; 1966 1970 rbio->failb = -1; ··· 1972 1976 else 1973 1977 BUG(); 1974 1978 } else { 1975 - rbio_orig_end_io(rbio, err, 0); 1979 + rbio_orig_end_io(rbio, err); 1976 1980 } 1977 1981 } 1978 1982 ··· 1980 1984 * This is called only for stripes we've read from disk to 1981 1985 * reconstruct the parity. 1982 1986 */ 1983 - static void raid_recover_end_io(struct bio *bio, int err) 1987 + static void raid_recover_end_io(struct bio *bio) 1984 1988 { 1985 1989 struct btrfs_raid_bio *rbio = bio->bi_private; 1986 1990 ··· 1988 1992 * we only read stripe pages off the disk, set them 1989 1993 * up to date if there were no errors 1990 1994 */ 1991 - if (err) 1995 + if (bio->bi_error) 1992 1996 fail_bio_stripe(rbio, bio); 1993 1997 else 1994 1998 set_bio_pages_uptodate(bio); ··· 1998 2002 return; 1999 2003 2000 2004 if (atomic_read(&rbio->error) > rbio->bbio->max_errors) 2001 - rbio_orig_end_io(rbio, -EIO, 0); 2005 + rbio_orig_end_io(rbio, -EIO); 2002 2006 else 2003 2007 __raid_recover_end_io(rbio); 2004 2008 } ··· 2090 2094 btrfs_bio_wq_end_io(rbio->fs_info, bio, 2091 2095 BTRFS_WQ_ENDIO_RAID56); 2092 2096 2093 - BUG_ON(!test_bit(BIO_UPTODATE, &bio->bi_flags)); 2094 2097 submit_bio(READ, bio); 2095 2098 } 2096 2099 out: ··· 2097 2102 2098 2103 cleanup: 2099 2104 if (rbio->operation == BTRFS_RBIO_READ_REBUILD) 2100 - rbio_orig_end_io(rbio, -EIO, 0); 2105 + rbio_orig_end_io(rbio, -EIO); 2101 2106 return -EIO; 2102 2107 } 2103 2108 ··· 2272 2277 * end io function used by finish_rmw. When we finally 2273 2278 * get here, we've written a full stripe 2274 2279 */ 2275 - static void raid_write_parity_end_io(struct bio *bio, int err) 2280 + static void raid_write_parity_end_io(struct bio *bio) 2276 2281 { 2277 2282 struct btrfs_raid_bio *rbio = bio->bi_private; 2283 + int err = bio->bi_error; 2278 2284 2279 - if (err) 2285 + if (bio->bi_error) 2280 2286 fail_bio_stripe(rbio, bio); 2281 2287 2282 2288 bio_put(bio); ··· 2290 2294 if (atomic_read(&rbio->error)) 2291 2295 err = -EIO; 2292 2296 2293 - rbio_orig_end_io(rbio, err, 0); 2297 + rbio_orig_end_io(rbio, err); 2294 2298 } 2295 2299 2296 2300 static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio, ··· 2433 2437 nr_data = bio_list_size(&bio_list); 2434 2438 if (!nr_data) { 2435 2439 /* Every parity is right */ 2436 - rbio_orig_end_io(rbio, 0, 0); 2440 + rbio_orig_end_io(rbio, 0); 2437 2441 return; 2438 2442 } 2439 2443 ··· 2446 2450 2447 2451 bio->bi_private = rbio; 2448 2452 bio->bi_end_io = raid_write_parity_end_io; 2449 - BUG_ON(!test_bit(BIO_UPTODATE, &bio->bi_flags)); 2450 2453 submit_bio(WRITE, bio); 2451 2454 } 2452 2455 return; 2453 2456 2454 2457 cleanup: 2455 - rbio_orig_end_io(rbio, -EIO, 0); 2458 + rbio_orig_end_io(rbio, -EIO); 2456 2459 } 2457 2460 2458 2461 static inline int is_data_stripe(struct btrfs_raid_bio *rbio, int stripe) ··· 2519 2524 return; 2520 2525 2521 2526 cleanup: 2522 - rbio_orig_end_io(rbio, -EIO, 0); 2527 + rbio_orig_end_io(rbio, -EIO); 2523 2528 } 2524 2529 2525 2530 /* ··· 2530 2535 * This will usually kick off finish_rmw once all the bios are read in, but it 2531 2536 * may trigger parity reconstruction if we had any errors along the way 2532 2537 */ 2533 - static void raid56_parity_scrub_end_io(struct bio *bio, int err) 2538 + static void raid56_parity_scrub_end_io(struct bio *bio) 2534 2539 { 2535 2540 struct btrfs_raid_bio *rbio = bio->bi_private; 2536 2541 2537 - if (err) 2542 + if (bio->bi_error) 2538 2543 fail_bio_stripe(rbio, bio); 2539 2544 else 2540 2545 set_bio_pages_uptodate(bio); ··· 2627 2632 btrfs_bio_wq_end_io(rbio->fs_info, bio, 2628 2633 BTRFS_WQ_ENDIO_RAID56); 2629 2634 2630 - BUG_ON(!test_bit(BIO_UPTODATE, &bio->bi_flags)); 2631 2635 submit_bio(READ, bio); 2632 2636 } 2633 2637 /* the actual write will happen once the reads are done */ 2634 2638 return; 2635 2639 2636 2640 cleanup: 2637 - rbio_orig_end_io(rbio, -EIO, 0); 2641 + rbio_orig_end_io(rbio, -EIO); 2638 2642 return; 2639 2643 2640 2644 finish:
+13 -27
fs/btrfs/scrub.c
··· 278 278 u64 physical, struct btrfs_device *dev, u64 flags, 279 279 u64 gen, int mirror_num, u8 *csum, int force, 280 280 u64 physical_for_dev_replace); 281 - static void scrub_bio_end_io(struct bio *bio, int err); 281 + static void scrub_bio_end_io(struct bio *bio); 282 282 static void scrub_bio_end_io_worker(struct btrfs_work *work); 283 283 static void scrub_block_complete(struct scrub_block *sblock); 284 284 static void scrub_remap_extent(struct btrfs_fs_info *fs_info, ··· 295 295 static int scrub_add_page_to_wr_bio(struct scrub_ctx *sctx, 296 296 struct scrub_page *spage); 297 297 static void scrub_wr_submit(struct scrub_ctx *sctx); 298 - static void scrub_wr_bio_end_io(struct bio *bio, int err); 298 + static void scrub_wr_bio_end_io(struct bio *bio); 299 299 static void scrub_wr_bio_end_io_worker(struct btrfs_work *work); 300 300 static int write_page_nocow(struct scrub_ctx *sctx, 301 301 u64 physical_for_dev_replace, struct page *page); ··· 454 454 struct scrub_ctx *sctx; 455 455 int i; 456 456 struct btrfs_fs_info *fs_info = dev->dev_root->fs_info; 457 - int pages_per_rd_bio; 458 457 int ret; 459 458 460 - /* 461 - * the setting of pages_per_rd_bio is correct for scrub but might 462 - * be wrong for the dev_replace code where we might read from 463 - * different devices in the initial huge bios. However, that 464 - * code is able to correctly handle the case when adding a page 465 - * to a bio fails. 466 - */ 467 - if (dev->bdev) 468 - pages_per_rd_bio = min_t(int, SCRUB_PAGES_PER_RD_BIO, 469 - bio_get_nr_vecs(dev->bdev)); 470 - else 471 - pages_per_rd_bio = SCRUB_PAGES_PER_RD_BIO; 472 459 sctx = kzalloc(sizeof(*sctx), GFP_NOFS); 473 460 if (!sctx) 474 461 goto nomem; 475 462 atomic_set(&sctx->refs, 1); 476 463 sctx->is_dev_replace = is_dev_replace; 477 - sctx->pages_per_rd_bio = pages_per_rd_bio; 464 + sctx->pages_per_rd_bio = SCRUB_PAGES_PER_RD_BIO; 478 465 sctx->curr = -1; 479 466 sctx->dev_root = dev->dev_root; 480 467 for (i = 0; i < SCRUB_BIOS_PER_SCTX; ++i) { ··· 1416 1429 int error; 1417 1430 }; 1418 1431 1419 - static void scrub_bio_wait_endio(struct bio *bio, int error) 1432 + static void scrub_bio_wait_endio(struct bio *bio) 1420 1433 { 1421 1434 struct scrub_bio_ret *ret = bio->bi_private; 1422 1435 1423 - ret->error = error; 1436 + ret->error = bio->bi_error; 1424 1437 complete(&ret->event); 1425 1438 } 1426 1439 ··· 1777 1790 btrfsic_submit_bio(WRITE, sbio->bio); 1778 1791 } 1779 1792 1780 - static void scrub_wr_bio_end_io(struct bio *bio, int err) 1793 + static void scrub_wr_bio_end_io(struct bio *bio) 1781 1794 { 1782 1795 struct scrub_bio *sbio = bio->bi_private; 1783 1796 struct btrfs_fs_info *fs_info = sbio->dev->dev_root->fs_info; 1784 1797 1785 - sbio->err = err; 1798 + sbio->err = bio->bi_error; 1786 1799 sbio->bio = bio; 1787 1800 1788 1801 btrfs_init_work(&sbio->work, btrfs_scrubwrc_helper, ··· 2085 2098 */ 2086 2099 printk_ratelimited(KERN_WARNING 2087 2100 "BTRFS: scrub_submit(bio bdev == NULL) is unexpected!\n"); 2088 - bio_endio(sbio->bio, -EIO); 2101 + bio_io_error(sbio->bio); 2089 2102 } else { 2090 2103 btrfsic_submit_bio(READ, sbio->bio); 2091 2104 } ··· 2247 2260 return 0; 2248 2261 } 2249 2262 2250 - static void scrub_bio_end_io(struct bio *bio, int err) 2263 + static void scrub_bio_end_io(struct bio *bio) 2251 2264 { 2252 2265 struct scrub_bio *sbio = bio->bi_private; 2253 2266 struct btrfs_fs_info *fs_info = sbio->dev->dev_root->fs_info; 2254 2267 2255 - sbio->err = err; 2268 + sbio->err = bio->bi_error; 2256 2269 sbio->bio = bio; 2257 2270 2258 2271 btrfs_queue_work(fs_info->scrub_workers, &sbio->work); ··· 2659 2672 scrub_pending_bio_dec(sctx); 2660 2673 } 2661 2674 2662 - static void scrub_parity_bio_endio(struct bio *bio, int error) 2675 + static void scrub_parity_bio_endio(struct bio *bio) 2663 2676 { 2664 2677 struct scrub_parity *sparity = (struct scrub_parity *)bio->bi_private; 2665 2678 2666 - if (error) 2679 + if (bio->bi_error) 2667 2680 bitmap_or(sparity->ebitmap, sparity->ebitmap, sparity->dbitmap, 2668 2681 sparity->nsectors); 2669 2682 ··· 3883 3896 return 0; 3884 3897 3885 3898 WARN_ON(!dev->bdev); 3886 - wr_ctx->pages_per_wr_bio = min_t(int, SCRUB_PAGES_PER_WR_BIO, 3887 - bio_get_nr_vecs(dev->bdev)); 3899 + wr_ctx->pages_per_wr_bio = SCRUB_PAGES_PER_WR_BIO; 3888 3900 wr_ctx->tgtdev = dev; 3889 3901 atomic_set(&wr_ctx->flush_all_writes, 0); 3890 3902 return 0;
+11 -84
fs/btrfs/volumes.c
··· 5741 5741 return 0; 5742 5742 } 5743 5743 5744 - static inline void btrfs_end_bbio(struct btrfs_bio *bbio, struct bio *bio, int err) 5744 + static inline void btrfs_end_bbio(struct btrfs_bio *bbio, struct bio *bio) 5745 5745 { 5746 5746 bio->bi_private = bbio->private; 5747 5747 bio->bi_end_io = bbio->end_io; 5748 - bio_endio(bio, err); 5748 + bio_endio(bio); 5749 5749 5750 5750 btrfs_put_bbio(bbio); 5751 5751 } 5752 5752 5753 - static void btrfs_end_bio(struct bio *bio, int err) 5753 + static void btrfs_end_bio(struct bio *bio) 5754 5754 { 5755 5755 struct btrfs_bio *bbio = bio->bi_private; 5756 5756 int is_orig_bio = 0; 5757 5757 5758 - if (err) { 5758 + if (bio->bi_error) { 5759 5759 atomic_inc(&bbio->error); 5760 - if (err == -EIO || err == -EREMOTEIO) { 5760 + if (bio->bi_error == -EIO || bio->bi_error == -EREMOTEIO) { 5761 5761 unsigned int stripe_index = 5762 5762 btrfs_io_bio(bio)->stripe_index; 5763 5763 struct btrfs_device *dev; ··· 5795 5795 * beyond the tolerance of the btrfs bio 5796 5796 */ 5797 5797 if (atomic_read(&bbio->error) > bbio->max_errors) { 5798 - err = -EIO; 5798 + bio->bi_error = -EIO; 5799 5799 } else { 5800 5800 /* 5801 5801 * this bio is actually up to date, we didn't 5802 5802 * go over the max number of errors 5803 5803 */ 5804 - set_bit(BIO_UPTODATE, &bio->bi_flags); 5805 - err = 0; 5804 + bio->bi_error = 0; 5806 5805 } 5807 5806 5808 - btrfs_end_bbio(bbio, bio, err); 5807 + btrfs_end_bbio(bbio, bio); 5809 5808 } else if (!is_orig_bio) { 5810 5809 bio_put(bio); 5811 5810 } ··· 5825 5826 struct btrfs_pending_bios *pending_bios; 5826 5827 5827 5828 if (device->missing || !device->bdev) { 5828 - bio_endio(bio, -EIO); 5829 + bio_io_error(bio); 5829 5830 return; 5830 5831 } 5831 5832 ··· 5870 5871 &device->work); 5871 5872 } 5872 5873 5873 - static int bio_size_ok(struct block_device *bdev, struct bio *bio, 5874 - sector_t sector) 5875 - { 5876 - struct bio_vec *prev; 5877 - struct request_queue *q = bdev_get_queue(bdev); 5878 - unsigned int max_sectors = queue_max_sectors(q); 5879 - struct bvec_merge_data bvm = { 5880 - .bi_bdev = bdev, 5881 - .bi_sector = sector, 5882 - .bi_rw = bio->bi_rw, 5883 - }; 5884 - 5885 - if (WARN_ON(bio->bi_vcnt == 0)) 5886 - return 1; 5887 - 5888 - prev = &bio->bi_io_vec[bio->bi_vcnt - 1]; 5889 - if (bio_sectors(bio) > max_sectors) 5890 - return 0; 5891 - 5892 - if (!q->merge_bvec_fn) 5893 - return 1; 5894 - 5895 - bvm.bi_size = bio->bi_iter.bi_size - prev->bv_len; 5896 - if (q->merge_bvec_fn(q, &bvm, prev) < prev->bv_len) 5897 - return 0; 5898 - return 1; 5899 - } 5900 - 5901 5874 static void submit_stripe_bio(struct btrfs_root *root, struct btrfs_bio *bbio, 5902 5875 struct bio *bio, u64 physical, int dev_nr, 5903 5876 int rw, int async) ··· 5903 5932 btrfsic_submit_bio(rw, bio); 5904 5933 } 5905 5934 5906 - static int breakup_stripe_bio(struct btrfs_root *root, struct btrfs_bio *bbio, 5907 - struct bio *first_bio, struct btrfs_device *dev, 5908 - int dev_nr, int rw, int async) 5909 - { 5910 - struct bio_vec *bvec = first_bio->bi_io_vec; 5911 - struct bio *bio; 5912 - int nr_vecs = bio_get_nr_vecs(dev->bdev); 5913 - u64 physical = bbio->stripes[dev_nr].physical; 5914 - 5915 - again: 5916 - bio = btrfs_bio_alloc(dev->bdev, physical >> 9, nr_vecs, GFP_NOFS); 5917 - if (!bio) 5918 - return -ENOMEM; 5919 - 5920 - while (bvec <= (first_bio->bi_io_vec + first_bio->bi_vcnt - 1)) { 5921 - if (bio_add_page(bio, bvec->bv_page, bvec->bv_len, 5922 - bvec->bv_offset) < bvec->bv_len) { 5923 - u64 len = bio->bi_iter.bi_size; 5924 - 5925 - atomic_inc(&bbio->stripes_pending); 5926 - submit_stripe_bio(root, bbio, bio, physical, dev_nr, 5927 - rw, async); 5928 - physical += len; 5929 - goto again; 5930 - } 5931 - bvec++; 5932 - } 5933 - 5934 - submit_stripe_bio(root, bbio, bio, physical, dev_nr, rw, async); 5935 - return 0; 5936 - } 5937 - 5938 5935 static void bbio_error(struct btrfs_bio *bbio, struct bio *bio, u64 logical) 5939 5936 { 5940 5937 atomic_inc(&bbio->error); ··· 5912 5973 5913 5974 btrfs_io_bio(bio)->mirror_num = bbio->mirror_num; 5914 5975 bio->bi_iter.bi_sector = logical >> 9; 5915 - 5916 - btrfs_end_bbio(bbio, bio, -EIO); 5976 + bio->bi_error = -EIO; 5977 + btrfs_end_bbio(bbio, bio); 5917 5978 } 5918 5979 } 5919 5980 ··· 5972 6033 dev = bbio->stripes[dev_nr].dev; 5973 6034 if (!dev || !dev->bdev || (rw & WRITE && !dev->writeable)) { 5974 6035 bbio_error(bbio, first_bio, logical); 5975 - continue; 5976 - } 5977 - 5978 - /* 5979 - * Check and see if we're ok with this bio based on it's size 5980 - * and offset with the given device. 5981 - */ 5982 - if (!bio_size_ok(dev->bdev, first_bio, 5983 - bbio->stripes[dev_nr].physical >> 9)) { 5984 - ret = breakup_stripe_bio(root, bbio, first_bio, dev, 5985 - dev_nr, rw, async_submit); 5986 - BUG_ON(ret); 5987 6036 continue; 5988 6037 } 5989 6038
+5 -8
fs/buffer.c
··· 2957 2957 } 2958 2958 EXPORT_SYMBOL(generic_block_bmap); 2959 2959 2960 - static void end_bio_bh_io_sync(struct bio *bio, int err) 2960 + static void end_bio_bh_io_sync(struct bio *bio) 2961 2961 { 2962 2962 struct buffer_head *bh = bio->bi_private; 2963 2963 2964 - if (unlikely (test_bit(BIO_QUIET,&bio->bi_flags))) 2964 + if (unlikely(bio_flagged(bio, BIO_QUIET))) 2965 2965 set_bit(BH_Quiet, &bh->b_state); 2966 2966 2967 - bh->b_end_io(bh, test_bit(BIO_UPTODATE, &bio->bi_flags)); 2967 + bh->b_end_io(bh, !bio->bi_error); 2968 2968 bio_put(bio); 2969 2969 } 2970 2970 ··· 3046 3046 3047 3047 bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9); 3048 3048 bio->bi_bdev = bh->b_bdev; 3049 - bio->bi_io_vec[0].bv_page = bh->b_page; 3050 - bio->bi_io_vec[0].bv_len = bh->b_size; 3051 - bio->bi_io_vec[0].bv_offset = bh_offset(bh); 3052 3049 3053 - bio->bi_vcnt = 1; 3054 - bio->bi_iter.bi_size = bh->b_size; 3050 + bio_add_page(bio, bh->b_page, bh->b_size, bh_offset(bh)); 3051 + BUG_ON(bio->bi_iter.bi_size != bh->b_size); 3055 3052 3056 3053 bio->bi_end_io = end_bio_bh_io_sync; 3057 3054 bio->bi_private = bh;
+10 -8
fs/direct-io.c
··· 285 285 /* 286 286 * Asynchronous IO callback. 287 287 */ 288 - static void dio_bio_end_aio(struct bio *bio, int error) 288 + static void dio_bio_end_aio(struct bio *bio) 289 289 { 290 290 struct dio *dio = bio->bi_private; 291 291 unsigned long remaining; ··· 318 318 * During I/O bi_private points at the dio. After I/O, bi_private is used to 319 319 * implement a singly-linked list of completed BIOs, at dio->bio_list. 320 320 */ 321 - static void dio_bio_end_io(struct bio *bio, int error) 321 + static void dio_bio_end_io(struct bio *bio) 322 322 { 323 323 struct dio *dio = bio->bi_private; 324 324 unsigned long flags; ··· 345 345 struct dio *dio = bio->bi_private; 346 346 347 347 if (dio->is_async) 348 - dio_bio_end_aio(bio, error); 348 + dio_bio_end_aio(bio); 349 349 else 350 - dio_bio_end_io(bio, error); 350 + dio_bio_end_io(bio); 351 351 } 352 352 EXPORT_SYMBOL_GPL(dio_end_io); 353 353 ··· 457 457 */ 458 458 static int dio_bio_complete(struct dio *dio, struct bio *bio) 459 459 { 460 - const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 461 460 struct bio_vec *bvec; 462 461 unsigned i; 462 + int err; 463 463 464 - if (!uptodate) 464 + if (bio->bi_error) 465 465 dio->io_error = -EIO; 466 466 467 467 if (dio->is_async && dio->rw == READ) { 468 468 bio_check_pages_dirty(bio); /* transfers ownership */ 469 + err = bio->bi_error; 469 470 } else { 470 471 bio_for_each_segment_all(bvec, bio, i) { 471 472 struct page *page = bvec->bv_page; ··· 475 474 set_page_dirty_lock(page); 476 475 page_cache_release(page); 477 476 } 477 + err = bio->bi_error; 478 478 bio_put(bio); 479 479 } 480 - return uptodate ? 0 : -EIO; 480 + return err; 481 481 } 482 482 483 483 /* ··· 655 653 if (ret) 656 654 goto out; 657 655 sector = start_sector << (sdio->blkbits - 9); 658 - nr_pages = min(sdio->pages_in_io, bio_get_nr_vecs(map_bh->b_bdev)); 656 + nr_pages = min(sdio->pages_in_io, BIO_MAX_PAGES); 659 657 BUG_ON(nr_pages <= 0); 660 658 dio_bio_alloc(dio, sdio, map_bh->b_bdev, sector, nr_pages); 661 659 sdio->boundary = 0;
+7 -11
fs/ext4/page-io.c
··· 61 61 static void ext4_finish_bio(struct bio *bio) 62 62 { 63 63 int i; 64 - int error = !test_bit(BIO_UPTODATE, &bio->bi_flags); 65 64 struct bio_vec *bvec; 66 65 67 66 bio_for_each_segment_all(bvec, bio, i) { ··· 87 88 } 88 89 #endif 89 90 90 - if (error) { 91 + if (bio->bi_error) { 91 92 SetPageError(page); 92 93 set_bit(AS_EIO, &page->mapping->flags); 93 94 } ··· 106 107 continue; 107 108 } 108 109 clear_buffer_async_write(bh); 109 - if (error) 110 + if (bio->bi_error) 110 111 buffer_io_error(bh); 111 112 } while ((bh = bh->b_this_page) != head); 112 113 bit_spin_unlock(BH_Uptodate_Lock, &head->b_state); ··· 309 310 } 310 311 311 312 /* BIO completion function for page writeback */ 312 - static void ext4_end_bio(struct bio *bio, int error) 313 + static void ext4_end_bio(struct bio *bio) 313 314 { 314 315 ext4_io_end_t *io_end = bio->bi_private; 315 316 sector_t bi_sector = bio->bi_iter.bi_sector; 316 317 317 318 BUG_ON(!io_end); 318 319 bio->bi_end_io = NULL; 319 - if (test_bit(BIO_UPTODATE, &bio->bi_flags)) 320 - error = 0; 321 320 322 - if (error) { 321 + if (bio->bi_error) { 323 322 struct inode *inode = io_end->inode; 324 323 325 324 ext4_warning(inode->i_sb, "I/O error %d writing to inode %lu " 326 325 "(offset %llu size %ld starting block %llu)", 327 - error, inode->i_ino, 326 + bio->bi_error, inode->i_ino, 328 327 (unsigned long long) io_end->offset, 329 328 (long) io_end->size, 330 329 (unsigned long long) 331 330 bi_sector >> (inode->i_blkbits - 9)); 332 - mapping_set_error(inode->i_mapping, error); 331 + mapping_set_error(inode->i_mapping, bio->bi_error); 333 332 } 334 333 335 334 if (io_end->flag & EXT4_IO_END_UNWRITTEN) { ··· 372 375 static int io_submit_init_bio(struct ext4_io_submit *io, 373 376 struct buffer_head *bh) 374 377 { 375 - int nvecs = bio_get_nr_vecs(bh->b_bdev); 376 378 struct bio *bio; 377 379 378 - bio = bio_alloc(GFP_NOIO, min(nvecs, BIO_MAX_PAGES)); 380 + bio = bio_alloc(GFP_NOIO, BIO_MAX_PAGES); 379 381 if (!bio) 380 382 return -ENOMEM; 381 383 bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9);
+4 -4
fs/ext4/readpage.c
··· 98 98 * status of that page is hard. See end_buffer_async_read() for the details. 99 99 * There is no point in duplicating all that complexity. 100 100 */ 101 - static void mpage_end_io(struct bio *bio, int err) 101 + static void mpage_end_io(struct bio *bio) 102 102 { 103 103 struct bio_vec *bv; 104 104 int i; ··· 106 106 if (ext4_bio_encrypted(bio)) { 107 107 struct ext4_crypto_ctx *ctx = bio->bi_private; 108 108 109 - if (err) { 109 + if (bio->bi_error) { 110 110 ext4_release_crypto_ctx(ctx); 111 111 } else { 112 112 INIT_WORK(&ctx->r.work, completion_pages); ··· 118 118 bio_for_each_segment_all(bv, bio, i) { 119 119 struct page *page = bv->bv_page; 120 120 121 - if (!err) { 121 + if (!bio->bi_error) { 122 122 SetPageUptodate(page); 123 123 } else { 124 124 ClearPageUptodate(page); ··· 284 284 goto set_error_page; 285 285 } 286 286 bio = bio_alloc(GFP_KERNEL, 287 - min_t(int, nr_pages, bio_get_nr_vecs(bdev))); 287 + min_t(int, nr_pages, BIO_MAX_PAGES)); 288 288 if (!bio) { 289 289 if (ctx) 290 290 ext4_release_crypto_ctx(ctx);
+6 -6
fs/f2fs/data.c
··· 29 29 static struct kmem_cache *extent_tree_slab; 30 30 static struct kmem_cache *extent_node_slab; 31 31 32 - static void f2fs_read_end_io(struct bio *bio, int err) 32 + static void f2fs_read_end_io(struct bio *bio) 33 33 { 34 34 struct bio_vec *bvec; 35 35 int i; 36 36 37 37 if (f2fs_bio_encrypted(bio)) { 38 - if (err) { 38 + if (bio->bi_error) { 39 39 f2fs_release_crypto_ctx(bio->bi_private); 40 40 } else { 41 41 f2fs_end_io_crypto_work(bio->bi_private, bio); ··· 46 46 bio_for_each_segment_all(bvec, bio, i) { 47 47 struct page *page = bvec->bv_page; 48 48 49 - if (!err) { 49 + if (!bio->bi_error) { 50 50 SetPageUptodate(page); 51 51 } else { 52 52 ClearPageUptodate(page); ··· 57 57 bio_put(bio); 58 58 } 59 59 60 - static void f2fs_write_end_io(struct bio *bio, int err) 60 + static void f2fs_write_end_io(struct bio *bio) 61 61 { 62 62 struct f2fs_sb_info *sbi = bio->bi_private; 63 63 struct bio_vec *bvec; ··· 68 68 69 69 f2fs_restore_and_release_control_page(&page); 70 70 71 - if (unlikely(err)) { 71 + if (unlikely(bio->bi_error)) { 72 72 set_page_dirty(page); 73 73 set_bit(AS_EIO, &page->mapping->flags); 74 74 f2fs_stop_checkpoint(sbi); ··· 1552 1552 } 1553 1553 1554 1554 bio = bio_alloc(GFP_KERNEL, 1555 - min_t(int, nr_pages, bio_get_nr_vecs(bdev))); 1555 + min_t(int, nr_pages, BIO_MAX_PAGES)); 1556 1556 if (!bio) { 1557 1557 if (ctx) 1558 1558 f2fs_release_crypto_ctx(ctx);
+6 -13
fs/gfs2/lops.c
··· 202 202 * 203 203 */ 204 204 205 - static void gfs2_end_log_write(struct bio *bio, int error) 205 + static void gfs2_end_log_write(struct bio *bio) 206 206 { 207 207 struct gfs2_sbd *sdp = bio->bi_private; 208 208 struct bio_vec *bvec; 209 209 struct page *page; 210 210 int i; 211 211 212 - if (error) { 213 - sdp->sd_log_error = error; 214 - fs_err(sdp, "Error %d writing to log\n", error); 212 + if (bio->bi_error) { 213 + sdp->sd_log_error = bio->bi_error; 214 + fs_err(sdp, "Error %d writing to log\n", bio->bi_error); 215 215 } 216 216 217 217 bio_for_each_segment_all(bvec, bio, i) { 218 218 page = bvec->bv_page; 219 219 if (page_has_buffers(page)) 220 - gfs2_end_log_write_bh(sdp, bvec, error); 220 + gfs2_end_log_write_bh(sdp, bvec, bio->bi_error); 221 221 else 222 222 mempool_free(page, gfs2_page_pool); 223 223 } ··· 261 261 static struct bio *gfs2_log_alloc_bio(struct gfs2_sbd *sdp, u64 blkno) 262 262 { 263 263 struct super_block *sb = sdp->sd_vfs; 264 - unsigned nrvecs = bio_get_nr_vecs(sb->s_bdev); 265 264 struct bio *bio; 266 265 267 266 BUG_ON(sdp->sd_log_bio); 268 267 269 - while (1) { 270 - bio = bio_alloc(GFP_NOIO, nrvecs); 271 - if (likely(bio)) 272 - break; 273 - nrvecs = max(nrvecs/2, 1U); 274 - } 275 - 268 + bio = bio_alloc(GFP_NOIO, BIO_MAX_PAGES); 276 269 bio->bi_iter.bi_sector = blkno * (sb->s_blocksize >> 9); 277 270 bio->bi_bdev = sb->s_bdev; 278 271 bio->bi_end_io = gfs2_end_log_write;
+3 -3
fs/gfs2/ops_fstype.c
··· 171 171 return -EINVAL; 172 172 } 173 173 174 - static void end_bio_io_page(struct bio *bio, int error) 174 + static void end_bio_io_page(struct bio *bio) 175 175 { 176 176 struct page *page = bio->bi_private; 177 177 178 - if (!error) 178 + if (!bio->bi_error) 179 179 SetPageUptodate(page); 180 180 else 181 - pr_warn("error %d reading superblock\n", error); 181 + pr_warn("error %d reading superblock\n", bio->bi_error); 182 182 unlock_page(page); 183 183 } 184 184
+8 -14
fs/jfs/jfs_logmgr.c
··· 1999 1999 2000 2000 bio->bi_iter.bi_sector = bp->l_blkno << (log->l2bsize - 9); 2001 2001 bio->bi_bdev = log->bdev; 2002 - bio->bi_io_vec[0].bv_page = bp->l_page; 2003 - bio->bi_io_vec[0].bv_len = LOGPSIZE; 2004 - bio->bi_io_vec[0].bv_offset = bp->l_offset; 2005 2002 2006 - bio->bi_vcnt = 1; 2007 - bio->bi_iter.bi_size = LOGPSIZE; 2003 + bio_add_page(bio, bp->l_page, LOGPSIZE, bp->l_offset); 2004 + BUG_ON(bio->bi_iter.bi_size != LOGPSIZE); 2008 2005 2009 2006 bio->bi_end_io = lbmIODone; 2010 2007 bio->bi_private = bp; 2011 2008 /*check if journaling to disk has been disabled*/ 2012 2009 if (log->no_integrity) { 2013 2010 bio->bi_iter.bi_size = 0; 2014 - lbmIODone(bio, 0); 2011 + lbmIODone(bio); 2015 2012 } else { 2016 2013 submit_bio(READ_SYNC, bio); 2017 2014 } ··· 2142 2145 bio = bio_alloc(GFP_NOFS, 1); 2143 2146 bio->bi_iter.bi_sector = bp->l_blkno << (log->l2bsize - 9); 2144 2147 bio->bi_bdev = log->bdev; 2145 - bio->bi_io_vec[0].bv_page = bp->l_page; 2146 - bio->bi_io_vec[0].bv_len = LOGPSIZE; 2147 - bio->bi_io_vec[0].bv_offset = bp->l_offset; 2148 2148 2149 - bio->bi_vcnt = 1; 2150 - bio->bi_iter.bi_size = LOGPSIZE; 2149 + bio_add_page(bio, bp->l_page, LOGPSIZE, bp->l_offset); 2150 + BUG_ON(bio->bi_iter.bi_size != LOGPSIZE); 2151 2151 2152 2152 bio->bi_end_io = lbmIODone; 2153 2153 bio->bi_private = bp; ··· 2152 2158 /* check if journaling to disk has been disabled */ 2153 2159 if (log->no_integrity) { 2154 2160 bio->bi_iter.bi_size = 0; 2155 - lbmIODone(bio, 0); 2161 + lbmIODone(bio); 2156 2162 } else { 2157 2163 submit_bio(WRITE_SYNC, bio); 2158 2164 INCREMENT(lmStat.submitted); ··· 2190 2196 * 2191 2197 * executed at INTIODONE level 2192 2198 */ 2193 - static void lbmIODone(struct bio *bio, int error) 2199 + static void lbmIODone(struct bio *bio) 2194 2200 { 2195 2201 struct lbuf *bp = bio->bi_private; 2196 2202 struct lbuf *nextbp, *tail; ··· 2206 2212 2207 2213 bp->l_flag |= lbmDONE; 2208 2214 2209 - if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) { 2215 + if (bio->bi_error) { 2210 2216 bp->l_flag |= lbmERROR; 2211 2217 2212 2218 jfs_err("lbmIODone: I/O error in JFS log");
+4 -4
fs/jfs/jfs_metapage.c
··· 276 276 unlock_page(page); 277 277 } 278 278 279 - static void metapage_read_end_io(struct bio *bio, int err) 279 + static void metapage_read_end_io(struct bio *bio) 280 280 { 281 281 struct page *page = bio->bi_private; 282 282 283 - if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) { 283 + if (bio->bi_error) { 284 284 printk(KERN_ERR "metapage_read_end_io: I/O error\n"); 285 285 SetPageError(page); 286 286 } ··· 331 331 end_page_writeback(page); 332 332 } 333 333 334 - static void metapage_write_end_io(struct bio *bio, int err) 334 + static void metapage_write_end_io(struct bio *bio) 335 335 { 336 336 struct page *page = bio->bi_private; 337 337 338 338 BUG_ON(!PagePrivate(page)); 339 339 340 - if (! test_bit(BIO_UPTODATE, &bio->bi_flags)) { 340 + if (bio->bi_error) { 341 341 printk(KERN_ERR "metapage_write_end_io: I/O error\n"); 342 342 SetPageError(page); 343 343 }
+6 -10
fs/logfs/dev_bdev.c
··· 53 53 54 54 static DECLARE_WAIT_QUEUE_HEAD(wq); 55 55 56 - static void writeseg_end_io(struct bio *bio, int err) 56 + static void writeseg_end_io(struct bio *bio) 57 57 { 58 - const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 59 58 struct bio_vec *bvec; 60 59 int i; 61 60 struct super_block *sb = bio->bi_private; 62 61 struct logfs_super *super = logfs_super(sb); 63 62 64 - BUG_ON(!uptodate); /* FIXME: Retry io or write elsewhere */ 65 - BUG_ON(err); 63 + BUG_ON(bio->bi_error); /* FIXME: Retry io or write elsewhere */ 66 64 67 65 bio_for_each_segment_all(bvec, bio, i) { 68 66 end_page_writeback(bvec->bv_page); ··· 81 83 unsigned int max_pages; 82 84 int i; 83 85 84 - max_pages = min(nr_pages, (size_t) bio_get_nr_vecs(super->s_bdev)); 86 + max_pages = min(nr_pages, BIO_MAX_PAGES); 85 87 86 88 bio = bio_alloc(GFP_NOFS, max_pages); 87 89 BUG_ON(!bio); ··· 151 153 } 152 154 153 155 154 - static void erase_end_io(struct bio *bio, int err) 156 + static void erase_end_io(struct bio *bio) 155 157 { 156 - const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 157 158 struct super_block *sb = bio->bi_private; 158 159 struct logfs_super *super = logfs_super(sb); 159 160 160 - BUG_ON(!uptodate); /* FIXME: Retry io or write elsewhere */ 161 - BUG_ON(err); 161 + BUG_ON(bio->bi_error); /* FIXME: Retry io or write elsewhere */ 162 162 BUG_ON(bio->bi_vcnt == 0); 163 163 bio_put(bio); 164 164 if (atomic_dec_and_test(&super->s_pending_writes)) ··· 171 175 unsigned int max_pages; 172 176 int i; 173 177 174 - max_pages = min(nr_pages, (size_t) bio_get_nr_vecs(super->s_bdev)); 178 + max_pages = min(nr_pages, BIO_MAX_PAGES); 175 179 176 180 bio = bio_alloc(GFP_NOFS, max_pages); 177 181 BUG_ON(!bio);
+4 -4
fs/mpage.c
··· 42 42 * status of that page is hard. See end_buffer_async_read() for the details. 43 43 * There is no point in duplicating all that complexity. 44 44 */ 45 - static void mpage_end_io(struct bio *bio, int err) 45 + static void mpage_end_io(struct bio *bio) 46 46 { 47 47 struct bio_vec *bv; 48 48 int i; 49 49 50 50 bio_for_each_segment_all(bv, bio, i) { 51 51 struct page *page = bv->bv_page; 52 - page_endio(page, bio_data_dir(bio), err); 52 + page_endio(page, bio_data_dir(bio), bio->bi_error); 53 53 } 54 54 55 55 bio_put(bio); ··· 277 277 goto out; 278 278 } 279 279 bio = mpage_alloc(bdev, blocks[0] << (blkbits - 9), 280 - min_t(int, nr_pages, bio_get_nr_vecs(bdev)), 280 + min_t(int, nr_pages, BIO_MAX_PAGES), 281 281 GFP_KERNEL); 282 282 if (bio == NULL) 283 283 goto confused; ··· 602 602 } 603 603 } 604 604 bio = mpage_alloc(bdev, blocks[0] << (blkbits - 9), 605 - bio_get_nr_vecs(bdev), GFP_NOFS|__GFP_HIGH); 605 + BIO_MAX_PAGES, GFP_NOFS|__GFP_HIGH); 606 606 if (bio == NULL) 607 607 goto confused; 608 608
+6 -8
fs/nfs/blocklayout/blocklayout.c
··· 116 116 117 117 static struct bio * 118 118 bl_alloc_init_bio(int npg, struct block_device *bdev, sector_t disk_sector, 119 - void (*end_io)(struct bio *, int err), struct parallel_io *par) 119 + bio_end_io_t end_io, struct parallel_io *par) 120 120 { 121 121 struct bio *bio; 122 122 ··· 139 139 static struct bio * 140 140 do_add_page_to_bio(struct bio *bio, int npg, int rw, sector_t isect, 141 141 struct page *page, struct pnfs_block_dev_map *map, 142 - struct pnfs_block_extent *be, 143 - void (*end_io)(struct bio *, int err), 142 + struct pnfs_block_extent *be, bio_end_io_t end_io, 144 143 struct parallel_io *par, unsigned int offset, int *len) 145 144 { 146 145 struct pnfs_block_dev *dev = ··· 182 183 return bio; 183 184 } 184 185 185 - static void bl_end_io_read(struct bio *bio, int err) 186 + static void bl_end_io_read(struct bio *bio) 186 187 { 187 188 struct parallel_io *par = bio->bi_private; 188 189 189 - if (err) { 190 + if (bio->bi_error) { 190 191 struct nfs_pgio_header *header = par->data; 191 192 192 193 if (!header->pnfs_error) ··· 315 316 return PNFS_ATTEMPTED; 316 317 } 317 318 318 - static void bl_end_io_write(struct bio *bio, int err) 319 + static void bl_end_io_write(struct bio *bio) 319 320 { 320 321 struct parallel_io *par = bio->bi_private; 321 - const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 322 322 struct nfs_pgio_header *header = par->data; 323 323 324 - if (!uptodate) { 324 + if (bio->bi_error) { 325 325 if (!header->pnfs_error) 326 326 header->pnfs_error = -EIO; 327 327 pnfs_set_lo_fail(header->lseg);
+3 -4
fs/nilfs2/segbuf.c
··· 338 338 /* 339 339 * BIO operations 340 340 */ 341 - static void nilfs_end_bio_write(struct bio *bio, int err) 341 + static void nilfs_end_bio_write(struct bio *bio) 342 342 { 343 - const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 344 343 struct nilfs_segment_buffer *segbuf = bio->bi_private; 345 344 346 - if (!uptodate) 345 + if (bio->bi_error) 347 346 atomic_inc(&segbuf->sb_err); 348 347 349 348 bio_put(bio); ··· 414 415 { 415 416 wi->bio = NULL; 416 417 wi->rest_blocks = segbuf->sb_sum.nblocks; 417 - wi->max_pages = bio_get_nr_vecs(wi->nilfs->ns_bdev); 418 + wi->max_pages = BIO_MAX_PAGES; 418 419 wi->nr_vecs = min(wi->max_pages, wi->rest_blocks); 419 420 wi->start = wi->end = 0; 420 421 wi->blocknr = segbuf->sb_pseg_start;
+4 -5
fs/ocfs2/cluster/heartbeat.c
··· 372 372 wait_for_completion(&wc->wc_io_complete); 373 373 } 374 374 375 - static void o2hb_bio_end_io(struct bio *bio, 376 - int error) 375 + static void o2hb_bio_end_io(struct bio *bio) 377 376 { 378 377 struct o2hb_bio_wait_ctxt *wc = bio->bi_private; 379 378 380 - if (error) { 381 - mlog(ML_ERROR, "IO Error %d\n", error); 382 - wc->wc_error = error; 379 + if (bio->bi_error) { 380 + mlog(ML_ERROR, "IO Error %d\n", bio->bi_error); 381 + wc->wc_error = bio->bi_error; 383 382 } 384 383 385 384 o2hb_bio_wait_dec(wc, 1);
+3 -5
fs/xfs/xfs_aops.c
··· 351 351 */ 352 352 STATIC void 353 353 xfs_end_bio( 354 - struct bio *bio, 355 - int error) 354 + struct bio *bio) 356 355 { 357 356 xfs_ioend_t *ioend = bio->bi_private; 358 357 359 - ioend->io_error = test_bit(BIO_UPTODATE, &bio->bi_flags) ? 0 : error; 358 + ioend->io_error = bio->bi_error; 360 359 361 360 /* Toss bio and pass work off to an xfsdatad thread */ 362 361 bio->bi_private = NULL; ··· 381 382 xfs_alloc_ioend_bio( 382 383 struct buffer_head *bh) 383 384 { 384 - int nvecs = bio_get_nr_vecs(bh->b_bdev); 385 - struct bio *bio = bio_alloc(GFP_NOIO, nvecs); 385 + struct bio *bio = bio_alloc(GFP_NOIO, BIO_MAX_PAGES); 386 386 387 387 ASSERT(bio->bi_private == NULL); 388 388 bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9);
+3 -4
fs/xfs/xfs_buf.c
··· 1096 1096 1097 1097 STATIC void 1098 1098 xfs_buf_bio_end_io( 1099 - struct bio *bio, 1100 - int error) 1099 + struct bio *bio) 1101 1100 { 1102 1101 xfs_buf_t *bp = (xfs_buf_t *)bio->bi_private; 1103 1102 ··· 1104 1105 * don't overwrite existing errors - otherwise we can lose errors on 1105 1106 * buffers that require multiple bios to complete. 1106 1107 */ 1107 - if (error) { 1108 + if (bio->bi_error) { 1108 1109 spin_lock(&bp->b_lock); 1109 1110 if (!bp->b_io_error) 1110 - bp->b_io_error = error; 1111 + bp->b_io_error = bio->bi_error; 1111 1112 spin_unlock(&bp->b_lock); 1112 1113 } 1113 1114
+24 -14
include/linux/bio.h
··· 187 187 __BIO_SEG_BOUNDARY(bvec_to_phys((b1)), bvec_to_phys((b2)) + (b2)->bv_len, queue_segment_boundary((q))) 188 188 189 189 /* 190 - * Check if adding a bio_vec after bprv with offset would create a gap in 191 - * the SG list. Most drivers don't care about this, but some do. 192 - */ 193 - static inline bool bvec_gap_to_prev(struct bio_vec *bprv, unsigned int offset) 194 - { 195 - return offset || ((bprv->bv_offset + bprv->bv_len) & (PAGE_SIZE - 1)); 196 - } 197 - 198 - #define bio_io_error(bio) bio_endio((bio), -EIO) 199 - 200 - /* 201 190 * drivers should _never_ use the all version - the bio may have been split 202 191 * before it got to the driver and the driver won't own all of it 203 192 */ ··· 293 304 smp_mb__before_atomic(); 294 305 } 295 306 atomic_set(&bio->__bi_cnt, count); 307 + } 308 + 309 + static inline bool bio_flagged(struct bio *bio, unsigned int bit) 310 + { 311 + return (bio->bi_flags & (1U << bit)) != 0; 312 + } 313 + 314 + static inline void bio_set_flag(struct bio *bio, unsigned int bit) 315 + { 316 + bio->bi_flags |= (1U << bit); 317 + } 318 + 319 + static inline void bio_clear_flag(struct bio *bio, unsigned int bit) 320 + { 321 + bio->bi_flags &= ~(1U << bit); 296 322 } 297 323 298 324 enum bip_flags { ··· 430 426 431 427 } 432 428 433 - extern void bio_endio(struct bio *, int); 429 + extern void bio_endio(struct bio *); 430 + 431 + static inline void bio_io_error(struct bio *bio) 432 + { 433 + bio->bi_error = -EIO; 434 + bio_endio(bio); 435 + } 436 + 434 437 struct request_queue; 435 438 extern int bio_phys_segments(struct request_queue *, struct bio *); 436 439 ··· 451 440 extern int bio_add_page(struct bio *, struct page *, unsigned int,unsigned int); 452 441 extern int bio_add_pc_page(struct request_queue *, struct bio *, struct page *, 453 442 unsigned int, unsigned int); 454 - extern int bio_get_nr_vecs(struct block_device *); 455 443 struct rq_map_data; 456 444 extern struct bio *bio_map_user_iov(struct request_queue *, 457 445 const struct iov_iter *, gfp_t); ··· 727 717 extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int); 728 718 extern bool bio_integrity_enabled(struct bio *bio); 729 719 extern int bio_integrity_prep(struct bio *); 730 - extern void bio_integrity_endio(struct bio *, int); 720 + extern void bio_integrity_endio(struct bio *); 731 721 extern void bio_integrity_advance(struct bio *, unsigned int); 732 722 extern void bio_integrity_trim(struct bio *, unsigned int, unsigned int); 733 723 extern int bio_integrity_clone(struct bio *, struct bio *, gfp_t);
+1 -1
include/linux/blk-cgroup.h
··· 374 374 * root_rl in such cases. 375 375 */ 376 376 blkg = blkg_lookup_create(blkcg, q); 377 - if (unlikely(IS_ERR(blkg))) 377 + if (IS_ERR(blkg)) 378 378 goto root_rl; 379 379 380 380 blkg_get(blkg);
+4 -6
include/linux/blk_types.h
··· 14 14 struct block_device; 15 15 struct io_context; 16 16 struct cgroup_subsys_state; 17 - typedef void (bio_end_io_t) (struct bio *, int); 17 + typedef void (bio_end_io_t) (struct bio *); 18 18 typedef void (bio_destructor_t) (struct bio *); 19 19 20 20 /* ··· 46 46 struct bio { 47 47 struct bio *bi_next; /* request queue link */ 48 48 struct block_device *bi_bdev; 49 - unsigned long bi_flags; /* status, command, etc */ 49 + unsigned int bi_flags; /* status, command, etc */ 50 + int bi_error; 50 51 unsigned long bi_rw; /* bottom bits READ/WRITE, 51 52 * top bits priority 52 53 */ ··· 112 111 /* 113 112 * bio flags 114 113 */ 115 - #define BIO_UPTODATE 0 /* ok after I/O completion */ 116 114 #define BIO_SEG_VALID 1 /* bi_phys_segments valid */ 117 115 #define BIO_CLONED 2 /* doesn't own data */ 118 116 #define BIO_BOUNCED 3 /* bio is a bounce bio */ ··· 129 129 #define BIO_RESET_BITS 13 130 130 #define BIO_OWNS_VEC 13 /* bio_free() should free bvec */ 131 131 132 - #define bio_flagged(bio, flag) ((bio)->bi_flags & (1 << (flag))) 133 - 134 132 /* 135 133 * top 4 bits of bio flags indicate the pool this bio came from 136 134 */ 137 135 #define BIO_POOL_BITS (4) 138 136 #define BIO_POOL_NONE ((1UL << BIO_POOL_BITS) - 1) 139 - #define BIO_POOL_OFFSET (BITS_PER_LONG - BIO_POOL_BITS) 137 + #define BIO_POOL_OFFSET (32 - BIO_POOL_BITS) 140 138 #define BIO_POOL_MASK (1UL << BIO_POOL_OFFSET) 141 139 #define BIO_POOL_IDX(bio) ((bio)->bi_flags >> BIO_POOL_OFFSET) 142 140
+25 -11
include/linux/blkdev.h
··· 213 213 typedef void (unprep_rq_fn) (struct request_queue *, struct request *); 214 214 215 215 struct bio_vec; 216 - struct bvec_merge_data { 217 - struct block_device *bi_bdev; 218 - sector_t bi_sector; 219 - unsigned bi_size; 220 - unsigned long bi_rw; 221 - }; 222 - typedef int (merge_bvec_fn) (struct request_queue *, struct bvec_merge_data *, 223 - struct bio_vec *); 224 216 typedef void (softirq_done_fn)(struct request *); 225 217 typedef int (dma_drain_needed_fn)(struct request *); 226 218 typedef int (lld_busy_fn) (struct request_queue *q); ··· 250 258 struct queue_limits { 251 259 unsigned long bounce_pfn; 252 260 unsigned long seg_boundary_mask; 261 + unsigned long virt_boundary_mask; 253 262 254 263 unsigned int max_hw_sectors; 255 264 unsigned int chunk_sectors; ··· 261 268 unsigned int io_min; 262 269 unsigned int io_opt; 263 270 unsigned int max_discard_sectors; 271 + unsigned int max_hw_discard_sectors; 264 272 unsigned int max_write_same_sectors; 265 273 unsigned int discard_granularity; 266 274 unsigned int discard_alignment; ··· 299 305 make_request_fn *make_request_fn; 300 306 prep_rq_fn *prep_rq_fn; 301 307 unprep_rq_fn *unprep_rq_fn; 302 - merge_bvec_fn *merge_bvec_fn; 303 308 softirq_done_fn *softirq_done_fn; 304 309 rq_timed_out_fn *rq_timed_out_fn; 305 310 dma_drain_needed_fn *dma_drain_needed; ··· 455 462 456 463 struct blk_mq_tag_set *tag_set; 457 464 struct list_head tag_set_list; 465 + struct bio_set *bio_split; 458 466 }; 459 467 460 468 #define QUEUE_FLAG_QUEUED 1 /* uses generic tag queueing */ ··· 480 486 #define QUEUE_FLAG_DEAD 19 /* queue tear-down finished */ 481 487 #define QUEUE_FLAG_INIT_DONE 20 /* queue is initialized */ 482 488 #define QUEUE_FLAG_NO_SG_MERGE 21 /* don't attempt to merge SG segments*/ 483 - #define QUEUE_FLAG_SG_GAPS 22 /* queue doesn't support SG gaps */ 484 489 485 490 #define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ 486 491 (1 << QUEUE_FLAG_STACKABLE) | \ ··· 775 782 extern int blk_insert_cloned_request(struct request_queue *q, 776 783 struct request *rq); 777 784 extern void blk_delay_queue(struct request_queue *, unsigned long); 785 + extern void blk_queue_split(struct request_queue *, struct bio **, 786 + struct bio_set *); 778 787 extern void blk_recount_segments(struct request_queue *, struct bio *); 779 788 extern int scsi_verify_blk_ioctl(struct block_device *, unsigned int); 780 789 extern int scsi_cmd_blk_ioctl(struct block_device *, fmode_t, ··· 981 986 void *buf, unsigned int size); 982 987 extern void blk_queue_lld_busy(struct request_queue *q, lld_busy_fn *fn); 983 988 extern void blk_queue_segment_boundary(struct request_queue *, unsigned long); 989 + extern void blk_queue_virt_boundary(struct request_queue *, unsigned long); 984 990 extern void blk_queue_prep_rq(struct request_queue *, prep_rq_fn *pfn); 985 991 extern void blk_queue_unprep_rq(struct request_queue *, unprep_rq_fn *ufn); 986 - extern void blk_queue_merge_bvec(struct request_queue *, merge_bvec_fn *); 987 992 extern void blk_queue_dma_alignment(struct request_queue *, int); 988 993 extern void blk_queue_update_dma_alignment(struct request_queue *, int); 989 994 extern void blk_queue_softirq_done(struct request_queue *, softirq_done_fn *); ··· 1133 1138 enum blk_default_limits { 1134 1139 BLK_MAX_SEGMENTS = 128, 1135 1140 BLK_SAFE_MAX_SECTORS = 255, 1141 + BLK_DEF_MAX_SECTORS = 2560, 1136 1142 BLK_MAX_SEGMENT_SIZE = 65536, 1137 1143 BLK_SEG_BOUNDARY_MASK = 0xFFFFFFFFUL, 1138 1144 }; ··· 1148 1152 static inline unsigned long queue_segment_boundary(struct request_queue *q) 1149 1153 { 1150 1154 return q->limits.seg_boundary_mask; 1155 + } 1156 + 1157 + static inline unsigned long queue_virt_boundary(struct request_queue *q) 1158 + { 1159 + return q->limits.virt_boundary_mask; 1151 1160 } 1152 1161 1153 1162 static inline unsigned int queue_max_sectors(struct request_queue *q) ··· 1353 1352 static inline void put_dev_sector(Sector p) 1354 1353 { 1355 1354 page_cache_release(p.v); 1355 + } 1356 + 1357 + /* 1358 + * Check if adding a bio_vec after bprv with offset would create a gap in 1359 + * the SG list. Most drivers don't care about this, but some do. 1360 + */ 1361 + static inline bool bvec_gap_to_prev(struct request_queue *q, 1362 + struct bio_vec *bprv, unsigned int offset) 1363 + { 1364 + if (!queue_virt_boundary(q)) 1365 + return false; 1366 + return offset || 1367 + ((bprv->bv_offset + bprv->bv_len) & queue_virt_boundary(q)); 1356 1368 } 1357 1369 1358 1370 struct work_struct;
-4
include/linux/device-mapper.h
··· 82 82 typedef int (*dm_ioctl_fn) (struct dm_target *ti, unsigned int cmd, 83 83 unsigned long arg); 84 84 85 - typedef int (*dm_merge_fn) (struct dm_target *ti, struct bvec_merge_data *bvm, 86 - struct bio_vec *biovec, int max_size); 87 - 88 85 /* 89 86 * These iteration functions are typically used to check (and combine) 90 87 * properties of underlying devices. ··· 157 160 dm_status_fn status; 158 161 dm_message_fn message; 159 162 dm_ioctl_fn ioctl; 160 - dm_merge_fn merge; 161 163 dm_busy_fn busy; 162 164 dm_iterate_devices_fn iterate_devices; 163 165 dm_io_hints_fn io_hints;
+23 -10
include/linux/genhd.h
··· 13 13 #include <linux/kdev_t.h> 14 14 #include <linux/rcupdate.h> 15 15 #include <linux/slab.h> 16 + #include <linux/percpu-refcount.h> 16 17 17 18 #ifdef CONFIG_BLOCK 18 19 ··· 125 124 #else 126 125 struct disk_stats dkstats; 127 126 #endif 128 - atomic_t ref; 127 + struct percpu_ref ref; 129 128 struct rcu_head rcu_head; 130 129 }; 131 130 ··· 612 611 sector_t len, int flags, 613 612 struct partition_meta_info 614 613 *info); 615 - extern void __delete_partition(struct hd_struct *); 614 + extern void __delete_partition(struct percpu_ref *); 616 615 extern void delete_partition(struct gendisk *, int); 617 616 extern void printk_all_partitions(void); 618 617 ··· 641 640 const char *buf, size_t count); 642 641 #endif /* CONFIG_FAIL_MAKE_REQUEST */ 643 642 644 - static inline void hd_ref_init(struct hd_struct *part) 643 + static inline int hd_ref_init(struct hd_struct *part) 645 644 { 646 - atomic_set(&part->ref, 1); 647 - smp_mb(); 645 + if (percpu_ref_init(&part->ref, __delete_partition, 0, 646 + GFP_KERNEL)) 647 + return -ENOMEM; 648 + return 0; 648 649 } 649 650 650 651 static inline void hd_struct_get(struct hd_struct *part) 651 652 { 652 - atomic_inc(&part->ref); 653 - smp_mb__after_atomic(); 653 + percpu_ref_get(&part->ref); 654 654 } 655 655 656 656 static inline int hd_struct_try_get(struct hd_struct *part) 657 657 { 658 - return atomic_inc_not_zero(&part->ref); 658 + return percpu_ref_tryget_live(&part->ref); 659 659 } 660 660 661 661 static inline void hd_struct_put(struct hd_struct *part) 662 662 { 663 - if (atomic_dec_and_test(&part->ref)) 664 - __delete_partition(part); 663 + percpu_ref_put(&part->ref); 664 + } 665 + 666 + static inline void hd_struct_kill(struct hd_struct *part) 667 + { 668 + percpu_ref_kill(&part->ref); 669 + } 670 + 671 + static inline void hd_free_part(struct hd_struct *part) 672 + { 673 + free_part_stats(part); 674 + free_part_info(part); 675 + percpu_ref_exit(&part->ref); 665 676 } 666 677 667 678 /*
+2 -2
include/linux/swap.h
··· 373 373 /* linux/mm/page_io.c */ 374 374 extern int swap_readpage(struct page *); 375 375 extern int swap_writepage(struct page *page, struct writeback_control *wbc); 376 - extern void end_swap_bio_write(struct bio *bio, int err); 376 + extern void end_swap_bio_write(struct bio *bio); 377 377 extern int __swap_writepage(struct page *page, struct writeback_control *wbc, 378 - void (*end_write_func)(struct bio *, int)); 378 + bio_end_io_t end_write_func); 379 379 extern int swap_set_page_dirty(struct page *page); 380 380 381 381 int add_swap_extent(struct swap_info_struct *sis, unsigned long start_page,
+4 -8
kernel/power/swap.c
··· 227 227 hb->error = 0; 228 228 } 229 229 230 - static void hib_end_io(struct bio *bio, int error) 230 + static void hib_end_io(struct bio *bio) 231 231 { 232 232 struct hib_bio_batch *hb = bio->bi_private; 233 - const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 234 233 struct page *page = bio->bi_io_vec[0].bv_page; 235 234 236 - if (!uptodate || error) { 235 + if (bio->bi_error) { 237 236 printk(KERN_ALERT "Read-error on swap-device (%u:%u:%Lu)\n", 238 237 imajor(bio->bi_bdev->bd_inode), 239 238 iminor(bio->bi_bdev->bd_inode), 240 239 (unsigned long long)bio->bi_iter.bi_sector); 241 - 242 - if (!error) 243 - error = -EIO; 244 240 } 245 241 246 242 if (bio_data_dir(bio) == WRITE) 247 243 put_page(page); 248 244 249 - if (error && !hb->error) 250 - hb->error = error; 245 + if (bio->bi_error && !hb->error) 246 + hb->error = bio->bi_error; 251 247 if (atomic_dec_and_test(&hb->count)) 252 248 wake_up(&hb->wait); 253 249
+3 -7
kernel/trace/blktrace.c
··· 778 778 if (likely(!bt)) 779 779 return; 780 780 781 - if (!error && !bio_flagged(bio, BIO_UPTODATE)) 782 - error = EIO; 783 - 784 781 __blk_add_trace(bt, bio->bi_iter.bi_sector, bio->bi_iter.bi_size, 785 782 bio->bi_rw, what, error, 0, NULL); 786 783 } ··· 884 887 885 888 __blk_add_trace(bt, bio->bi_iter.bi_sector, 886 889 bio->bi_iter.bi_size, bio->bi_rw, BLK_TA_SPLIT, 887 - !bio_flagged(bio, BIO_UPTODATE), 888 - sizeof(rpdu), &rpdu); 890 + bio->bi_error, sizeof(rpdu), &rpdu); 889 891 } 890 892 } 891 893 ··· 916 920 r.sector_from = cpu_to_be64(from); 917 921 918 922 __blk_add_trace(bt, bio->bi_iter.bi_sector, bio->bi_iter.bi_size, 919 - bio->bi_rw, BLK_TA_REMAP, 920 - !bio_flagged(bio, BIO_UPTODATE), sizeof(r), &r); 923 + bio->bi_rw, BLK_TA_REMAP, bio->bi_error, 924 + sizeof(r), &r); 921 925 } 922 926 923 927 /**
+8 -12
mm/page_io.c
··· 33 33 if (bio) { 34 34 bio->bi_iter.bi_sector = map_swap_page(page, &bio->bi_bdev); 35 35 bio->bi_iter.bi_sector <<= PAGE_SHIFT - 9; 36 - bio->bi_io_vec[0].bv_page = page; 37 - bio->bi_io_vec[0].bv_len = PAGE_SIZE; 38 - bio->bi_io_vec[0].bv_offset = 0; 39 - bio->bi_vcnt = 1; 40 - bio->bi_iter.bi_size = PAGE_SIZE; 41 36 bio->bi_end_io = end_io; 37 + 38 + bio_add_page(bio, page, PAGE_SIZE, 0); 39 + BUG_ON(bio->bi_iter.bi_size != PAGE_SIZE); 42 40 } 43 41 return bio; 44 42 } 45 43 46 - void end_swap_bio_write(struct bio *bio, int err) 44 + void end_swap_bio_write(struct bio *bio) 47 45 { 48 - const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 49 46 struct page *page = bio->bi_io_vec[0].bv_page; 50 47 51 - if (!uptodate) { 48 + if (bio->bi_error) { 52 49 SetPageError(page); 53 50 /* 54 51 * We failed to write the page out to swap-space. ··· 66 69 bio_put(bio); 67 70 } 68 71 69 - static void end_swap_bio_read(struct bio *bio, int err) 72 + static void end_swap_bio_read(struct bio *bio) 70 73 { 71 - const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 72 74 struct page *page = bio->bi_io_vec[0].bv_page; 73 75 74 - if (!uptodate) { 76 + if (bio->bi_error) { 75 77 SetPageError(page); 76 78 ClearPageUptodate(page); 77 79 printk(KERN_ALERT "Read-error on swap-device (%u:%u:%Lu)\n", ··· 250 254 } 251 255 252 256 int __swap_writepage(struct page *page, struct writeback_control *wbc, 253 - void (*end_write_func)(struct bio *, int)) 257 + bio_end_io_t end_write_func) 254 258 { 255 259 struct bio *bio; 256 260 int ret, rw = WRITE;