diff options
author | David Woodhouse <David.Woodhouse@intel.com> | 2008-08-09 11:42:20 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2008-10-09 02:56:02 -0400 |
commit | e17fc0a1ccf88f6d4dcb363729f3141b0958c325 (patch) | |
tree | 0a7c2dc1c3159c2af14d87c67ca83e158b2c78b5 /include/linux | |
parent | d30a2605be9d5132d95944916e8f578fcfe4f976 (diff) |
Allow elevators to sort/merge discard requests
But blkdev_issue_discard() still emits requests which are interpreted as
soft barriers, because naïve callers might otherwise issue subsequent
writes to those same sectors, which might cross on the queue (if they're
reallocated quickly enough).
Callers still _can_ issue non-barrier discard requests, but they have to
take care of queue ordering for themselves.
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/bio.h | 2 | ||||
-rw-r--r-- | include/linux/blkdev.h | 5 | ||||
-rw-r--r-- | include/linux/fs.h | 3 |
3 files changed, 6 insertions, 4 deletions
diff --git a/include/linux/bio.h b/include/linux/bio.h index 1fdfc5621c83..33c3947d61e9 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h | |||
@@ -188,8 +188,8 @@ struct bio { | |||
188 | #define bio_failfast(bio) ((bio)->bi_rw & (1 << BIO_RW_FAILFAST)) | 188 | #define bio_failfast(bio) ((bio)->bi_rw & (1 << BIO_RW_FAILFAST)) |
189 | #define bio_rw_ahead(bio) ((bio)->bi_rw & (1 << BIO_RW_AHEAD)) | 189 | #define bio_rw_ahead(bio) ((bio)->bi_rw & (1 << BIO_RW_AHEAD)) |
190 | #define bio_rw_meta(bio) ((bio)->bi_rw & (1 << BIO_RW_META)) | 190 | #define bio_rw_meta(bio) ((bio)->bi_rw & (1 << BIO_RW_META)) |
191 | #define bio_empty_barrier(bio) (bio_barrier(bio) && !bio_has_data(bio)) | ||
192 | #define bio_discard(bio) ((bio)->bi_rw & (1 << BIO_RW_DISCARD)) | 191 | #define bio_discard(bio) ((bio)->bi_rw & (1 << BIO_RW_DISCARD)) |
192 | #define bio_empty_barrier(bio) (bio_barrier(bio) && !bio_has_data(bio) && !bio_discard(bio)) | ||
193 | 193 | ||
194 | static inline unsigned int bio_cur_sectors(struct bio *bio) | 194 | static inline unsigned int bio_cur_sectors(struct bio *bio) |
195 | { | 195 | { |
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 727886d25c4e..e9eb35c9bf26 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
@@ -541,7 +541,7 @@ enum { | |||
541 | #define blk_noretry_request(rq) ((rq)->cmd_flags & REQ_FAILFAST) | 541 | #define blk_noretry_request(rq) ((rq)->cmd_flags & REQ_FAILFAST) |
542 | #define blk_rq_started(rq) ((rq)->cmd_flags & REQ_STARTED) | 542 | #define blk_rq_started(rq) ((rq)->cmd_flags & REQ_STARTED) |
543 | 543 | ||
544 | #define blk_account_rq(rq) (blk_rq_started(rq) && blk_fs_request(rq)) | 544 | #define blk_account_rq(rq) (blk_rq_started(rq) && (blk_fs_request(rq) || blk_discard_rq(rq))) |
545 | 545 | ||
546 | #define blk_pm_suspend_request(rq) ((rq)->cmd_type == REQ_TYPE_PM_SUSPEND) | 546 | #define blk_pm_suspend_request(rq) ((rq)->cmd_type == REQ_TYPE_PM_SUSPEND) |
547 | #define blk_pm_resume_request(rq) ((rq)->cmd_type == REQ_TYPE_PM_RESUME) | 547 | #define blk_pm_resume_request(rq) ((rq)->cmd_type == REQ_TYPE_PM_RESUME) |
@@ -598,7 +598,8 @@ static inline void blk_clear_queue_full(struct request_queue *q, int rw) | |||
598 | #define RQ_NOMERGE_FLAGS \ | 598 | #define RQ_NOMERGE_FLAGS \ |
599 | (REQ_NOMERGE | REQ_STARTED | REQ_HARDBARRIER | REQ_SOFTBARRIER) | 599 | (REQ_NOMERGE | REQ_STARTED | REQ_HARDBARRIER | REQ_SOFTBARRIER) |
600 | #define rq_mergeable(rq) \ | 600 | #define rq_mergeable(rq) \ |
601 | (!((rq)->cmd_flags & RQ_NOMERGE_FLAGS) && blk_fs_request((rq))) | 601 | (!((rq)->cmd_flags & RQ_NOMERGE_FLAGS) && \ |
602 | (blk_discard_rq(rq) || blk_fs_request((rq)))) | ||
602 | 603 | ||
603 | /* | 604 | /* |
604 | * q->prep_rq_fn return values | 605 | * q->prep_rq_fn return values |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 88358ca6af25..860689f541b1 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -87,7 +87,8 @@ extern int dir_notify_enable; | |||
87 | #define WRITE_SYNC (WRITE | (1 << BIO_RW_SYNC)) | 87 | #define WRITE_SYNC (WRITE | (1 << BIO_RW_SYNC)) |
88 | #define SWRITE_SYNC (SWRITE | (1 << BIO_RW_SYNC)) | 88 | #define SWRITE_SYNC (SWRITE | (1 << BIO_RW_SYNC)) |
89 | #define WRITE_BARRIER (WRITE | (1 << BIO_RW_BARRIER)) | 89 | #define WRITE_BARRIER (WRITE | (1 << BIO_RW_BARRIER)) |
90 | #define WRITE_DISCARD (WRITE | (1 << BIO_RW_DISCARD)) | 90 | #define DISCARD_NOBARRIER (1 << BIO_RW_DISCARD) |
91 | #define DISCARD_BARRIER ((1 << BIO_RW_DISCARD) | (1 << BIO_RW_BARRIER)) | ||
91 | 92 | ||
92 | #define SEL_IN 1 | 93 | #define SEL_IN 1 |
93 | #define SEL_OUT 2 | 94 | #define SEL_OUT 2 |