diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-02-19 18:35:12 -0800 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-02-19 18:35:12 -0800 |
commit | fa2c8f401797eee814b7b9fa0b23fa6c4c3f5533 (patch) | |
tree | 826fb23071b866e112d6e9c510fe3ad4d668acdc /block/blk-merge.c | |
parent | a387419612f9c246701a5080bccecf3c04f65277 (diff) | |
parent | b01543dfe67bb1d191998e90d20534dc354de059 (diff) |
Merge tag 'v3.3-rc4' into for-3.4 in order to resolve the conflict
resolved below within the FSI driver and allow the application of the
dmaeengine conversion that depends on this resolution.
Linux 3.3-rc4
Conflicts:
sound/soc/sh/fsi.c
Diffstat (limited to 'block/blk-merge.c')
-rw-r--r-- | block/blk-merge.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/block/blk-merge.c b/block/blk-merge.c index cfcc37cb222..160035f5488 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -471,3 +471,40 @@ int blk_attempt_req_merge(struct request_queue *q, struct request *rq, { return attempt_merge(q, rq, next); } + +bool blk_rq_merge_ok(struct request *rq, struct bio *bio) +{ + if (!rq_mergeable(rq)) + return false; + + /* don't merge file system requests and discard requests */ + if ((bio->bi_rw & REQ_DISCARD) != (rq->bio->bi_rw & REQ_DISCARD)) + return false; + + /* don't merge discard requests and secure discard requests */ + if ((bio->bi_rw & REQ_SECURE) != (rq->bio->bi_rw & REQ_SECURE)) + return false; + + /* different data direction or already started, don't merge */ + if (bio_data_dir(bio) != rq_data_dir(rq)) + return false; + + /* must be same device and not a special request */ + if (rq->rq_disk != bio->bi_bdev->bd_disk || rq->special) + return false; + + /* only merge integrity protected bio into ditto rq */ + if (bio_integrity(bio) != blk_integrity_rq(rq)) + return false; + + return true; +} + +int blk_try_merge(struct request *rq, struct bio *bio) +{ + if (blk_rq_pos(rq) + blk_rq_sectors(rq) == bio->bi_sector) + return ELEVATOR_BACK_MERGE; + else if (blk_rq_pos(rq) - bio_sectors(bio) == bio->bi_sector) + return ELEVATOR_FRONT_MERGE; + return ELEVATOR_NO_MERGE; +} |