Commit a82afdfc authored by Tejun Heo's avatar Tejun Heo Committed by Jens Axboe

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: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
parent 0d03d59d
...@@ -1111,17 +1111,13 @@ void init_request_from_bio(struct request *req, struct bio *bio) ...@@ -1111,17 +1111,13 @@ void init_request_from_bio(struct request *req, struct bio *bio)
req->cmd_type = REQ_TYPE_FS; req->cmd_type = REQ_TYPE_FS;
/* /*
* inherit FAILFAST from bio (for read-ahead, and explicit FAILFAST) * Inherit FAILFAST from bio (for read-ahead, and explicit
* FAILFAST). FAILFAST flags are identical for req and bio.
*/ */
if (bio_rw_ahead(bio)) if (bio_rw_ahead(bio))
req->cmd_flags |= (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | req->cmd_flags |= REQ_FAILFAST_MASK;
REQ_FAILFAST_DRIVER); else
if (bio_failfast_dev(bio)) req->cmd_flags |= bio->bi_rw & REQ_FAILFAST_MASK;
req->cmd_flags |= REQ_FAILFAST_DEV;
if (bio_failfast_transport(bio))
req->cmd_flags |= REQ_FAILFAST_TRANSPORT;
if (bio_failfast_driver(bio))
req->cmd_flags |= REQ_FAILFAST_DRIVER;
if (unlikely(bio_discard(bio))) { if (unlikely(bio_discard(bio))) {
req->cmd_flags |= REQ_DISCARD; req->cmd_flags |= REQ_DISCARD;
...@@ -2239,9 +2235,8 @@ EXPORT_SYMBOL(__blk_end_request_cur); ...@@ -2239,9 +2235,8 @@ EXPORT_SYMBOL(__blk_end_request_cur);
void blk_rq_bio_prep(struct request_queue *q, struct request *rq, void blk_rq_bio_prep(struct request_queue *q, struct request *rq,
struct bio *bio) struct bio *bio)
{ {
/* Bit 0 (R/W) is identical in rq->cmd_flags and bio->bi_rw, and /* Bit 0 (R/W) is identical in rq->cmd_flags and bio->bi_rw */
we want BIO_RW_AHEAD (bit 1) to imply REQ_FAILFAST (bit 1). */ rq->cmd_flags |= bio->bi_rw & REQ_RW;
rq->cmd_flags |= (bio->bi_rw & 3);
if (bio_has_data(bio)) { if (bio_has_data(bio)) {
rq->nr_phys_segments = bio_phys_segments(q, bio); rq->nr_phys_segments = bio_phys_segments(q, bio);
......
...@@ -142,37 +142,40 @@ struct bio { ...@@ -142,37 +142,40 @@ struct bio {
* *
* bit 0 -- data direction * bit 0 -- data direction
* If not set, bio is a read from device. If set, it's a write to device. * If not set, bio is a read from device. If set, it's a write to device.
* bit 1 -- rw-ahead when set * bit 1 -- fail fast device errors
* bit 2 -- barrier * bit 2 -- fail fast transport errors
* bit 3 -- fail fast driver errors
* bit 4 -- rw-ahead when set
* bit 5 -- barrier
* Insert a serialization point in the IO queue, forcing previously * Insert a serialization point in the IO queue, forcing previously
* submitted IO to be completed before this one is issued. * submitted IO to be completed before this one is issued.
* bit 3 -- synchronous I/O hint. * bit 6 -- synchronous I/O hint.
* bit 4 -- Unplug the device immediately after submitting this bio. * bit 7 -- Unplug the device immediately after submitting this bio.
* bit 5 -- metadata request * bit 8 -- metadata request
* Used for tracing to differentiate metadata and data IO. May also * Used for tracing to differentiate metadata and data IO. May also
* get some preferential treatment in the IO scheduler * get some preferential treatment in the IO scheduler
* bit 6 -- discard sectors * bit 9 -- discard sectors
* Informs the lower level device that this range of sectors is no longer * Informs the lower level device that this range of sectors is no longer
* used by the file system and may thus be freed by the device. Used * used by the file system and may thus be freed by the device. Used
* for flash based storage. * for flash based storage.
* bit 7 -- fail fast device errors
* bit 8 -- fail fast transport errors
* bit 9 -- fail fast driver errors
* Don't want driver retries for any fast fail whatever the reason. * Don't want driver retries for any fast fail whatever the reason.
* bit 10 -- Tell the IO scheduler not to wait for more requests after this * bit 10 -- Tell the IO scheduler not to wait for more requests after this
one has been submitted, even if it is a SYNC request. one has been submitted, even if it is a SYNC request.
*/ */
#define BIO_RW 0 /* Must match RW in req flags (blkdev.h) */ enum bio_rw_flags {
#define BIO_RW_AHEAD 1 /* Must match FAILFAST in req flags */ BIO_RW,
#define BIO_RW_BARRIER 2 BIO_RW_FAILFAST_DEV,
#define BIO_RW_SYNCIO 3 BIO_RW_FAILFAST_TRANSPORT,
#define BIO_RW_UNPLUG 4 BIO_RW_FAILFAST_DRIVER,
#define BIO_RW_META 5 /* above flags must match REQ_* */
#define BIO_RW_DISCARD 6 BIO_RW_AHEAD,
#define BIO_RW_FAILFAST_DEV 7 BIO_RW_BARRIER,
#define BIO_RW_FAILFAST_TRANSPORT 8 BIO_RW_SYNCIO,
#define BIO_RW_FAILFAST_DRIVER 9 BIO_RW_UNPLUG,
#define BIO_RW_NOIDLE 10 BIO_RW_META,
BIO_RW_DISCARD,
BIO_RW_NOIDLE,
};
#define bio_rw_flagged(bio, flag) ((bio)->bi_rw & (1 << (flag))) #define bio_rw_flagged(bio, flag) ((bio)->bi_rw & (1 << (flag)))
......
...@@ -93,6 +93,7 @@ enum rq_flag_bits { ...@@ -93,6 +93,7 @@ enum rq_flag_bits {
__REQ_FAILFAST_DEV, /* no driver retries of device errors */ __REQ_FAILFAST_DEV, /* no driver retries of device errors */
__REQ_FAILFAST_TRANSPORT, /* no driver retries of transport errors */ __REQ_FAILFAST_TRANSPORT, /* no driver retries of transport errors */
__REQ_FAILFAST_DRIVER, /* no driver retries of driver errors */ __REQ_FAILFAST_DRIVER, /* no driver retries of driver errors */
/* above flags must match BIO_RW_* */
__REQ_DISCARD, /* request to discard sectors */ __REQ_DISCARD, /* request to discard sectors */
__REQ_SORTED, /* elevator knows about this request */ __REQ_SORTED, /* elevator knows about this request */
__REQ_SOFTBARRIER, /* may not be passed by ioscheduler */ __REQ_SOFTBARRIER, /* may not be passed by ioscheduler */
...@@ -143,6 +144,9 @@ enum rq_flag_bits { ...@@ -143,6 +144,9 @@ enum rq_flag_bits {
#define REQ_NOIDLE (1 << __REQ_NOIDLE) #define REQ_NOIDLE (1 << __REQ_NOIDLE)
#define REQ_IO_STAT (1 << __REQ_IO_STAT) #define REQ_IO_STAT (1 << __REQ_IO_STAT)
#define REQ_FAILFAST_MASK (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | \
REQ_FAILFAST_DRIVER)
#define BLK_MAX_CDB 16 #define BLK_MAX_CDB 16
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment