diff options
author | Tejun Heo <tj@kernel.org> | 2009-07-03 04:48:16 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2009-09-11 08:33:27 -0400 |
commit | a82afdfcb8c0df09776b6458af6b68fc58b2e87b (patch) | |
tree | d53910e4c2e9d1502cf2a7ce67a67cc54decb7fa | |
parent | 0d03d59d9b31cd1e33b7e46a80b6fef66244b1f2 (diff) |
block: use the same failfast bits for bio and request
bio and request use the same set of failfast bits. This patch makes
the following changes to simplify things.
* enumify BIO_RW* bits and reorder bits such that BIOS_RW_FAILFAST_*
bits coincide with __REQ_FAILFAST_* bits.
* The above pushes BIO_RW_AHEAD out of sync with __REQ_FAILFAST_DEV
but the matching is useless anyway. init_request_from_bio() is
responsible for setting FAILFAST bits on FS requests and non-FS
requests never use BIO_RW_AHEAD. Drop the code and comment from
blk_rq_bio_prep().
* Define REQ_FAILFAST_MASK which is OR of all FAILFAST bits and
simplify FAILFAST flags handling in init_request_from_bio().
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r-- | block/blk-core.c | 19 | ||||
-rw-r--r-- | include/linux/bio.h | 43 | ||||
-rw-r--r-- | include/linux/blkdev.h | 4 |
3 files changed, 34 insertions, 32 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index e3299a77a0d8..4daae1ee2b23 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -1111,17 +1111,13 @@ void init_request_from_bio(struct request *req, struct bio *bio) | |||
1111 | req->cmd_type = REQ_TYPE_FS; | 1111 | req->cmd_type = REQ_TYPE_FS; |
1112 | 1112 | ||
1113 | /* | 1113 | /* |
1114 | * inherit FAILFAST from bio (for read-ahead, and explicit FAILFAST) | 1114 | * Inherit FAILFAST from bio (for read-ahead, and explicit |
1115 | * FAILFAST). FAILFAST flags are identical for req and bio. | ||
1115 | */ | 1116 | */ |
1116 | if (bio_rw_ahead(bio)) | 1117 | if (bio_rw_ahead(bio)) |
1117 | req->cmd_flags |= (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | | 1118 | req->cmd_flags |= REQ_FAILFAST_MASK; |
1118 | REQ_FAILFAST_DRIVER); | 1119 | else |
1119 | if (bio_failfast_dev(bio)) | 1120 | req->cmd_flags |= bio->bi_rw & REQ_FAILFAST_MASK; |
1120 | req->cmd_flags |= REQ_FAILFAST_DEV; | ||
1121 | if (bio_failfast_transport(bio)) | ||
1122 | req->cmd_flags |= REQ_FAILFAST_TRANSPORT; | ||
1123 | if (bio_failfast_driver(bio)) | ||
1124 | req->cmd_flags |= REQ_FAILFAST_DRIVER; | ||
1125 | 1121 | ||
1126 | if (unlikely(bio_discard(bio))) { | 1122 | if (unlikely(bio_discard(bio))) { |
1127 | req->cmd_flags |= REQ_DISCARD; | 1123 | req->cmd_flags |= REQ_DISCARD; |
@@ -2239,9 +2235,8 @@ EXPORT_SYMBOL(__blk_end_request_cur); | |||
2239 | void blk_rq_bio_prep(struct request_queue *q, struct request *rq, | 2235 | void blk_rq_bio_prep(struct request_queue *q, struct request *rq, |
2240 | struct bio *bio) | 2236 | struct bio *bio) |
2241 | { | 2237 | { |
2242 | /* Bit 0 (R/W) is identical in rq->cmd_flags and bio->bi_rw, and | 2238 | /* Bit 0 (R/W) is identical in rq->cmd_flags and bio->bi_rw */ |
2243 | we want BIO_RW_AHEAD (bit 1) to imply REQ_FAILFAST (bit 1). */ | 2239 | rq->cmd_flags |= bio->bi_rw & REQ_RW; |
2244 | rq->cmd_flags |= (bio->bi_rw & 3); | ||
2245 | 2240 | ||
2246 | if (bio_has_data(bio)) { | 2241 | if (bio_has_data(bio)) { |
2247 | rq->nr_phys_segments = bio_phys_segments(q, bio); | 2242 | rq->nr_phys_segments = bio_phys_segments(q, bio); |
diff --git a/include/linux/bio.h b/include/linux/bio.h index 2892b710771c..a299ed38fcd7 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h | |||
@@ -142,37 +142,40 @@ struct bio { | |||
142 | * | 142 | * |
143 | * bit 0 -- data direction | 143 | * bit 0 -- data direction |
144 | * If not set, bio is a read from device. If set, it's a write to device. | 144 | * If not set, bio is a read from device. If set, it's a write to device. |
145 | * bit 1 -- rw-ahead when set | 145 | * bit 1 -- fail fast device errors |
146 | * bit 2 -- barrier | 146 | * bit 2 -- fail fast transport errors |
147 | * bit 3 -- fail fast driver errors | ||
148 | * bit 4 -- rw-ahead when set | ||
149 | * bit 5 -- barrier | ||
147 | * Insert a serialization point in the IO queue, forcing previously | 150 | * Insert a serialization point in the IO queue, forcing previously |
148 | * submitted IO to be completed before this one is issued. | 151 | * submitted IO to be completed before this one is issued. |
149 | * bit 3 -- synchronous I/O hint. | 152 | * bit 6 -- synchronous I/O hint. |
150 | * bit 4 -- Unplug the device immediately after submitting this bio. | 153 | * bit 7 -- Unplug the device immediately after submitting this bio. |
151 | * bit 5 -- metadata request | 154 | * bit 8 -- metadata request |
152 | * Used for tracing to differentiate metadata and data IO. May also | 155 | * Used for tracing to differentiate metadata and data IO. May also |
153 | * get some preferential treatment in the IO scheduler | 156 | * get some preferential treatment in the IO scheduler |
154 | * bit 6 -- discard sectors | 157 | * bit 9 -- discard sectors |
155 | * Informs the lower level device that this range of sectors is no longer | 158 | * Informs the lower level device that this range of sectors is no longer |
156 | * used by the file system and may thus be freed by the device. Used | 159 | * used by the file system and may thus be freed by the device. Used |
157 | * for flash based storage. | 160 | * for flash based storage. |
158 | * bit 7 -- fail fast device errors | ||
159 | * bit 8 -- fail fast transport errors | ||
160 | * bit 9 -- fail fast driver errors | ||
161 | * Don't want driver retries for any fast fail whatever the reason. | 161 | * Don't want driver retries for any fast fail whatever the reason. |
162 | * bit 10 -- Tell the IO scheduler not to wait for more requests after this | 162 | * bit 10 -- Tell the IO scheduler not to wait for more requests after this |
163 | one has been submitted, even if it is a SYNC request. | 163 | one has been submitted, even if it is a SYNC request. |
164 | */ | 164 | */ |
165 | #define BIO_RW 0 /* Must match RW in req flags (blkdev.h) */ | 165 | enum bio_rw_flags { |
166 | #define BIO_RW_AHEAD 1 /* Must match FAILFAST in req flags */ | 166 | BIO_RW, |
167 | #define BIO_RW_BARRIER 2 | 167 | BIO_RW_FAILFAST_DEV, |
168 | #define BIO_RW_SYNCIO 3 | 168 | BIO_RW_FAILFAST_TRANSPORT, |
169 | #define BIO_RW_UNPLUG 4 | 169 | BIO_RW_FAILFAST_DRIVER, |
170 | #define BIO_RW_META 5 | 170 | /* above flags must match REQ_* */ |
171 | #define BIO_RW_DISCARD 6 | 171 | BIO_RW_AHEAD, |
172 | #define BIO_RW_FAILFAST_DEV 7 | 172 | BIO_RW_BARRIER, |
173 | #define BIO_RW_FAILFAST_TRANSPORT 8 | 173 | BIO_RW_SYNCIO, |
174 | #define BIO_RW_FAILFAST_DRIVER 9 | 174 | BIO_RW_UNPLUG, |
175 | #define BIO_RW_NOIDLE 10 | 175 | BIO_RW_META, |
176 | BIO_RW_DISCARD, | ||
177 | BIO_RW_NOIDLE, | ||
178 | }; | ||
176 | 179 | ||
177 | #define bio_rw_flagged(bio, flag) ((bio)->bi_rw & (1 << (flag))) | 180 | #define bio_rw_flagged(bio, flag) ((bio)->bi_rw & (1 << (flag))) |
178 | 181 | ||
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 69103e053c92..c3015736d814 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
@@ -93,6 +93,7 @@ enum rq_flag_bits { | |||
93 | __REQ_FAILFAST_DEV, /* no driver retries of device errors */ | 93 | __REQ_FAILFAST_DEV, /* no driver retries of device errors */ |
94 | __REQ_FAILFAST_TRANSPORT, /* no driver retries of transport errors */ | 94 | __REQ_FAILFAST_TRANSPORT, /* no driver retries of transport errors */ |
95 | __REQ_FAILFAST_DRIVER, /* no driver retries of driver errors */ | 95 | __REQ_FAILFAST_DRIVER, /* no driver retries of driver errors */ |
96 | /* above flags must match BIO_RW_* */ | ||
96 | __REQ_DISCARD, /* request to discard sectors */ | 97 | __REQ_DISCARD, /* request to discard sectors */ |
97 | __REQ_SORTED, /* elevator knows about this request */ | 98 | __REQ_SORTED, /* elevator knows about this request */ |
98 | __REQ_SOFTBARRIER, /* may not be passed by ioscheduler */ | 99 | __REQ_SOFTBARRIER, /* may not be passed by ioscheduler */ |
@@ -143,6 +144,9 @@ enum rq_flag_bits { | |||
143 | #define REQ_NOIDLE (1 << __REQ_NOIDLE) | 144 | #define REQ_NOIDLE (1 << __REQ_NOIDLE) |
144 | #define REQ_IO_STAT (1 << __REQ_IO_STAT) | 145 | #define REQ_IO_STAT (1 << __REQ_IO_STAT) |
145 | 146 | ||
147 | #define REQ_FAILFAST_MASK (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | \ | ||
148 | REQ_FAILFAST_DRIVER) | ||
149 | |||
146 | #define BLK_MAX_CDB 16 | 150 | #define BLK_MAX_CDB 16 |
147 | 151 | ||
148 | /* | 152 | /* |