aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin K. Petersen2012-09-18 11:19:25 -0500
committerJens Axboe2012-09-20 07:31:38 -0500
commite2a60da74fc8215c68509a89e9a69c66363153db (patch)
treec23dd6540dc211e2b2583c3e950a7f6977e3f1df /block/blk-core.c
parentd41570b7469724005eb78448a69289900f911963 (diff)
downloadkernel-common-e2a60da74fc8215c68509a89e9a69c66363153db.tar.gz
kernel-common-e2a60da74fc8215c68509a89e9a69c66363153db.tar.xz
kernel-common-e2a60da74fc8215c68509a89e9a69c66363153db.zip
block: Clean up special command handling logic
Remove special-casing of non-rw fs style requests (discard). The nomerge flags are consolidated in blk_types.h, and rq_mergeable() and bio_mergeable() have been modified to use them. bio_is_rw() is used in place of bio_has_data() a few places. This is done to to distinguish true reads and writes from other fs type requests that carry a payload (e.g. write same). Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Acked-by: Mike Snitzer <snitzer@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-core.c')
-rw-r--r--block/blk-core.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index 2d739ca1092..5cc29299f6a 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1657,8 +1657,8 @@ generic_make_request_checks(struct bio *bio)
1657 goto end_io; 1657 goto end_io;
1658 } 1658 }
1659 1659
1660 if (unlikely(!(bio->bi_rw & REQ_DISCARD) && 1660 if (likely(bio_is_rw(bio) &&
1661 nr_sectors > queue_max_hw_sectors(q))) { 1661 nr_sectors > queue_max_hw_sectors(q))) {
1662 printk(KERN_ERR "bio too big device %s (%u > %u)\n", 1662 printk(KERN_ERR "bio too big device %s (%u > %u)\n",
1663 bdevname(bio->bi_bdev, b), 1663 bdevname(bio->bi_bdev, b),
1664 bio_sectors(bio), 1664 bio_sectors(bio),
@@ -1699,8 +1699,7 @@ generic_make_request_checks(struct bio *bio)
1699 1699
1700 if ((bio->bi_rw & REQ_DISCARD) && 1700 if ((bio->bi_rw & REQ_DISCARD) &&
1701 (!blk_queue_discard(q) || 1701 (!blk_queue_discard(q) ||
1702 ((bio->bi_rw & REQ_SECURE) && 1702 ((bio->bi_rw & REQ_SECURE) && !blk_queue_secdiscard(q)))) {
1703 !blk_queue_secdiscard(q)))) {
1704 err = -EOPNOTSUPP; 1703 err = -EOPNOTSUPP;
1705 goto end_io; 1704 goto end_io;
1706 } 1705 }
@@ -1818,7 +1817,7 @@ void submit_bio(int rw, struct bio *bio)
1818 * If it's a regular read/write or a barrier with data attached, 1817 * If it's a regular read/write or a barrier with data attached,
1819 * go through the normal accounting stuff before submission. 1818 * go through the normal accounting stuff before submission.
1820 */ 1819 */
1821 if (bio_has_data(bio) && !(rw & REQ_DISCARD)) { 1820 if (bio_has_data(bio)) {
1822 if (rw & WRITE) { 1821 if (rw & WRITE) {
1823 count_vm_events(PGPGOUT, count); 1822 count_vm_events(PGPGOUT, count);
1824 } else { 1823 } else {
@@ -1864,7 +1863,7 @@ EXPORT_SYMBOL(submit_bio);
1864 */ 1863 */
1865int blk_rq_check_limits(struct request_queue *q, struct request *rq) 1864int blk_rq_check_limits(struct request_queue *q, struct request *rq)
1866{ 1865{
1867 if (rq->cmd_flags & REQ_DISCARD) 1866 if (!rq_mergeable(rq))
1868 return 0; 1867 return 0;
1869 1868
1870 if (blk_rq_sectors(rq) > queue_max_sectors(q) || 1869 if (blk_rq_sectors(rq) > queue_max_sectors(q) ||
@@ -2338,7 +2337,7 @@ bool blk_update_request(struct request *req, int error, unsigned int nr_bytes)
2338 req->buffer = bio_data(req->bio); 2337 req->buffer = bio_data(req->bio);
2339 2338
2340 /* update sector only for requests with clear definition of sector */ 2339 /* update sector only for requests with clear definition of sector */
2341 if (req->cmd_type == REQ_TYPE_FS || (req->cmd_flags & REQ_DISCARD)) 2340 if (req->cmd_type == REQ_TYPE_FS)
2342 req->__sector += total_bytes >> 9; 2341 req->__sector += total_bytes >> 9;
2343 2342
2344 /* mixed attributes always follow the first bio */ 2343 /* mixed attributes always follow the first bio */