History

Merge tag 'for-5.5/block-20191121' of git://git.kernel.dk/linux-block

Pull core block updates from Jens Axboe: "Due to more granular branches, this one is small and will be followed with other core branches that add specific features. I meant to just have a core and drivers branch, but external dependencies we ended up adding a few more that are also core. The changes are: - Fixes and improvements for the zoned device support (Ajay, Damien) - sed-opal table writing and datastore UID (Revanth) - blk-cgroup (and bfq) blk-cgroup stat fixes (Tejun) - Improvements to the block stats tracking (Pavel) - Fix for overruning sysfs buffer for large number of CPUs (Ming) - Optimization for small IO (Ming, Christoph) - Fix typo in RWH lifetime hint (Eugene) - Dead code removal and documentation (Bart) - Reduction in memory usage for queue and tag set (Bart) - Kerneldoc header documentation (André) - Device/partition revalidation fixes (Jan) - Stats tracking for flush requests (Konstantin) - Various other little fixes here and there (et al)" * tag 'for-5.5/block-20191121' of git://git.kernel.dk/linux-block: (48 commits) Revert "block: split bio if the only bvec's length is > SZ_4K" block: add iostat counters for flush requests block,bfq: Skip tracing hooks if possible block: sed-opal: Introduce SUM_SET_LIST parameter and append it using 'add_token_u64' blk-cgroup: cgroup_rstat_updated() shouldn't be called on cgroup1 block: Don't disable interrupts in trigger_softirq() sbitmap: Delete sbitmap_any_bit_clear() blk-mq: Delete blk_mq_has_free_tags() and blk_mq_can_queue() block: split bio if the only bvec's length is > SZ_4K block: still try to split bio if the bvec crosses pages blk-cgroup: separate out blkg_rwstat under CONFIG_BLK_CGROUP_RWSTAT blk-cgroup: reimplement basic IO stats using cgroup rstat blk-cgroup: remove now unused blkg_print_stat_{bytes|ios}_recursive() blk-throtl: stop using blkg->stat_bytes and ->stat_ios bfq-iosched: stop using blkg->stat_bytes and ->stat_ios bfq-iosched: relocate bfqg_*rwstat*() helpers block: add zone open, close and finish ioctl support block: add zone open, close and finish operations block: Simplify REQ_OP_ZONE_RESET_ALL handling block: Remove REQ_OP_ZONE_RESET plugging ...

Linus Torvalds committed 6 years ago

Commit ff6814b2 parents 6e7b06a 1e2791551 files · +1398 −800Browse files

Showing the changes to include/linux (6 of 51 files). Show all

Unified · Split

6 files
  1. include/linux/blk-cgroup.h +37 −162
  2. include/linux/blk-mq.h +246 −54
  3. include/linux/blk_types.h +27 −1
  4. include/linux/blkdev.h +8 −8
  5. include/linux/sbitmap.h +0 −9
  6. include/linux/sed-opal.h +1 −0
