diff options
| author | Martin K. Petersen <martin.petersen@oracle.com> | 2012-09-18 12:19:25 -0400 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2012-09-20 08:31:38 -0400 |
| commit | e2a60da74fc8215c68509a89e9a69c66363153db (patch) | |
| tree | c23dd6540dc211e2b2583c3e950a7f6977e3f1df /include/linux | |
| parent | d41570b7469724005eb78448a69289900f911963 (diff) | |
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 'include/linux')
| -rw-r--r-- | include/linux/bio.h | 23 | ||||
| -rw-r--r-- | include/linux/blk_types.h | 4 | ||||
| -rw-r--r-- | include/linux/blkdev.h | 22 |
3 files changed, 35 insertions, 14 deletions
diff --git a/include/linux/bio.h b/include/linux/bio.h index 52b9cbc3e4da..e54305cacc98 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h | |||
| @@ -386,9 +386,28 @@ static inline char *__bio_kmap_irq(struct bio *bio, unsigned short idx, | |||
| 386 | /* | 386 | /* |
| 387 | * Check whether this bio carries any data or not. A NULL bio is allowed. | 387 | * Check whether this bio carries any data or not. A NULL bio is allowed. |
| 388 | */ | 388 | */ |
| 389 | static inline int bio_has_data(struct bio *bio) | 389 | static inline bool bio_has_data(struct bio *bio) |
| 390 | { | 390 | { |
| 391 | return bio && bio->bi_io_vec != NULL; | 391 | if (bio && bio->bi_vcnt) |
| 392 | return true; | ||
| 393 | |||
| 394 | return false; | ||
| 395 | } | ||
| 396 | |||
| 397 | static inline bool bio_is_rw(struct bio *bio) | ||
| 398 | { | ||
| 399 | if (!bio_has_data(bio)) | ||
| 400 | return false; | ||
| 401 | |||
| 402 | return true; | ||
| 403 | } | ||
| 404 | |||
| 405 | static inline bool bio_mergeable(struct bio *bio) | ||
| 406 | { | ||
| 407 | if (bio->bi_rw & REQ_NOMERGE_FLAGS) | ||
| 408 | return false; | ||
| 409 | |||
| 410 | return true; | ||
| 392 | } | 411 | } |
| 393 | 412 | ||
| 394 | /* | 413 | /* |
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 3eefbb291192..1b229664f573 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h | |||
| @@ -194,6 +194,10 @@ enum rq_flag_bits { | |||
| 194 | REQ_DISCARD | REQ_NOIDLE | REQ_FLUSH | REQ_FUA | REQ_SECURE) | 194 | REQ_DISCARD | REQ_NOIDLE | REQ_FLUSH | REQ_FUA | REQ_SECURE) |
| 195 | #define REQ_CLONE_MASK REQ_COMMON_MASK | 195 | #define REQ_CLONE_MASK REQ_COMMON_MASK |
| 196 | 196 | ||
| 197 | /* This mask is used for both bio and request merge checking */ | ||
| 198 | #define REQ_NOMERGE_FLAGS \ | ||
| 199 | (REQ_NOMERGE | REQ_STARTED | REQ_SOFTBARRIER | REQ_FLUSH | REQ_FUA) | ||
| 200 | |||
| 197 | #define REQ_RAHEAD (1 << __REQ_RAHEAD) | 201 | #define REQ_RAHEAD (1 << __REQ_RAHEAD) |
| 198 | #define REQ_THROTTLED (1 << __REQ_THROTTLED) | 202 | #define REQ_THROTTLED (1 << __REQ_THROTTLED) |
| 199 | 203 | ||
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 4a2ab7c85393..3a6fea7460f1 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
| @@ -540,8 +540,7 @@ static inline void queue_flag_clear(unsigned int flag, struct request_queue *q) | |||
| 540 | 540 | ||
| 541 | #define blk_account_rq(rq) \ | 541 | #define blk_account_rq(rq) \ |
| 542 | (((rq)->cmd_flags & REQ_STARTED) && \ | 542 | (((rq)->cmd_flags & REQ_STARTED) && \ |
| 543 | ((rq)->cmd_type == REQ_TYPE_FS || \ | 543 | ((rq)->cmd_type == REQ_TYPE_FS)) |
| 544 | ((rq)->cmd_flags & REQ_DISCARD))) | ||
| 545 | 544 | ||
| 546 | #define blk_pm_request(rq) \ | 545 | #define blk_pm_request(rq) \ |
| 547 | ((rq)->cmd_type == REQ_TYPE_PM_SUSPEND || \ | 546 | ((rq)->cmd_type == REQ_TYPE_PM_SUSPEND || \ |
| @@ -595,17 +594,16 @@ static inline void blk_clear_rl_full(struct request_list *rl, bool sync) | |||
| 595 | rl->flags &= ~flag; | 594 | rl->flags &= ~flag; |
| 596 | } | 595 | } |
| 597 | 596 | ||
| 597 | static inline bool rq_mergeable(struct request *rq) | ||
| 598 | { | ||
| 599 | if (rq->cmd_type != REQ_TYPE_FS) | ||
| 600 | return false; | ||
| 598 | 601 | ||
| 599 | /* | 602 | if (rq->cmd_flags & REQ_NOMERGE_FLAGS) |
| 600 | * mergeable request must not have _NOMERGE or _BARRIER bit set, nor may | 603 | return false; |
| 601 | * it already be started by driver. | 604 | |
| 602 | */ | 605 | return true; |
| 603 | #define RQ_NOMERGE_FLAGS \ | 606 | } |
| 604 | (REQ_NOMERGE | REQ_STARTED | REQ_SOFTBARRIER | REQ_FLUSH | REQ_FUA | REQ_DISCARD) | ||
| 605 | #define rq_mergeable(rq) \ | ||
| 606 | (!((rq)->cmd_flags & RQ_NOMERGE_FLAGS) && \ | ||
| 607 | (((rq)->cmd_flags & REQ_DISCARD) || \ | ||
| 608 | (rq)->cmd_type == REQ_TYPE_FS)) | ||
| 609 | 607 | ||
| 610 | /* | 608 | /* |
| 611 | * q->prep_rq_fn return values | 609 | * q->prep_rq_fn return values |
