aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/blkdev.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/blkdev.h')
-rw-r--r--include/linux/blkdev.h44
1 files changed, 34 insertions, 10 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 69103e053c92..e23a86cae5ac 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -86,13 +86,14 @@ enum {
86}; 86};
87 87
88/* 88/*
89 * request type modified bits. first two bits match BIO_RW* bits, important 89 * request type modified bits. first four bits match BIO_RW* bits, important
90 */ 90 */
91enum rq_flag_bits { 91enum rq_flag_bits {
92 __REQ_RW, /* not set, read. set, write */ 92 __REQ_RW, /* not set, read. set, write */
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 */
@@ -114,6 +115,7 @@ enum rq_flag_bits {
114 __REQ_INTEGRITY, /* integrity metadata has been remapped */ 115 __REQ_INTEGRITY, /* integrity metadata has been remapped */
115 __REQ_NOIDLE, /* Don't anticipate more IO after this one */ 116 __REQ_NOIDLE, /* Don't anticipate more IO after this one */
116 __REQ_IO_STAT, /* account I/O stat */ 117 __REQ_IO_STAT, /* account I/O stat */
118 __REQ_MIXED_MERGE, /* merge of different types, fail separately */
117 __REQ_NR_BITS, /* stops here */ 119 __REQ_NR_BITS, /* stops here */
118}; 120};
119 121
@@ -142,6 +144,10 @@ enum rq_flag_bits {
142#define REQ_INTEGRITY (1 << __REQ_INTEGRITY) 144#define REQ_INTEGRITY (1 << __REQ_INTEGRITY)
143#define REQ_NOIDLE (1 << __REQ_NOIDLE) 145#define REQ_NOIDLE (1 << __REQ_NOIDLE)
144#define REQ_IO_STAT (1 << __REQ_IO_STAT) 146#define REQ_IO_STAT (1 << __REQ_IO_STAT)
147#define REQ_MIXED_MERGE (1 << __REQ_MIXED_MERGE)
148
149#define REQ_FAILFAST_MASK (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | \
150 REQ_FAILFAST_DRIVER)
145 151
146#define BLK_MAX_CDB 16 152#define BLK_MAX_CDB 16
147 153
@@ -453,10 +459,12 @@ struct request_queue
453#define QUEUE_FLAG_NONROT 14 /* non-rotational device (SSD) */ 459#define QUEUE_FLAG_NONROT 14 /* non-rotational device (SSD) */
454#define QUEUE_FLAG_VIRT QUEUE_FLAG_NONROT /* paravirt device */ 460#define QUEUE_FLAG_VIRT QUEUE_FLAG_NONROT /* paravirt device */
455#define QUEUE_FLAG_IO_STAT 15 /* do IO stats */ 461#define QUEUE_FLAG_IO_STAT 15 /* do IO stats */
462#define QUEUE_FLAG_CQ 16 /* hardware does queuing */
456 463
457#define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ 464#define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \
458 (1 << QUEUE_FLAG_CLUSTER) | \ 465 (1 << QUEUE_FLAG_CLUSTER) | \
459 (1 << QUEUE_FLAG_STACKABLE)) 466 (1 << QUEUE_FLAG_STACKABLE) | \
467 (1 << QUEUE_FLAG_SAME_COMP))
460 468
461static inline int queue_is_locked(struct request_queue *q) 469static inline int queue_is_locked(struct request_queue *q)
462{ 470{
@@ -575,6 +583,7 @@ enum {
575 583
576#define blk_queue_plugged(q) test_bit(QUEUE_FLAG_PLUGGED, &(q)->queue_flags) 584#define blk_queue_plugged(q) test_bit(QUEUE_FLAG_PLUGGED, &(q)->queue_flags)
577#define blk_queue_tagged(q) test_bit(QUEUE_FLAG_QUEUED, &(q)->queue_flags) 585#define blk_queue_tagged(q) test_bit(QUEUE_FLAG_QUEUED, &(q)->queue_flags)
586#define blk_queue_queuing(q) test_bit(QUEUE_FLAG_CQ, &(q)->queue_flags)
578#define blk_queue_stopped(q) test_bit(QUEUE_FLAG_STOPPED, &(q)->queue_flags) 587#define blk_queue_stopped(q) test_bit(QUEUE_FLAG_STOPPED, &(q)->queue_flags)
579#define blk_queue_nomerges(q) test_bit(QUEUE_FLAG_NOMERGES, &(q)->queue_flags) 588#define blk_queue_nomerges(q) test_bit(QUEUE_FLAG_NOMERGES, &(q)->queue_flags)
580#define blk_queue_nonrot(q) test_bit(QUEUE_FLAG_NONROT, &(q)->queue_flags) 589#define blk_queue_nonrot(q) test_bit(QUEUE_FLAG_NONROT, &(q)->queue_flags)
@@ -828,11 +837,13 @@ static inline void blk_run_address_space(struct address_space *mapping)
828} 837}
829 838
830/* 839/*
831 * blk_rq_pos() : the current sector 840 * blk_rq_pos() : the current sector
832 * blk_rq_bytes() : bytes left in the entire request 841 * blk_rq_bytes() : bytes left in the entire request
833 * blk_rq_cur_bytes() : bytes left in the current segment 842 * blk_rq_cur_bytes() : bytes left in the current segment
834 * blk_rq_sectors() : sectors left in the entire request 843 * blk_rq_err_bytes() : bytes left till the next error boundary
835 * blk_rq_cur_sectors() : sectors left in the current segment 844 * blk_rq_sectors() : sectors left in the entire request
845 * blk_rq_cur_sectors() : sectors left in the current segment
846 * blk_rq_err_sectors() : sectors left till the next error boundary
836 */ 847 */
837static inline sector_t blk_rq_pos(const struct request *rq) 848static inline sector_t blk_rq_pos(const struct request *rq)
838{ 849{
@@ -849,6 +860,8 @@ static inline int blk_rq_cur_bytes(const struct request *rq)
849 return rq->bio ? bio_cur_bytes(rq->bio) : 0; 860 return rq->bio ? bio_cur_bytes(rq->bio) : 0;
850} 861}
851 862
863extern unsigned int blk_rq_err_bytes(const struct request *rq);
864
852static inline unsigned int blk_rq_sectors(const struct request *rq) 865static inline unsigned int blk_rq_sectors(const struct request *rq)
853{ 866{
854 return blk_rq_bytes(rq) >> 9; 867 return blk_rq_bytes(rq) >> 9;
@@ -859,6 +872,11 @@ static inline unsigned int blk_rq_cur_sectors(const struct request *rq)
859 return blk_rq_cur_bytes(rq) >> 9; 872 return blk_rq_cur_bytes(rq) >> 9;
860} 873}
861 874
875static inline unsigned int blk_rq_err_sectors(const struct request *rq)
876{
877 return blk_rq_err_bytes(rq) >> 9;
878}
879
862/* 880/*
863 * Request issue related functions. 881 * Request issue related functions.
864 */ 882 */
@@ -885,10 +903,12 @@ extern bool blk_end_request(struct request *rq, int error,
885 unsigned int nr_bytes); 903 unsigned int nr_bytes);
886extern void blk_end_request_all(struct request *rq, int error); 904extern void blk_end_request_all(struct request *rq, int error);
887extern bool blk_end_request_cur(struct request *rq, int error); 905extern bool blk_end_request_cur(struct request *rq, int error);
906extern bool blk_end_request_err(struct request *rq, int error);
888extern bool __blk_end_request(struct request *rq, int error, 907extern bool __blk_end_request(struct request *rq, int error,
889 unsigned int nr_bytes); 908 unsigned int nr_bytes);
890extern void __blk_end_request_all(struct request *rq, int error); 909extern void __blk_end_request_all(struct request *rq, int error);
891extern bool __blk_end_request_cur(struct request *rq, int error); 910extern bool __blk_end_request_cur(struct request *rq, int error);
911extern bool __blk_end_request_err(struct request *rq, int error);
892 912
893extern void blk_complete_request(struct request *); 913extern void blk_complete_request(struct request *);
894extern void __blk_complete_request(struct request *); 914extern void __blk_complete_request(struct request *);
@@ -915,6 +935,7 @@ extern void blk_queue_alignment_offset(struct request_queue *q,
915 unsigned int alignment); 935 unsigned int alignment);
916extern void blk_limits_io_min(struct queue_limits *limits, unsigned int min); 936extern void blk_limits_io_min(struct queue_limits *limits, unsigned int min);
917extern void blk_queue_io_min(struct request_queue *q, unsigned int min); 937extern void blk_queue_io_min(struct request_queue *q, unsigned int min);
938extern void blk_limits_io_opt(struct queue_limits *limits, unsigned int opt);
918extern void blk_queue_io_opt(struct request_queue *q, unsigned int opt); 939extern void blk_queue_io_opt(struct request_queue *q, unsigned int opt);
919extern void blk_set_default_limits(struct queue_limits *lim); 940extern void blk_set_default_limits(struct queue_limits *lim);
920extern int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, 941extern int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
@@ -977,15 +998,18 @@ static inline struct request *blk_map_queue_find_tag(struct blk_queue_tag *bqt,
977} 998}
978 999
979extern int blkdev_issue_flush(struct block_device *, sector_t *); 1000extern int blkdev_issue_flush(struct block_device *, sector_t *);
980extern int blkdev_issue_discard(struct block_device *, 1001#define DISCARD_FL_WAIT 0x01 /* wait for completion */
981 sector_t sector, sector_t nr_sects, gfp_t); 1002#define DISCARD_FL_BARRIER 0x02 /* issue DISCARD_BARRIER request */
1003extern int blkdev_issue_discard(struct block_device *, sector_t sector,
1004 sector_t nr_sects, gfp_t, int flags);
982 1005
983static inline int sb_issue_discard(struct super_block *sb, 1006static inline int sb_issue_discard(struct super_block *sb,
984 sector_t block, sector_t nr_blocks) 1007 sector_t block, sector_t nr_blocks)
985{ 1008{
986 block <<= (sb->s_blocksize_bits - 9); 1009 block <<= (sb->s_blocksize_bits - 9);
987 nr_blocks <<= (sb->s_blocksize_bits - 9); 1010 nr_blocks <<= (sb->s_blocksize_bits - 9);
988 return blkdev_issue_discard(sb->s_bdev, block, nr_blocks, GFP_KERNEL); 1011 return blkdev_issue_discard(sb->s_bdev, block, nr_blocks, GFP_KERNEL,
1012 DISCARD_FL_BARRIER);
989} 1013}
990 1014
991extern int blk_verify_command(unsigned char *cmd, fmode_t has_write_perm); 1015extern int blk_verify_command(unsigned char *cmd, fmode_t has_write_perm);