diff options
Diffstat (limited to 'include/linux/blkdev.h')
| -rw-r--r-- | include/linux/blkdev.h | 246 |
1 files changed, 219 insertions, 27 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index c47c358ba052..83695641bd5e 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include <linux/rcupdate.h> | 24 | #include <linux/rcupdate.h> |
| 25 | #include <linux/percpu-refcount.h> | 25 | #include <linux/percpu-refcount.h> |
| 26 | #include <linux/scatterlist.h> | 26 | #include <linux/scatterlist.h> |
| 27 | #include <linux/blkzoned.h> | ||
| 27 | 28 | ||
| 28 | struct module; | 29 | struct module; |
| 29 | struct scsi_ioctl_command; | 30 | struct scsi_ioctl_command; |
| @@ -37,6 +38,7 @@ struct bsg_job; | |||
| 37 | struct blkcg_gq; | 38 | struct blkcg_gq; |
| 38 | struct blk_flush_queue; | 39 | struct blk_flush_queue; |
| 39 | struct pr_ops; | 40 | struct pr_ops; |
| 41 | struct rq_wb; | ||
| 40 | 42 | ||
| 41 | #define BLKDEV_MIN_RQ 4 | 43 | #define BLKDEV_MIN_RQ 4 |
| 42 | #define BLKDEV_MAX_RQ 128 /* Default maximum */ | 44 | #define BLKDEV_MAX_RQ 128 /* Default maximum */ |
| @@ -77,6 +79,55 @@ enum rq_cmd_type_bits { | |||
| 77 | REQ_TYPE_DRV_PRIV, /* driver defined types from here */ | 79 | REQ_TYPE_DRV_PRIV, /* driver defined types from here */ |
| 78 | }; | 80 | }; |
| 79 | 81 | ||
| 82 | /* | ||
| 83 | * request flags */ | ||
| 84 | typedef __u32 __bitwise req_flags_t; | ||
| 85 | |||
| 86 | /* elevator knows about this request */ | ||
| 87 | #define RQF_SORTED ((__force req_flags_t)(1 << 0)) | ||
| 88 | /* drive already may have started this one */ | ||
| 89 | #define RQF_STARTED ((__force req_flags_t)(1 << 1)) | ||
| 90 | /* uses tagged queueing */ | ||
| 91 | #define RQF_QUEUED ((__force req_flags_t)(1 << 2)) | ||
| 92 | /* may not be passed by ioscheduler */ | ||
| 93 | #define RQF_SOFTBARRIER ((__force req_flags_t)(1 << 3)) | ||
| 94 | /* request for flush sequence */ | ||
| 95 | #define RQF_FLUSH_SEQ ((__force req_flags_t)(1 << 4)) | ||
| 96 | /* merge of different types, fail separately */ | ||
| 97 | #define RQF_MIXED_MERGE ((__force req_flags_t)(1 << 5)) | ||
| 98 | /* track inflight for MQ */ | ||
| 99 | #define RQF_MQ_INFLIGHT ((__force req_flags_t)(1 << 6)) | ||
| 100 | /* don't call prep for this one */ | ||
| 101 | #define RQF_DONTPREP ((__force req_flags_t)(1 << 7)) | ||
| 102 | /* set for "ide_preempt" requests and also for requests for which the SCSI | ||
| 103 | "quiesce" state must be ignored. */ | ||
| 104 | #define RQF_PREEMPT ((__force req_flags_t)(1 << 8)) | ||
| 105 | /* contains copies of user pages */ | ||
| 106 | #define RQF_COPY_USER ((__force req_flags_t)(1 << 9)) | ||
| 107 | /* vaguely specified driver internal error. Ignored by the block layer */ | ||
| 108 | #define RQF_FAILED ((__force req_flags_t)(1 << 10)) | ||
| 109 | /* don't warn about errors */ | ||
| 110 | #define RQF_QUIET ((__force req_flags_t)(1 << 11)) | ||
| 111 | /* elevator private data attached */ | ||
| 112 | #define RQF_ELVPRIV ((__force req_flags_t)(1 << 12)) | ||
| 113 | /* account I/O stat */ | ||
| 114 | #define RQF_IO_STAT ((__force req_flags_t)(1 << 13)) | ||
| 115 | /* request came from our alloc pool */ | ||
| 116 | #define RQF_ALLOCED ((__force req_flags_t)(1 << 14)) | ||
| 117 | /* runtime pm request */ | ||
| 118 | #define RQF_PM ((__force req_flags_t)(1 << 15)) | ||
| 119 | /* on IO scheduler merge hash */ | ||
| 120 | #define RQF_HASHED ((__force req_flags_t)(1 << 16)) | ||
| 121 | /* IO stats tracking on */ | ||
| 122 | #define RQF_STATS ((__force req_flags_t)(1 << 17)) | ||
| 123 | /* Look at ->special_vec for the actual data payload instead of the | ||
| 124 | bio chain. */ | ||
| 125 | #define RQF_SPECIAL_PAYLOAD ((__force req_flags_t)(1 << 18)) | ||
| 126 | |||
| 127 | /* flags that prevent us from merging requests: */ | ||
| 128 | #define RQF_NOMERGE_FLAGS \ | ||
| 129 | (RQF_STARTED | RQF_SOFTBARRIER | RQF_FLUSH_SEQ | RQF_SPECIAL_PAYLOAD) | ||
| 130 | |||
| 80 | #define BLK_MAX_CDB 16 | 131 | #define BLK_MAX_CDB 16 |
| 81 | 132 | ||
| 82 | /* | 133 | /* |
| @@ -97,7 +148,8 @@ struct request { | |||
| 97 | 148 | ||
| 98 | int cpu; | 149 | int cpu; |
| 99 | unsigned cmd_type; | 150 | unsigned cmd_type; |
| 100 | u64 cmd_flags; | 151 | unsigned int cmd_flags; /* op and common flags */ |
| 152 | req_flags_t rq_flags; | ||
| 101 | unsigned long atomic_flags; | 153 | unsigned long atomic_flags; |
| 102 | 154 | ||
| 103 | /* the following two fields are internal, NEVER access directly */ | 155 | /* the following two fields are internal, NEVER access directly */ |
| @@ -126,6 +178,7 @@ struct request { | |||
| 126 | */ | 178 | */ |
| 127 | union { | 179 | union { |
| 128 | struct rb_node rb_node; /* sort/lookup */ | 180 | struct rb_node rb_node; /* sort/lookup */ |
| 181 | struct bio_vec special_vec; | ||
| 129 | void *completion_data; | 182 | void *completion_data; |
| 130 | }; | 183 | }; |
| 131 | 184 | ||
| @@ -151,6 +204,7 @@ struct request { | |||
| 151 | struct gendisk *rq_disk; | 204 | struct gendisk *rq_disk; |
| 152 | struct hd_struct *part; | 205 | struct hd_struct *part; |
| 153 | unsigned long start_time; | 206 | unsigned long start_time; |
| 207 | struct blk_issue_stat issue_stat; | ||
| 154 | #ifdef CONFIG_BLK_CGROUP | 208 | #ifdef CONFIG_BLK_CGROUP |
| 155 | struct request_list *rl; /* rl this rq is alloced from */ | 209 | struct request_list *rl; /* rl this rq is alloced from */ |
| 156 | unsigned long long start_time_ns; | 210 | unsigned long long start_time_ns; |
| @@ -198,20 +252,6 @@ struct request { | |||
| 198 | struct request *next_rq; | 252 | struct request *next_rq; |
| 199 | }; | 253 | }; |
| 200 | 254 | ||
| 201 | #define REQ_OP_SHIFT (8 * sizeof(u64) - REQ_OP_BITS) | ||
| 202 | #define req_op(req) ((req)->cmd_flags >> REQ_OP_SHIFT) | ||
| 203 | |||
| 204 | #define req_set_op(req, op) do { \ | ||
| 205 | WARN_ON(op >= (1 << REQ_OP_BITS)); \ | ||
| 206 | (req)->cmd_flags &= ((1ULL << REQ_OP_SHIFT) - 1); \ | ||
| 207 | (req)->cmd_flags |= ((u64) (op) << REQ_OP_SHIFT); \ | ||
| 208 | } while (0) | ||
| 209 | |||
| 210 | #define req_set_op_attrs(req, op, flags) do { \ | ||
| 211 | req_set_op(req, op); \ | ||
| 212 | (req)->cmd_flags |= flags; \ | ||
| 213 | } while (0) | ||
| 214 | |||
| 215 | static inline unsigned short req_get_ioprio(struct request *req) | 255 | static inline unsigned short req_get_ioprio(struct request *req) |
| 216 | { | 256 | { |
| 217 | return req->ioprio; | 257 | return req->ioprio; |
| @@ -248,7 +288,6 @@ enum blk_queue_state { | |||
| 248 | struct blk_queue_tag { | 288 | struct blk_queue_tag { |
| 249 | struct request **tag_index; /* map of busy tags */ | 289 | struct request **tag_index; /* map of busy tags */ |
| 250 | unsigned long *tag_map; /* bit map of free/busy tags */ | 290 | unsigned long *tag_map; /* bit map of free/busy tags */ |
| 251 | int busy; /* current depth */ | ||
| 252 | int max_depth; /* what we will send to device */ | 291 | int max_depth; /* what we will send to device */ |
| 253 | int real_max_depth; /* what the array can hold */ | 292 | int real_max_depth; /* what the array can hold */ |
| 254 | atomic_t refcnt; /* map can be shared */ | 293 | atomic_t refcnt; /* map can be shared */ |
| @@ -261,6 +300,15 @@ struct blk_queue_tag { | |||
| 261 | #define BLK_SCSI_MAX_CMDS (256) | 300 | #define BLK_SCSI_MAX_CMDS (256) |
| 262 | #define BLK_SCSI_CMD_PER_LONG (BLK_SCSI_MAX_CMDS / (sizeof(long) * 8)) | 301 | #define BLK_SCSI_CMD_PER_LONG (BLK_SCSI_MAX_CMDS / (sizeof(long) * 8)) |
| 263 | 302 | ||
| 303 | /* | ||
| 304 | * Zoned block device models (zoned limit). | ||
| 305 | */ | ||
| 306 | enum blk_zoned_model { | ||
| 307 | BLK_ZONED_NONE, /* Regular block device */ | ||
| 308 | BLK_ZONED_HA, /* Host-aware zoned block device */ | ||
| 309 | BLK_ZONED_HM, /* Host-managed zoned block device */ | ||
| 310 | }; | ||
| 311 | |||
| 264 | struct queue_limits { | 312 | struct queue_limits { |
| 265 | unsigned long bounce_pfn; | 313 | unsigned long bounce_pfn; |
| 266 | unsigned long seg_boundary_mask; | 314 | unsigned long seg_boundary_mask; |
| @@ -278,6 +326,7 @@ struct queue_limits { | |||
| 278 | unsigned int max_discard_sectors; | 326 | unsigned int max_discard_sectors; |
| 279 | unsigned int max_hw_discard_sectors; | 327 | unsigned int max_hw_discard_sectors; |
| 280 | unsigned int max_write_same_sectors; | 328 | unsigned int max_write_same_sectors; |
| 329 | unsigned int max_write_zeroes_sectors; | ||
| 281 | unsigned int discard_granularity; | 330 | unsigned int discard_granularity; |
| 282 | unsigned int discard_alignment; | 331 | unsigned int discard_alignment; |
| 283 | 332 | ||
| @@ -290,8 +339,45 @@ struct queue_limits { | |||
| 290 | unsigned char cluster; | 339 | unsigned char cluster; |
| 291 | unsigned char discard_zeroes_data; | 340 | unsigned char discard_zeroes_data; |
| 292 | unsigned char raid_partial_stripes_expensive; | 341 | unsigned char raid_partial_stripes_expensive; |
| 342 | enum blk_zoned_model zoned; | ||
| 293 | }; | 343 | }; |
| 294 | 344 | ||
| 345 | #ifdef CONFIG_BLK_DEV_ZONED | ||
| 346 | |||
| 347 | struct blk_zone_report_hdr { | ||
| 348 | unsigned int nr_zones; | ||
| 349 | u8 padding[60]; | ||
| 350 | }; | ||
| 351 | |||
| 352 | extern int blkdev_report_zones(struct block_device *bdev, | ||
| 353 | sector_t sector, struct blk_zone *zones, | ||
| 354 | unsigned int *nr_zones, gfp_t gfp_mask); | ||
| 355 | extern int blkdev_reset_zones(struct block_device *bdev, sector_t sectors, | ||
| 356 | sector_t nr_sectors, gfp_t gfp_mask); | ||
| 357 | |||
| 358 | extern int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode, | ||
| 359 | unsigned int cmd, unsigned long arg); | ||
| 360 | extern int blkdev_reset_zones_ioctl(struct block_device *bdev, fmode_t mode, | ||
| 361 | unsigned int cmd, unsigned long arg); | ||
| 362 | |||
| 363 | #else /* CONFIG_BLK_DEV_ZONED */ | ||
| 364 | |||
| 365 | static inline int blkdev_report_zones_ioctl(struct block_device *bdev, | ||
| 366 | fmode_t mode, unsigned int cmd, | ||
| 367 | unsigned long arg) | ||
| 368 | { | ||
| 369 | return -ENOTTY; | ||
| 370 | } | ||
| 371 | |||
| 372 | static inline int blkdev_reset_zones_ioctl(struct block_device *bdev, | ||
| 373 | fmode_t mode, unsigned int cmd, | ||
| 374 | unsigned long arg) | ||
| 375 | { | ||
| 376 | return -ENOTTY; | ||
| 377 | } | ||
| 378 | |||
| 379 | #endif /* CONFIG_BLK_DEV_ZONED */ | ||
| 380 | |||
| 295 | struct request_queue { | 381 | struct request_queue { |
| 296 | /* | 382 | /* |
| 297 | * Together with queue_head for cacheline sharing | 383 | * Together with queue_head for cacheline sharing |
| @@ -302,6 +388,8 @@ struct request_queue { | |||
| 302 | int nr_rqs[2]; /* # allocated [a]sync rqs */ | 388 | int nr_rqs[2]; /* # allocated [a]sync rqs */ |
| 303 | int nr_rqs_elvpriv; /* # allocated rqs w/ elvpriv */ | 389 | int nr_rqs_elvpriv; /* # allocated rqs w/ elvpriv */ |
| 304 | 390 | ||
| 391 | struct rq_wb *rq_wb; | ||
| 392 | |||
| 305 | /* | 393 | /* |
| 306 | * If blkcg is not used, @q->root_rl serves all requests. If blkcg | 394 | * If blkcg is not used, @q->root_rl serves all requests. If blkcg |
| 307 | * is used, root blkg allocates from @q->root_rl and all other | 395 | * is used, root blkg allocates from @q->root_rl and all other |
| @@ -327,6 +415,8 @@ struct request_queue { | |||
| 327 | struct blk_mq_ctx __percpu *queue_ctx; | 415 | struct blk_mq_ctx __percpu *queue_ctx; |
| 328 | unsigned int nr_queues; | 416 | unsigned int nr_queues; |
| 329 | 417 | ||
| 418 | unsigned int queue_depth; | ||
| 419 | |||
| 330 | /* hw dispatch queues */ | 420 | /* hw dispatch queues */ |
| 331 | struct blk_mq_hw_ctx **queue_hw_ctx; | 421 | struct blk_mq_hw_ctx **queue_hw_ctx; |
| 332 | unsigned int nr_hw_queues; | 422 | unsigned int nr_hw_queues; |
| @@ -412,6 +502,9 @@ struct request_queue { | |||
| 412 | 502 | ||
| 413 | unsigned int nr_sorted; | 503 | unsigned int nr_sorted; |
| 414 | unsigned int in_flight[2]; | 504 | unsigned int in_flight[2]; |
| 505 | |||
| 506 | struct blk_rq_stat rq_stats[2]; | ||
| 507 | |||
| 415 | /* | 508 | /* |
| 416 | * Number of active block driver functions for which blk_drain_queue() | 509 | * Number of active block driver functions for which blk_drain_queue() |
| 417 | * must wait. Must be incremented around functions that unlock the | 510 | * must wait. Must be incremented around functions that unlock the |
| @@ -420,6 +513,7 @@ struct request_queue { | |||
| 420 | unsigned int request_fn_active; | 513 | unsigned int request_fn_active; |
| 421 | 514 | ||
| 422 | unsigned int rq_timeout; | 515 | unsigned int rq_timeout; |
| 516 | int poll_nsec; | ||
| 423 | struct timer_list timeout; | 517 | struct timer_list timeout; |
| 424 | struct work_struct timeout_work; | 518 | struct work_struct timeout_work; |
| 425 | struct list_head timeout_list; | 519 | struct list_head timeout_list; |
| @@ -505,6 +599,7 @@ struct request_queue { | |||
| 505 | #define QUEUE_FLAG_FUA 24 /* device supports FUA writes */ | 599 | #define QUEUE_FLAG_FUA 24 /* device supports FUA writes */ |
| 506 | #define QUEUE_FLAG_FLUSH_NQ 25 /* flush not queueuable */ | 600 | #define QUEUE_FLAG_FLUSH_NQ 25 /* flush not queueuable */ |
| 507 | #define QUEUE_FLAG_DAX 26 /* device supports DAX */ | 601 | #define QUEUE_FLAG_DAX 26 /* device supports DAX */ |
| 602 | #define QUEUE_FLAG_STATS 27 /* track rq completion times */ | ||
| 508 | 603 | ||
| 509 | #define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ | 604 | #define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ |
| 510 | (1 << QUEUE_FLAG_STACKABLE) | \ | 605 | (1 << QUEUE_FLAG_STACKABLE) | \ |
| @@ -601,7 +696,7 @@ static inline void queue_flag_clear(unsigned int flag, struct request_queue *q) | |||
| 601 | REQ_FAILFAST_DRIVER)) | 696 | REQ_FAILFAST_DRIVER)) |
| 602 | 697 | ||
| 603 | #define blk_account_rq(rq) \ | 698 | #define blk_account_rq(rq) \ |
| 604 | (((rq)->cmd_flags & REQ_STARTED) && \ | 699 | (((rq)->rq_flags & RQF_STARTED) && \ |
| 605 | ((rq)->cmd_type == REQ_TYPE_FS)) | 700 | ((rq)->cmd_type == REQ_TYPE_FS)) |
| 606 | 701 | ||
| 607 | #define blk_rq_cpu_valid(rq) ((rq)->cpu != -1) | 702 | #define blk_rq_cpu_valid(rq) ((rq)->cpu != -1) |
| @@ -627,17 +722,31 @@ static inline unsigned int blk_queue_cluster(struct request_queue *q) | |||
| 627 | return q->limits.cluster; | 722 | return q->limits.cluster; |
| 628 | } | 723 | } |
| 629 | 724 | ||
| 630 | /* | 725 | static inline enum blk_zoned_model |
| 631 | * We regard a request as sync, if either a read or a sync write | 726 | blk_queue_zoned_model(struct request_queue *q) |
| 632 | */ | 727 | { |
| 633 | static inline bool rw_is_sync(int op, unsigned int rw_flags) | 728 | return q->limits.zoned; |
| 729 | } | ||
| 730 | |||
| 731 | static inline bool blk_queue_is_zoned(struct request_queue *q) | ||
| 732 | { | ||
| 733 | switch (blk_queue_zoned_model(q)) { | ||
| 734 | case BLK_ZONED_HA: | ||
| 735 | case BLK_ZONED_HM: | ||
| 736 | return true; | ||
| 737 | default: | ||
| 738 | return false; | ||
| 739 | } | ||
| 740 | } | ||
| 741 | |||
| 742 | static inline unsigned int blk_queue_zone_size(struct request_queue *q) | ||
| 634 | { | 743 | { |
| 635 | return op == REQ_OP_READ || (rw_flags & REQ_SYNC); | 744 | return blk_queue_is_zoned(q) ? q->limits.chunk_sectors : 0; |
| 636 | } | 745 | } |
| 637 | 746 | ||
| 638 | static inline bool rq_is_sync(struct request *rq) | 747 | static inline bool rq_is_sync(struct request *rq) |
| 639 | { | 748 | { |
| 640 | return rw_is_sync(req_op(rq), rq->cmd_flags); | 749 | return op_is_sync(rq->cmd_flags); |
| 641 | } | 750 | } |
| 642 | 751 | ||
| 643 | static inline bool blk_rl_full(struct request_list *rl, bool sync) | 752 | static inline bool blk_rl_full(struct request_list *rl, bool sync) |
| @@ -669,8 +778,13 @@ static inline bool rq_mergeable(struct request *rq) | |||
| 669 | if (req_op(rq) == REQ_OP_FLUSH) | 778 | if (req_op(rq) == REQ_OP_FLUSH) |
| 670 | return false; | 779 | return false; |
| 671 | 780 | ||
| 781 | if (req_op(rq) == REQ_OP_WRITE_ZEROES) | ||
| 782 | return false; | ||
| 783 | |||
| 672 | if (rq->cmd_flags & REQ_NOMERGE_FLAGS) | 784 | if (rq->cmd_flags & REQ_NOMERGE_FLAGS) |
| 673 | return false; | 785 | return false; |
| 786 | if (rq->rq_flags & RQF_NOMERGE_FLAGS) | ||
| 787 | return false; | ||
| 674 | 788 | ||
| 675 | return true; | 789 | return true; |
| 676 | } | 790 | } |
| @@ -683,6 +797,14 @@ static inline bool blk_write_same_mergeable(struct bio *a, struct bio *b) | |||
| 683 | return false; | 797 | return false; |
| 684 | } | 798 | } |
| 685 | 799 | ||
| 800 | static inline unsigned int blk_queue_depth(struct request_queue *q) | ||
| 801 | { | ||
| 802 | if (q->queue_depth) | ||
| 803 | return q->queue_depth; | ||
| 804 | |||
| 805 | return q->nr_requests; | ||
| 806 | } | ||
| 807 | |||
| 686 | /* | 808 | /* |
| 687 | * q->prep_rq_fn return values | 809 | * q->prep_rq_fn return values |
| 688 | */ | 810 | */ |
| @@ -790,8 +912,6 @@ extern void __blk_put_request(struct request_queue *, struct request *); | |||
| 790 | extern struct request *blk_get_request(struct request_queue *, int, gfp_t); | 912 | extern struct request *blk_get_request(struct request_queue *, int, gfp_t); |
| 791 | extern void blk_rq_set_block_pc(struct request *); | 913 | extern void blk_rq_set_block_pc(struct request *); |
| 792 | extern void blk_requeue_request(struct request_queue *, struct request *); | 914 | extern void blk_requeue_request(struct request_queue *, struct request *); |
| 793 | extern void blk_add_request_payload(struct request *rq, struct page *page, | ||
| 794 | int offset, unsigned int len); | ||
| 795 | extern int blk_lld_busy(struct request_queue *q); | 915 | extern int blk_lld_busy(struct request_queue *q); |
| 796 | extern int blk_rq_prep_clone(struct request *rq, struct request *rq_src, | 916 | extern int blk_rq_prep_clone(struct request *rq, struct request *rq_src, |
| 797 | struct bio_set *bs, gfp_t gfp_mask, | 917 | struct bio_set *bs, gfp_t gfp_mask, |
| @@ -824,6 +944,7 @@ extern void __blk_run_queue(struct request_queue *q); | |||
| 824 | extern void __blk_run_queue_uncond(struct request_queue *q); | 944 | extern void __blk_run_queue_uncond(struct request_queue *q); |
| 825 | extern void blk_run_queue(struct request_queue *); | 945 | extern void blk_run_queue(struct request_queue *); |
| 826 | extern void blk_run_queue_async(struct request_queue *q); | 946 | extern void blk_run_queue_async(struct request_queue *q); |
| 947 | extern void blk_mq_quiesce_queue(struct request_queue *q); | ||
| 827 | extern int blk_rq_map_user(struct request_queue *, struct request *, | 948 | extern int blk_rq_map_user(struct request_queue *, struct request *, |
| 828 | struct rq_map_data *, void __user *, unsigned long, | 949 | struct rq_map_data *, void __user *, unsigned long, |
| 829 | gfp_t); | 950 | gfp_t); |
| @@ -837,7 +958,7 @@ extern int blk_execute_rq(struct request_queue *, struct gendisk *, | |||
| 837 | extern void blk_execute_rq_nowait(struct request_queue *, struct gendisk *, | 958 | extern void blk_execute_rq_nowait(struct request_queue *, struct gendisk *, |
| 838 | struct request *, int, rq_end_io_fn *); | 959 | struct request *, int, rq_end_io_fn *); |
| 839 | 960 | ||
| 840 | bool blk_poll(struct request_queue *q, blk_qc_t cookie); | 961 | bool blk_mq_poll(struct request_queue *q, blk_qc_t cookie); |
| 841 | 962 | ||
| 842 | static inline struct request_queue *bdev_get_queue(struct block_device *bdev) | 963 | static inline struct request_queue *bdev_get_queue(struct block_device *bdev) |
| 843 | { | 964 | { |
| @@ -888,6 +1009,9 @@ static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q, | |||
| 888 | if (unlikely(op == REQ_OP_WRITE_SAME)) | 1009 | if (unlikely(op == REQ_OP_WRITE_SAME)) |
| 889 | return q->limits.max_write_same_sectors; | 1010 | return q->limits.max_write_same_sectors; |
| 890 | 1011 | ||
| 1012 | if (unlikely(op == REQ_OP_WRITE_ZEROES)) | ||
| 1013 | return q->limits.max_write_zeroes_sectors; | ||
| 1014 | |||
| 891 | return q->limits.max_sectors; | 1015 | return q->limits.max_sectors; |
| 892 | } | 1016 | } |
| 893 | 1017 | ||
| @@ -934,6 +1058,20 @@ static inline unsigned int blk_rq_count_bios(struct request *rq) | |||
| 934 | } | 1058 | } |
| 935 | 1059 | ||
| 936 | /* | 1060 | /* |
| 1061 | * blk_rq_set_prio - associate a request with prio from ioc | ||
| 1062 | * @rq: request of interest | ||
| 1063 | * @ioc: target iocontext | ||
| 1064 | * | ||
| 1065 | * Assocate request prio with ioc prio so request based drivers | ||
| 1066 | * can leverage priority information. | ||
| 1067 | */ | ||
| 1068 | static inline void blk_rq_set_prio(struct request *rq, struct io_context *ioc) | ||
| 1069 | { | ||
| 1070 | if (ioc) | ||
| 1071 | rq->ioprio = ioc->ioprio; | ||
| 1072 | } | ||
| 1073 | |||
| 1074 | /* | ||
| 937 | * Request issue related functions. | 1075 | * Request issue related functions. |
| 938 | */ | 1076 | */ |
| 939 | extern struct request *blk_peek_request(struct request_queue *q); | 1077 | extern struct request *blk_peek_request(struct request_queue *q); |
| @@ -991,6 +1129,8 @@ extern void blk_queue_max_discard_sectors(struct request_queue *q, | |||
| 991 | unsigned int max_discard_sectors); | 1129 | unsigned int max_discard_sectors); |
| 992 | extern void blk_queue_max_write_same_sectors(struct request_queue *q, | 1130 | extern void blk_queue_max_write_same_sectors(struct request_queue *q, |
| 993 | unsigned int max_write_same_sectors); | 1131 | unsigned int max_write_same_sectors); |
| 1132 | extern void blk_queue_max_write_zeroes_sectors(struct request_queue *q, | ||
| 1133 | unsigned int max_write_same_sectors); | ||
| 994 | extern void blk_queue_logical_block_size(struct request_queue *, unsigned short); | 1134 | extern void blk_queue_logical_block_size(struct request_queue *, unsigned short); |
| 995 | extern void blk_queue_physical_block_size(struct request_queue *, unsigned int); | 1135 | extern void blk_queue_physical_block_size(struct request_queue *, unsigned int); |
| 996 | extern void blk_queue_alignment_offset(struct request_queue *q, | 1136 | extern void blk_queue_alignment_offset(struct request_queue *q, |
| @@ -999,6 +1139,7 @@ extern void blk_limits_io_min(struct queue_limits *limits, unsigned int min); | |||
| 999 | extern void blk_queue_io_min(struct request_queue *q, unsigned int min); | 1139 | extern void blk_queue_io_min(struct request_queue *q, unsigned int min); |
| 1000 | extern void blk_limits_io_opt(struct queue_limits *limits, unsigned int opt); | 1140 | extern void blk_limits_io_opt(struct queue_limits *limits, unsigned int opt); |
| 1001 | extern void blk_queue_io_opt(struct request_queue *q, unsigned int opt); | 1141 | extern void blk_queue_io_opt(struct request_queue *q, unsigned int opt); |
| 1142 | extern void blk_set_queue_depth(struct request_queue *q, unsigned int depth); | ||
| 1002 | extern void blk_set_default_limits(struct queue_limits *lim); | 1143 | extern void blk_set_default_limits(struct queue_limits *lim); |
| 1003 | extern void blk_set_stacking_limits(struct queue_limits *lim); | 1144 | extern void blk_set_stacking_limits(struct queue_limits *lim); |
| 1004 | extern int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, | 1145 | extern int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, |
| @@ -1027,6 +1168,13 @@ extern void blk_queue_flush_queueable(struct request_queue *q, bool queueable); | |||
| 1027 | extern void blk_queue_write_cache(struct request_queue *q, bool enabled, bool fua); | 1168 | extern void blk_queue_write_cache(struct request_queue *q, bool enabled, bool fua); |
| 1028 | extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev); | 1169 | extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev); |
| 1029 | 1170 | ||
| 1171 | static inline unsigned short blk_rq_nr_phys_segments(struct request *rq) | ||
| 1172 | { | ||
| 1173 | if (rq->rq_flags & RQF_SPECIAL_PAYLOAD) | ||
| 1174 | return 1; | ||
| 1175 | return rq->nr_phys_segments; | ||
| 1176 | } | ||
| 1177 | |||
| 1030 | extern int blk_rq_map_sg(struct request_queue *, struct request *, struct scatterlist *); | 1178 | extern int blk_rq_map_sg(struct request_queue *, struct request *, struct scatterlist *); |
| 1031 | extern void blk_dump_rq_flags(struct request *, char *); | 1179 | extern void blk_dump_rq_flags(struct request *, char *); |
| 1032 | extern long nr_blockdev_pages(void); | 1180 | extern long nr_blockdev_pages(void); |
| @@ -1057,7 +1205,7 @@ static inline int blk_pre_runtime_suspend(struct request_queue *q) | |||
| 1057 | static inline void blk_post_runtime_suspend(struct request_queue *q, int err) {} | 1205 | static inline void blk_post_runtime_suspend(struct request_queue *q, int err) {} |
| 1058 | static inline void blk_pre_runtime_resume(struct request_queue *q) {} | 1206 | static inline void blk_pre_runtime_resume(struct request_queue *q) {} |
| 1059 | static inline void blk_post_runtime_resume(struct request_queue *q, int err) {} | 1207 | static inline void blk_post_runtime_resume(struct request_queue *q, int err) {} |
| 1060 | extern inline void blk_set_runtime_active(struct request_queue *q) {} | 1208 | static inline void blk_set_runtime_active(struct request_queue *q) {} |
| 1061 | #endif | 1209 | #endif |
| 1062 | 1210 | ||
| 1063 | /* | 1211 | /* |
| @@ -1078,6 +1226,7 @@ struct blk_plug { | |||
| 1078 | struct list_head cb_list; /* md requires an unplug callback */ | 1226 | struct list_head cb_list; /* md requires an unplug callback */ |
| 1079 | }; | 1227 | }; |
| 1080 | #define BLK_MAX_REQUEST_COUNT 16 | 1228 | #define BLK_MAX_REQUEST_COUNT 16 |
| 1229 | #define BLK_PLUG_FLUSH_SIZE (128 * 1024) | ||
| 1081 | 1230 | ||
| 1082 | struct blk_plug_cb; | 1231 | struct blk_plug_cb; |
| 1083 | typedef void (*blk_plug_cb_fn)(struct blk_plug_cb *, bool); | 1232 | typedef void (*blk_plug_cb_fn)(struct blk_plug_cb *, bool); |
| @@ -1151,6 +1300,9 @@ extern int __blkdev_issue_discard(struct block_device *bdev, sector_t sector, | |||
| 1151 | struct bio **biop); | 1300 | struct bio **biop); |
| 1152 | extern int blkdev_issue_write_same(struct block_device *bdev, sector_t sector, | 1301 | extern int blkdev_issue_write_same(struct block_device *bdev, sector_t sector, |
| 1153 | sector_t nr_sects, gfp_t gfp_mask, struct page *page); | 1302 | sector_t nr_sects, gfp_t gfp_mask, struct page *page); |
| 1303 | extern int __blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, | ||
| 1304 | sector_t nr_sects, gfp_t gfp_mask, struct bio **biop, | ||
| 1305 | bool discard); | ||
| 1154 | extern int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, | 1306 | extern int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, |
| 1155 | sector_t nr_sects, gfp_t gfp_mask, bool discard); | 1307 | sector_t nr_sects, gfp_t gfp_mask, bool discard); |
| 1156 | static inline int sb_issue_discard(struct super_block *sb, sector_t block, | 1308 | static inline int sb_issue_discard(struct super_block *sb, sector_t block, |
| @@ -1354,6 +1506,46 @@ static inline unsigned int bdev_write_same(struct block_device *bdev) | |||
| 1354 | return 0; | 1506 | return 0; |
| 1355 | } | 1507 | } |
| 1356 | 1508 | ||
| 1509 | static inline unsigned int bdev_write_zeroes_sectors(struct block_device *bdev) | ||
| 1510 | { | ||
| 1511 | struct request_queue *q = bdev_get_queue(bdev); | ||
| 1512 | |||
| 1513 | if (q) | ||
| 1514 | return q->limits.max_write_zeroes_sectors; | ||
| 1515 | |||
| 1516 | return 0; | ||
| 1517 | } | ||
| 1518 | |||
| 1519 | static inline enum blk_zoned_model bdev_zoned_model(struct block_device *bdev) | ||
| 1520 | { | ||
| 1521 | struct request_queue *q = bdev_get_queue(bdev); | ||
| 1522 | |||
| 1523 | if (q) | ||
| 1524 | return blk_queue_zoned_model(q); | ||
| 1525 | |||
| 1526 | return BLK_ZONED_NONE; | ||
| 1527 | } | ||
| 1528 | |||
| 1529 | static inline bool bdev_is_zoned(struct block_device *bdev) | ||
| 1530 | { | ||
| 1531 | struct request_queue *q = bdev_get_queue(bdev); | ||
| 1532 | |||
| 1533 | if (q) | ||
| 1534 | return blk_queue_is_zoned(q); | ||
| 1535 | |||
| 1536 | return false; | ||
| 1537 | } | ||
| 1538 | |||
| 1539 | static inline unsigned int bdev_zone_size(struct block_device *bdev) | ||
| 1540 | { | ||
| 1541 | struct request_queue *q = bdev_get_queue(bdev); | ||
| 1542 | |||
| 1543 | if (q) | ||
| 1544 | return blk_queue_zone_size(q); | ||
| 1545 | |||
| 1546 | return 0; | ||
| 1547 | } | ||
| 1548 | |||
| 1357 | static inline int queue_dma_alignment(struct request_queue *q) | 1549 | static inline int queue_dma_alignment(struct request_queue *q) |
| 1358 | { | 1550 | { |
| 1359 | return q ? q->dma_alignment : 511; | 1551 | return q ? q->dma_alignment : 511; |