include/linux/blk-cgroup.h+37−162
@@ -15,7 +15,9 @@ · 14 unmodified lines
1515 */
1616
1717 #include <linux/cgroup.h>
18+#include <linux/percpu.h>
1819 #include <linux/percpu_counter.h>
20+#include <linux/u64_stats_sync.h>
1921 #include <linux/seq_file.h>
2022 #include <linux/radix-tree.h>
2123 #include <linux/blkdev.h>
@@ -31,15 +33,12 @@ · 9 unmodified lines
3133
3234 #ifdef CONFIG_BLK_CGROUP
3335
34−enum blkg_rwstat_type {
35− BLKG_RWSTAT_READ,
36− BLKG_RWSTAT_WRITE,
37− BLKG_RWSTAT_SYNC,
38− BLKG_RWSTAT_ASYNC,
39− BLKG_RWSTAT_DISCARD,
36+enum blkg_iostat_type {
37+ BLKG_IOSTAT_READ,
38+ BLKG_IOSTAT_WRITE,
39+ BLKG_IOSTAT_DISCARD,
4040
41− BLKG_RWSTAT_NR,
42− BLKG_RWSTAT_TOTAL = BLKG_RWSTAT_NR,
41+ BLKG_IOSTAT_NR,
4342 };
4443
4544 struct blkcg_gq;
@@ -61,17 +60,15 @@ struct blkcg { · 15 unmodified lines
6160 #endif
6261 };
6362
64−/*
65− * blkg_[rw]stat->aux_cnt is excluded for local stats but included for
66− * recursive. Used to carry stats of dead children.
67− */
68−struct blkg_rwstat {
69− struct percpu_counter cpu_cnt[BLKG_RWSTAT_NR];
70− atomic64_t aux_cnt[BLKG_RWSTAT_NR];
63+struct blkg_iostat {
64+ u64 bytes[BLKG_IOSTAT_NR];
65+ u64 ios[BLKG_IOSTAT_NR];
7166 };
7267
73−struct blkg_rwstat_sample {
74− u64 cnt[BLKG_RWSTAT_NR];
68+struct blkg_iostat_set {
69+ struct u64_stats_sync sync;
70+ struct blkg_iostat cur;
71+ struct blkg_iostat last;
7572 };
7673
7774 /*
@@ -127,8 +124,8 @@ struct blkcg_gq { · 49 unmodified lines
127124 /* is this blkg online? protected by both blkcg and q locks */
128125 bool online;
129126
130− struct blkg_rwstat stat_bytes;
131− struct blkg_rwstat stat_ios;
127+ struct blkg_iostat_set __percpu *iostat_cpu;
128+ struct blkg_iostat_set iostat;
132129
133130 struct blkg_policy_data *pd[BLKCG_MAX_POLS];
134131
@@ -202,13 +199,6 @@ int blkcg_activate_policy(struct request_queue *q, · 67 unmodified lines
202199 void blkcg_deactivate_policy(struct request_queue *q,
203200 const struct blkcg_policy *pol);
204201
205−static inline u64 blkg_rwstat_read_counter(struct blkg_rwstat *rwstat,
206− unsigned int idx)
207−{
208− return atomic64_read(&rwstat->aux_cnt[idx]) +
209− percpu_counter_sum_positive(&rwstat->cpu_cnt[idx]);
210−}
211−
212202 const char *blkg_dev_name(struct blkcg_gq *blkg);
213203 void blkcg_print_blkgs(struct seq_file *sf, struct blkcg *blkcg,
214204 u64 (*prfill)(struct seq_file *,
@@ -216,17 +206,6 @@ void blkcg_print_blkgs(struct seq_file *sf, struct blkcg *blkcg, · 1 unmodified line
216206 const struct blkcg_policy *pol, int data,
217207 bool show_total);
218208 u64 __blkg_prfill_u64(struct seq_file *sf, struct blkg_policy_data *pd, u64 v);
219−u64 __blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd,
220− const struct blkg_rwstat_sample *rwstat);
221−u64 blkg_prfill_rwstat(struct seq_file *sf, struct blkg_policy_data *pd,
222− int off);
223−int blkg_print_stat_bytes(struct seq_file *sf, void *v);
224−int blkg_print_stat_ios(struct seq_file *sf, void *v);
225−int blkg_print_stat_bytes_recursive(struct seq_file *sf, void *v);
226−int blkg_print_stat_ios_recursive(struct seq_file *sf, void *v);
227−
228−void blkg_rwstat_recursive_sum(struct blkcg_gq *blkg, struct blkcg_policy *pol,
229− int off, struct blkg_rwstat_sample *sum);
230209
231210 struct blkg_conf_ctx {
232211 struct gendisk *disk;
@@ -578,128 +557,6 @@ static inline void blkg_put(struct blkcg_gq *blkg) · 345 unmodified lines
578557 if (((d_blkg) = __blkg_lookup(css_to_blkcg(pos_css), \
579558 (p_blkg)->q, false)))
580559
581−static inline int blkg_rwstat_init(struct blkg_rwstat *rwstat, gfp_t gfp)
582−{
583− int i, ret;
584−
585− for (i = 0; i < BLKG_RWSTAT_NR; i++) {
586− ret = percpu_counter_init(&rwstat->cpu_cnt[i], 0, gfp);
587− if (ret) {
588− while (--i >= 0)
589− percpu_counter_destroy(&rwstat->cpu_cnt[i]);
590− return ret;
591− }
592− atomic64_set(&rwstat->aux_cnt[i], 0);
593− }
594− return 0;
595−}
596−
597−static inline void blkg_rwstat_exit(struct blkg_rwstat *rwstat)
598−{
599− int i;
600−
601− for (i = 0; i < BLKG_RWSTAT_NR; i++)
602− percpu_counter_destroy(&rwstat->cpu_cnt[i]);
603−}
604−
605−/**
606− * blkg_rwstat_add - add a value to a blkg_rwstat
607− * @rwstat: target blkg_rwstat
608− * @op: REQ_OP and flags
609− * @val: value to add
610− *
611− * Add @val to @rwstat. The counters are chosen according to @rw. The
612− * caller is responsible for synchronizing calls to this function.
613− */
614−static inline void blkg_rwstat_add(struct blkg_rwstat *rwstat,
615− unsigned int op, uint64_t val)
616−{
617− struct percpu_counter *cnt;
618−
619− if (op_is_discard(op))
620− cnt = &rwstat->cpu_cnt[BLKG_RWSTAT_DISCARD];
621− else if (op_is_write(op))
622− cnt = &rwstat->cpu_cnt[BLKG_RWSTAT_WRITE];
623− else
624− cnt = &rwstat->cpu_cnt[BLKG_RWSTAT_READ];
625−
626− percpu_counter_add_batch(cnt, val, BLKG_STAT_CPU_BATCH);
627−
628− if (op_is_sync(op))
629− cnt = &rwstat->cpu_cnt[BLKG_RWSTAT_SYNC];
630− else
631− cnt = &rwstat->cpu_cnt[BLKG_RWSTAT_ASYNC];
632−
633− percpu_counter_add_batch(cnt, val, BLKG_STAT_CPU_BATCH);
634−}
635−
636−/**
637− * blkg_rwstat_read - read the current values of a blkg_rwstat
638− * @rwstat: blkg_rwstat to read
639− *
640− * Read the current snapshot of @rwstat and return it in the aux counts.
641− */
642−static inline void blkg_rwstat_read(struct blkg_rwstat *rwstat,
643− struct blkg_rwstat_sample *result)
644−{
645− int i;
646−
647− for (i = 0; i < BLKG_RWSTAT_NR; i++)
648− result->cnt[i] =
649− percpu_counter_sum_positive(&rwstat->cpu_cnt[i]);
650−}
651−
652−/**
653− * blkg_rwstat_total - read the total count of a blkg_rwstat
654− * @rwstat: blkg_rwstat to read
655− *
656− * Return the total count of @rwstat regardless of the IO direction. This
657− * function can be called without synchronization and takes care of u64
658− * atomicity.
659− */
660−static inline uint64_t blkg_rwstat_total(struct blkg_rwstat *rwstat)
661−{
662− struct blkg_rwstat_sample tmp = { };
663−
664− blkg_rwstat_read(rwstat, &tmp);
665− return tmp.cnt[BLKG_RWSTAT_READ] + tmp.cnt[BLKG_RWSTAT_WRITE];
666−}
667−
668−/**
669− * blkg_rwstat_reset - reset a blkg_rwstat
670− * @rwstat: blkg_rwstat to reset
671− */
672−static inline void blkg_rwstat_reset(struct blkg_rwstat *rwstat)
673−{
674− int i;
675−
676− for (i = 0; i < BLKG_RWSTAT_NR; i++) {
677− percpu_counter_set(&rwstat->cpu_cnt[i], 0);
678− atomic64_set(&rwstat->aux_cnt[i], 0);
679− }
680−}
681−
682−/**
683− * blkg_rwstat_add_aux - add a blkg_rwstat into another's aux count
684− * @to: the destination blkg_rwstat
685− * @from: the source
686− *
687− * Add @from's count including the aux one to @to's aux count.
688− */
689−static inline void blkg_rwstat_add_aux(struct blkg_rwstat *to,
690− struct blkg_rwstat *from)
691−{
692− u64 sum[BLKG_RWSTAT_NR];
693− int i;
694−
695− for (i = 0; i < BLKG_RWSTAT_NR; i++)
696− sum[i] = percpu_counter_sum_positive(&from->cpu_cnt[i]);
697−
698− for (i = 0; i < BLKG_RWSTAT_NR; i++)
699− atomic64_add(sum[i] + atomic64_read(&from->aux_cnt[i]),
700− &to->aux_cnt[i]);
701−}
702−
703560 #ifdef CONFIG_BLK_DEV_THROTTLING
704561 extern bool blk_throtl_bio(struct request_queue *q, struct blkcg_gq *blkg,
705562 struct bio *bio);
@@ -745,15 +602,33 @@ static inline bool blkcg_bio_issue_check(struct request_queue *q, · 39 unmodified lines
745602 throtl = blk_throtl_bio(q, blkg, bio);
746603
747604 if (!throtl) {
605+ struct blkg_iostat_set *bis;
606+ int rwd, cpu;
607+
608+ if (op_is_discard(bio->bi_opf))
609+ rwd = BLKG_IOSTAT_DISCARD;
610+ else if (op_is_write(bio->bi_opf))
611+ rwd = BLKG_IOSTAT_WRITE;
612+ else
613+ rwd = BLKG_IOSTAT_READ;
614+
615+ cpu = get_cpu();
616+ bis = per_cpu_ptr(blkg->iostat_cpu, cpu);
617+ u64_stats_update_begin(&bis->sync);
618+
748619 /*
749620 * If the bio is flagged with BIO_QUEUE_ENTERED it means this
750621 * is a split bio and we would have already accounted for the
751622 * size of the bio.
752623 */
753624 if (!bio_flagged(bio, BIO_QUEUE_ENTERED))
754− blkg_rwstat_add(&blkg->stat_bytes, bio->bi_opf,
755− bio->bi_iter.bi_size);
756− blkg_rwstat_add(&blkg->stat_ios, bio->bi_opf, 1);
625+ bis->cur.bytes[rwd] += bio->bi_iter.bi_size;
626+ bis->cur.ios[rwd]++;
627+
628+ u64_stats_update_end(&bis->sync);
629+ if (cgroup_subsys_on_dfl(io_cgrp_subsys))
630+ cgroup_rstat_updated(blkg->blkcg->css.cgroup, cpu);
631+ put_cpu();
757632 }
758633
759634 blkcg_bio_issue_init(bio);
include/linux/blk-mq.h+246−54
@@ -10,103 +10,239 @@ struct blk_mq_tags; · 9 unmodified lines
1010 struct blk_flush_queue;
1111
1212 /**
13− * struct blk_mq_hw_ctx - State for a hardware queue facing the hardware block device
13+ * struct blk_mq_hw_ctx - State for a hardware queue facing the hardware
14+ * block device
1415 */
1516 struct blk_mq_hw_ctx {
1617 struct {
18+ /** @lock: Protects the dispatch list. */
1719 spinlock_t lock;
20+ /**
21+ * @dispatch: Used for requests that are ready to be
22+ * dispatched to the hardware but for some reason (e.g. lack of
23+ * resources) could not be sent to the hardware. As soon as the
24+ * driver can send new requests, requests at this list will
25+ * be sent first for a fairer dispatch.
26+ */
1827 struct list_head dispatch;
19− unsigned long state; /* BLK_MQ_S_* flags */
28+ /**
29+ * @state: BLK_MQ_S_* flags. Defines the state of the hw
30+ * queue (active, scheduled to restart, stopped).
31+ */
32+ unsigned long state;
2033 } ____cacheline_aligned_in_smp;
2134
35+ /**
36+ * @run_work: Used for scheduling a hardware queue run at a later time.
37+ */
2238 struct delayed_work run_work;
39+ /** @cpumask: Map of available CPUs where this hctx can run. */
2340 cpumask_var_t cpumask;
41+ /**
42+ * @next_cpu: Used by blk_mq_hctx_next_cpu() for round-robin CPU
43+ * selection from @cpumask.
44+ */
2445 int next_cpu;
46+ /**
47+ * @next_cpu_batch: Counter of how many works left in the batch before
48+ * changing to the next CPU.
49+ */
2550 int next_cpu_batch;
2651
27− unsigned long flags; /* BLK_MQ_F_* flags */
52+ /** @flags: BLK_MQ_F_* flags. Defines the behaviour of the queue. */
53+ unsigned long flags;
2854
55+ /**
56+ * @sched_data: Pointer owned by the IO scheduler attached to a request
57+ * queue. It's up to the IO scheduler how to use this pointer.
58+ */
2959 void *sched_data;
60+ /**
61+ * @queue: Pointer to the request queue that owns this hardware context.
62+ */
3063 struct request_queue *queue;
64+ /** @fq: Queue of requests that need to perform a flush operation. */
3165 struct blk_flush_queue *fq;
3266
67+ /**
68+ * @driver_data: Pointer to data owned by the block driver that created
69+ * this hctx
70+ */
3371 void *driver_data;
3472
73+ /**
74+ * @ctx_map: Bitmap for each software queue. If bit is on, there is a
75+ * pending request in that software queue.
76+ */
3577 struct sbitmap ctx_map;
3678
79+ /**
80+ * @dispatch_from: Software queue to be used when no scheduler was
81+ * selected.
82+ */
3783 struct blk_mq_ctx *dispatch_from;
84+ /**
85+ * @dispatch_busy: Number used by blk_mq_update_dispatch_busy() to
86+ * decide if the hw_queue is busy using Exponential Weighted Moving
87+ * Average algorithm.
88+ */
3889 unsigned int dispatch_busy;
3990
91+ /** @type: HCTX_TYPE_* flags. Type of hardware queue. */
4092 unsigned short type;
93+ /** @nr_ctx: Number of software queues. */
4194 unsigned short nr_ctx;
95+ /** @ctxs: Array of software queues. */
4296 struct blk_mq_ctx **ctxs;
4397
98+ /** @dispatch_wait_lock: Lock for dispatch_wait queue. */
4499 spinlock_t dispatch_wait_lock;
100+ /**
101+ * @dispatch_wait: Waitqueue to put requests when there is no tag
102+ * available at the moment, to wait for another try in the future.
103+ */
45104 wait_queue_entry_t dispatch_wait;
105+
106+ /**
107+ * @wait_index: Index of next available dispatch_wait queue to insert
108+ * requests.
109+ */
46110 atomic_t wait_index;
47111
112+ /**
113+ * @tags: Tags owned by the block driver. A tag at this set is only
114+ * assigned when a request is dispatched from a hardware queue.
115+ */
48116 struct blk_mq_tags *tags;
117+ /**
118+ * @sched_tags: Tags owned by I/O scheduler. If there is an I/O
119+ * scheduler associated with a request queue, a tag is assigned when
120+ * that request is allocated. Else, this member is not used.
121+ */
49122 struct blk_mq_tags *sched_tags;
50123
124+ /** @queued: Number of queued requests. */
51125 unsigned long queued;
126+ /** @run: Number of dispatched requests. */
52127 unsigned long run;
53128 #define BLK_MQ_MAX_DISPATCH_ORDER 7
129+ /** @dispatched: Number of dispatch requests by queue. */
54130 unsigned long dispatched[BLK_MQ_MAX_DISPATCH_ORDER];
55131
132+ /** @numa_node: NUMA node the storage adapter has been connected to. */
56133 unsigned int numa_node;
134+ /** @queue_num: Index of this hardware queue. */
57135 unsigned int queue_num;
58136
137+ /**
138+ * @nr_active: Number of active requests. Only used when a tag set is
139+ * shared across request queues.
140+ */
59141 atomic_t nr_active;
60142
143+ /** @cpuhp_dead: List to store request if some CPU die. */
61144 struct hlist_node cpuhp_dead;
145+ /** @kobj: Kernel object for sysfs. */
62146 struct kobject kobj;
63147
148+ /** @poll_considered: Count times blk_poll() was called. */
64149 unsigned long poll_considered;
150+ /** @poll_invoked: Count how many requests blk_poll() polled. */
65151 unsigned long poll_invoked;
152+ /** @poll_success: Count how many polled requests were completed. */
66153 unsigned long poll_success;
67154
68155 #ifdef CONFIG_BLK_DEBUG_FS
156+ /**
157+ * @debugfs_dir: debugfs directory for this hardware queue. Named
158+ * as cpu<cpu_number>.
159+ */
69160 struct dentry *debugfs_dir;
161+ /** @sched_debugfs_dir: debugfs directory for the scheduler. */
70162 struct dentry *sched_debugfs_dir;
71163 #endif
72164
165+ /** @hctx_list: List of all hardware queues. */
73166 struct list_head hctx_list;
74167
75− /* Must be the last member - see also blk_mq_hw_ctx_size(). */
168+ /**
169+ * @srcu: Sleepable RCU. Use as lock when type of the hardware queue is
170+ * blocking (BLK_MQ_F_BLOCKING). Must be the last member - see also
171+ * blk_mq_hw_ctx_size().
172+ */
76173 struct srcu_struct srcu[0];
77174 };
78175
176+/**
177+ * struct blk_mq_queue_map - Map software queues to hardware queues
178+ * @mq_map: CPU ID to hardware queue index map. This is an array
179+ * with nr_cpu_ids elements. Each element has a value in the range
180+ * [@queue_offset, @queue_offset + @nr_queues).
181+ * @nr_queues: Number of hardware queues to map CPU IDs onto.
182+ * @queue_offset: First hardware queue to map onto. Used by the PCIe NVMe
183+ * driver to map each hardware queue type (enum hctx_type) onto a distinct
184+ * set of hardware queues.
185+ */
79186 struct blk_mq_queue_map {
80187 unsigned int *mq_map;
81188 unsigned int nr_queues;
82189 unsigned int queue_offset;
83190 };
84191
192+/**
193+ * enum hctx_type - Type of hardware queue
194+ * @HCTX_TYPE_DEFAULT: All I/O not otherwise accounted for.
195+ * @HCTX_TYPE_READ: Just for READ I/O.
196+ * @HCTX_TYPE_POLL: Polled I/O of any kind.
197+ * @HCTX_MAX_TYPES: Number of types of hctx.
198+ */
85199 enum hctx_type {
86− HCTX_TYPE_DEFAULT, /* all I/O not otherwise accounted for */
87− HCTX_TYPE_READ, /* just for READ I/O */
88− HCTX_TYPE_POLL, /* polled I/O of any kind */
200+ HCTX_TYPE_DEFAULT,
201+ HCTX_TYPE_READ,
202+ HCTX_TYPE_POLL,
89203
90204 HCTX_MAX_TYPES,
91205 };
92206
207+/**
208+ * struct blk_mq_tag_set - tag set that can be shared between request queues
209+ * @map: One or more ctx -> hctx mappings. One map exists for each
210+ * hardware queue type (enum hctx_type) that the driver wishes
211+ * to support. There are no restrictions on maps being of the
212+ * same size, and it's perfectly legal to share maps between
213+ * types.
214+ * @nr_maps: Number of elements in the @map array. A number in the range
215+ * [1, HCTX_MAX_TYPES].
216+ * @ops: Pointers to functions that implement block driver behavior.
217+ * @nr_hw_queues: Number of hardware queues supported by the block driver that
218+ * owns this data structure.
219+ * @queue_depth: Number of tags per hardware queue, reserved tags included.
220+ * @reserved_tags: Number of tags to set aside for BLK_MQ_REQ_RESERVED tag
221+ * allocations.
222+ * @cmd_size: Number of additional bytes to allocate per request. The block
223+ * driver owns these additional bytes.
224+ * @numa_node: NUMA node the storage adapter has been connected to.
225+ * @timeout: Request processing timeout in jiffies.
226+ * @flags: Zero or more BLK_MQ_F_* flags.
227+ * @driver_data: Pointer to data owned by the block driver that created this
228+ * tag set.
229+ * @tags: Tag sets. One tag set per hardware queue. Has @nr_hw_queues
230+ * elements.
231+ * @tag_list_lock: Serializes tag_list accesses.
232+ * @tag_list: List of the request queues that use this tag set. See also
233+ * request_queue.tag_set_list.
234+ */
93235 struct blk_mq_tag_set {
94− /*
95− * map[] holds ctx -> hctx mappings, one map exists for each type
96− * that the driver wishes to support. There are no restrictions
97− * on maps being of the same size, and it's perfectly legal to
98− * share maps between types.
99− */
100236 struct blk_mq_queue_map map[HCTX_MAX_TYPES];
101− unsigned int nr_maps; /* nr entries in map[] */
237+ unsigned int nr_maps;
102238 const struct blk_mq_ops *ops;
103− unsigned int nr_hw_queues; /* nr hw queues across maps */
104− unsigned int queue_depth; /* max hw supported */
239+ unsigned int nr_hw_queues;
240+ unsigned int queue_depth;
105241 unsigned int reserved_tags;
106− unsigned int cmd_size; /* per-request extra data */
242+ unsigned int cmd_size;
107243 int numa_node;
108244 unsigned int timeout;
109− unsigned int flags; /* BLK_MQ_F_* */
245+ unsigned int flags;
110246 void *driver_data;
111247
112248 struct blk_mq_tags **tags;
@@ -115,6 +251,12 @@ struct blk_mq_tag_set { · 2 unmodified lines
115251 struct list_head tag_list;
116252 };
117253
254+/**
255+ * struct blk_mq_queue_data - Data about a request inserted in a queue
256+ *
257+ * @rq: Request pointer.
258+ * @last: If it is the last request in the queue.
259+ */
118260 struct blk_mq_queue_data {
119261 struct request *rq;
120262 bool last;
@@ -142,81 +284,101 @@ typedef bool (busy_fn)(struct request_queue *); · 21 unmodified lines
142284 typedef void (complete_fn)(struct request *);
143285 typedef void (cleanup_rq_fn)(struct request *);
144286
145−
287+/**
288+ * struct blk_mq_ops - Callback functions that implements block driver
289+ * behaviour.
290+ */
146291 struct blk_mq_ops {
147− /*
148− * Queue request
292+ /**
293+ * @queue_rq: Queue a new request from block IO.
149294 */
150295 queue_rq_fn *queue_rq;
151296
152− /*
153− * If a driver uses bd->last to judge when to submit requests to
154− * hardware, it must define this function. In case of errors that
155− * make us stop issuing further requests, this hook serves the
297+ /**
298+ * @commit_rqs: If a driver uses bd->last to judge when to submit
299+ * requests to hardware, it must define this function. In case of errors
300+ * that make us stop issuing further requests, this hook serves the
156301 * purpose of kicking the hardware (which the last request otherwise
157302 * would have done).
158303 */
159304 commit_rqs_fn *commit_rqs;
160305
161− /*
162− * Reserve budget before queue request, once .queue_rq is
306+ /**
307+ * @get_budget: Reserve budget before queue request, once .queue_rq is
163308 * run, it is driver's responsibility to release the
164309 * reserved budget. Also we have to handle failure case
165310 * of .get_budget for avoiding I/O deadlock.
166311 */
167312 get_budget_fn *get_budget;
313+ /**
314+ * @put_budget: Release the reserved budget.
315+ */
168316 put_budget_fn *put_budget;
169317
170− /*
171− * Called on request timeout
318+ /**
319+ * @timeout: Called on request timeout.
172320 */
173321 timeout_fn *timeout;
174322
175− /*
176− * Called to poll for completion of a specific tag.
323+ /**
324+ * @poll: Called to poll for completion of a specific tag.
177325 */
178326 poll_fn *poll;
179327
328+ /**
329+ * @complete: Mark the request as complete.
330+ */
180331 complete_fn *complete;
181332
182− /*
183− * Called when the block layer side of a hardware queue has been
184− * set up, allowing the driver to allocate/init matching structures.
185− * Ditto for exit/teardown.
333+ /**
334+ * @init_hctx: Called when the block layer side of a hardware queue has
335+ * been set up, allowing the driver to allocate/init matching
336+ * structures.
186337 */
187338 init_hctx_fn *init_hctx;
339+ /**
340+ * @exit_hctx: Ditto for exit/teardown.
341+ */
188342 exit_hctx_fn *exit_hctx;
189343
190− /*
191− * Called for every command allocated by the block layer to allow
192− * the driver to set up driver specific data.
344+ /**
345+ * @init_request: Called for every command allocated by the block layer
346+ * to allow the driver to set up driver specific data.
193347 *
194348 * Tag greater than or equal to queue_depth is for setting up
195349 * flush request.
196− *
197− * Ditto for exit/teardown.
198350 */
199351 init_request_fn *init_request;
352+ /**
353+ * @exit_request: Ditto for exit/teardown.
354+ */
200355 exit_request_fn *exit_request;
201− /* Called from inside blk_get_request() */
356+
357+ /**
358+ * @initialize_rq_fn: Called from inside blk_get_request().
359+ */
202360 void (*initialize_rq_fn)(struct request *rq);
203361
204− /*
205− * Called before freeing one request which isn't completed yet,
206− * and usually for freeing the driver private data
362+ /**
363+ * @cleanup_rq: Called before freeing one request which isn't completed
364+ * yet, and usually for freeing the driver private data.
207365 */
208366 cleanup_rq_fn *cleanup_rq;
209367
210− /*
211− * If set, returns whether or not this queue currently is busy
368+ /**
369+ * @busy: If set, returns whether or not this queue currently is busy.
212370 */
213371 busy_fn *busy;
214372
373+ /**
374+ * @map_queues: This allows drivers specify their own queue mapping by
375+ * overriding the setup-time function that builds the mq_map.
376+ */
215377 map_queues_fn *map_queues;
216378
217379 #ifdef CONFIG_BLK_DEBUG_FS
218− /*
219− * Used by the debugfs implementation to show driver-specific
380+ /**
381+ * @show_rq: Used by the debugfs implementation to show driver-specific
220382 * information about a request.
221383 */
222384 void (*show_rq)(struct seq_file *m, struct request *rq);
@@ -262,7 +424,6 @@ void blk_mq_free_tag_set(struct blk_mq_tag_set *set); · 39 unmodified lines
262424 void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule);
263425
264426 void blk_mq_free_request(struct request *rq);
265−bool blk_mq_can_queue(struct blk_mq_hw_ctx *);
266427
267428 bool blk_mq_queue_inflight(struct request_queue *q);
268429
@@ -301,9 +462,25 @@ static inline u16 blk_mq_unique_tag_to_tag(u32 unique_tag) · 32 unmodified lines
301462 return unique_tag & BLK_MQ_UNIQUE_TAG_MASK;
302463 }
303464
465+/**
466+ * blk_mq_rq_state() - read the current MQ_RQ_* state of a request
467+ * @rq: target request.
468+ */
469+static inline enum mq_rq_state blk_mq_rq_state(struct request *rq)
470+{
471+ return READ_ONCE(rq->state);
472+}
473+
474+static inline int blk_mq_request_started(struct request *rq)
475+{
476+ return blk_mq_rq_state(rq) != MQ_RQ_IDLE;
477+}
478+
479+static inline int blk_mq_request_completed(struct request *rq)
480+{
481+ return blk_mq_rq_state(rq) == MQ_RQ_COMPLETE;
482+}
304483
305−int blk_mq_request_started(struct request *rq);
306−int blk_mq_request_completed(struct request *rq);
307484 void blk_mq_start_request(struct request *rq);
308485 void blk_mq_end_request(struct request *rq, blk_status_t error);
309486 void __blk_mq_end_request(struct request *rq, blk_status_t error);
@@ -324,7 +501,7 @@ void blk_mq_start_stopped_hw_queues(struct request_queue *q, bool async); · 14 unmodified lines
324501 void blk_mq_quiesce_queue(struct request_queue *q);
325502 void blk_mq_unquiesce_queue(struct request_queue *q);
326503 void blk_mq_delay_run_hw_queue(struct blk_mq_hw_ctx *hctx, unsigned long msecs);
327−bool blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async);
504+void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async);
328505 void blk_mq_run_hw_queues(struct request_queue *q, bool async);
329506 void blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset,
330507 busy_tag_iter_fn *fn, void *priv);
@@ -343,14 +520,29 @@ void blk_mq_quiesce_queue_nowait(struct request_queue *q); · 12 unmodified lines
343520
344521 unsigned int blk_mq_rq_cpu(struct request *rq);
345522
346−/*
523+/**
524+ * blk_mq_rq_from_pdu - cast a PDU to a request
525+ * @pdu: the PDU (Protocol Data Unit) to be casted
526+ *
527+ * Return: request
528+ *
347529 * Driver command data is immediately after the request. So subtract request
348− * size to get back to the original request, add request size to get the PDU.
530+ * size to get back to the original request.
349531 */
350532 static inline struct request *blk_mq_rq_from_pdu(void *pdu)
351533 {
352534 return pdu - sizeof(struct request);
353535 }
536+
537+/**
538+ * blk_mq_rq_to_pdu - cast a request to a PDU
539+ * @rq: the request to be casted
540+ *
541+ * Return: pointer to the PDU
542+ *
543+ * Driver command data is immediately after the request. So add request to get
544+ * the PDU.
545+ */
354546 static inline void *blk_mq_rq_to_pdu(struct request *rq)
355547 {
356548 return rq + 1;
include/linux/blk_types.h+27−1
@@ -153,10 +153,10 @@ struct bio { · 152 unmodified lines
153153 unsigned short bi_write_hint;
154154 blk_status_t bi_status;
155155 u8 bi_partno;
156+ atomic_t __bi_remaining;
156157
157158 struct bvec_iter bi_iter;
158159
159− atomic_t __bi_remaining;
160160 bio_end_io_t *bi_end_io;
161161
162162 void *bi_private;
@@ -290,6 +290,12 @@ enum req_opf { · 127 unmodified lines
290290 REQ_OP_ZONE_RESET_ALL = 8,
291291 /* write the zero filled sector many times */
292292 REQ_OP_WRITE_ZEROES = 9,
293+ /* Open a zone */
294+ REQ_OP_ZONE_OPEN = 10,
295+ /* Close a zone */
296+ REQ_OP_ZONE_CLOSE = 11,
297+ /* Transition a zone to full */
298+ REQ_OP_ZONE_FINISH = 12,
293299
294300 /* SCSI passthrough using struct scsi_request */
295301 REQ_OP_SCSI_IN = 32,
@@ -371,6 +377,7 @@ enum stat_group { · 75 unmodified lines
371377 STAT_READ,
372378 STAT_WRITE,
373379 STAT_DISCARD,
380+ STAT_FLUSH,
374381
375382 NR_STAT_GROUPS
376383 };
@@ -417,6 +424,25 @@ static inline bool op_is_discard(unsigned int op) · 40 unmodified lines
417424 return (op & REQ_OP_MASK) == REQ_OP_DISCARD;
418425 }
419426
427+/*
428+ * Check if a bio or request operation is a zone management operation, with
429+ * the exception of REQ_OP_ZONE_RESET_ALL which is treated as a special case
430+ * due to its different handling in the block layer and device response in
431+ * case of command failure.
432+ */
433+static inline bool op_is_zone_mgmt(enum req_opf op)
434+{
435+ switch (op & REQ_OP_MASK) {
436+ case REQ_OP_ZONE_RESET:
437+ case REQ_OP_ZONE_OPEN:
438+ case REQ_OP_ZONE_CLOSE:
439+ case REQ_OP_ZONE_FINISH:
440+ return true;
441+ default:
442+ return false;
443+ }
444+}
445+
420446 static inline int op_stat_group(unsigned int op)
421447 {
422448 if (op_is_discard(op))
include/linux/blkdev.h+8−8
@@ -360,14 +360,15 @@ extern unsigned int blkdev_nr_zones(struct block_device *bdev); · 359 unmodified lines
360360 extern int blkdev_report_zones(struct block_device *bdev,
361361 sector_t sector, struct blk_zone *zones,
362362 unsigned int *nr_zones);
363−extern int blkdev_reset_zones(struct block_device *bdev, sector_t sectors,
364− sector_t nr_sectors, gfp_t gfp_mask);
363+extern int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
364+ sector_t sectors, sector_t nr_sectors,
365+ gfp_t gfp_mask);
365366 extern int blk_revalidate_disk_zones(struct gendisk *disk);
366367
367368 extern int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
368369 unsigned int cmd, unsigned long arg);
369−extern int blkdev_reset_zones_ioctl(struct block_device *bdev, fmode_t mode,
370− unsigned int cmd, unsigned long arg);
370+extern int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
371+ unsigned int cmd, unsigned long arg);
371372
372373 #else /* CONFIG_BLK_DEV_ZONED */
373374
@@ -388,9 +389,9 @@ static inline int blkdev_report_zones_ioctl(struct block_device *bdev, · 14 unmodified lines
388389 return -ENOTTY;
389390 }
390391
391−static inline int blkdev_reset_zones_ioctl(struct block_device *bdev,
392− fmode_t mode, unsigned int cmd,
393− unsigned long arg)
392+static inline int blkdev_zone_mgmt_ioctl(struct block_device *bdev,
393+ fmode_t mode, unsigned int cmd,
394+ unsigned long arg)
394395 {
395396 return -ENOTTY;
396397 }
@@ -411,7 +412,6 @@ struct request_queue { · 14 unmodified lines
411412
412413 /* sw queues */
413414 struct blk_mq_ctx __percpu *queue_ctx;
414− unsigned int nr_queues;
415415
416416 unsigned int queue_depth;
417417
include/linux/sbitmap.h+0−9
@@ -216,15 +216,6 @@ int sbitmap_get_shallow(struct sbitmap *sb, unsigned int alloc_hint, · 215 unmodified lines
216216 */
217217 bool sbitmap_any_bit_set(const struct sbitmap *sb);
218218
219−/**
220− * sbitmap_any_bit_clear() - Check for an unset bit in a &struct
221− * sbitmap.
222− * @sb: Bitmap to check.
223− *
224− * Return: true if any bit in the bitmap is clear, false otherwise.
225− */
226−bool sbitmap_any_bit_clear(const struct sbitmap *sb);
227−
228219 #define SB_NR_TO_INDEX(sb, bitnr) ((bitnr) >> (sb)->shift)
229220 #define SB_NR_TO_BIT(sb, bitnr) ((bitnr) & ((1U << (sb)->shift) - 1U))
230221
include/linux/sed-opal.h+1−0
@@ -42,6 +42,7 @@ static inline bool is_sed_ioctl(unsigned int cmd) · 41 unmodified lines
4242 case IOC_OPAL_PSID_REVERT_TPR:
4343 case IOC_OPAL_MBR_DONE:
4444 case IOC_OPAL_WRITE_SHADOW_MBR:
45+ case IOC_OPAL_GENERIC_TABLE_RW:
4546 return true;
4647 }
4748 return false;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t