Skip to content

Commit 2edc78b

Browse files
committed
Merge tag 'block-5.6-2020-02-28' of git://git.kernel.dk/linux-block
Pull block fixes from Jens Axboe: - Passthrough insertion fix (Ming) - Kill off some unused arguments (John) - blktrace RCU fix (Jan) - Dead fields removal for null_blk (Dongli) - NVMe polled IO fix (Bijan) * tag 'block-5.6-2020-02-28' of git://git.kernel.dk/linux-block: nvme-pci: Hold cq_poll_lock while completing CQEs blk-mq: Remove some unused function arguments null_blk: remove unused fields in 'nullb_cmd' blktrace: Protect q->blk_trace with RCU blk-mq: insert passthrough request into hctx->dispatch directly
2 parents 74dea5d + 5b8ea58 commit 2edc78b

File tree

12 files changed

+136
-70
lines changed

12 files changed

+136
-70
lines changed

block/blk-flush.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ void blk_insert_flush(struct request *rq)
412412
*/
413413
if ((policy & REQ_FSEQ_DATA) &&
414414
!(policy & (REQ_FSEQ_PREFLUSH | REQ_FSEQ_POSTFLUSH))) {
415-
blk_mq_request_bypass_insert(rq, false);
415+
blk_mq_request_bypass_insert(rq, false, false);
416416
return;
417417
}
418418

block/blk-mq-sched.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,19 @@ static bool blk_mq_sched_bypass_insert(struct blk_mq_hw_ctx *hctx,
361361
bool has_sched,
362362
struct request *rq)
363363
{
364-
/* dispatch flush rq directly */
365-
if (rq->rq_flags & RQF_FLUSH_SEQ) {
366-
spin_lock(&hctx->lock);
367-
list_add(&rq->queuelist, &hctx->dispatch);
368-
spin_unlock(&hctx->lock);
364+
/*
365+
* dispatch flush and passthrough rq directly
366+
*
367+
* passthrough request has to be added to hctx->dispatch directly.
368+
* For some reason, device may be in one situation which can't
369+
* handle FS request, so STS_RESOURCE is always returned and the
370+
* FS request will be added to hctx->dispatch. However passthrough
371+
* request may be required at that time for fixing the problem. If
372+
* passthrough request is added to scheduler queue, there isn't any
373+
* chance to dispatch it given we prioritize requests in hctx->dispatch.
374+
*/
375+
if ((rq->rq_flags & RQF_FLUSH_SEQ) || blk_rq_is_passthrough(rq))
369376
return true;
370-
}
371377

372378
if (has_sched)
373379
rq->rq_flags |= RQF_SORTED;
@@ -391,8 +397,10 @@ void blk_mq_sched_insert_request(struct request *rq, bool at_head,
391397

392398
WARN_ON(e && (rq->tag != -1));
393399

394-
if (blk_mq_sched_bypass_insert(hctx, !!e, rq))
400+
if (blk_mq_sched_bypass_insert(hctx, !!e, rq)) {
401+
blk_mq_request_bypass_insert(rq, at_head, false);
395402
goto run;
403+
}
396404

397405
if (e && e->type->ops.insert_requests) {
398406
LIST_HEAD(list);

block/blk-mq-tag.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data)
183183
return tag + tag_offset;
184184
}
185185

186-
void blk_mq_put_tag(struct blk_mq_hw_ctx *hctx, struct blk_mq_tags *tags,
187-
struct blk_mq_ctx *ctx, unsigned int tag)
186+
void blk_mq_put_tag(struct blk_mq_tags *tags, struct blk_mq_ctx *ctx,
187+
unsigned int tag)
188188
{
189189
if (!blk_mq_tag_is_reserved(tags, tag)) {
190190
const int real_tag = tag - tags->nr_reserved_tags;

block/blk-mq-tag.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ extern struct blk_mq_tags *blk_mq_init_tags(unsigned int nr_tags, unsigned int r
2626
extern void blk_mq_free_tags(struct blk_mq_tags *tags);
2727

2828
extern unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data);
29-
extern void blk_mq_put_tag(struct blk_mq_hw_ctx *hctx, struct blk_mq_tags *tags,
30-
struct blk_mq_ctx *ctx, unsigned int tag);
29+
extern void blk_mq_put_tag(struct blk_mq_tags *tags, struct blk_mq_ctx *ctx,
30+
unsigned int tag);
3131
extern int blk_mq_tag_update_depth(struct blk_mq_hw_ctx *hctx,
3232
struct blk_mq_tags **tags,
3333
unsigned int depth, bool can_grow);

block/blk-mq.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,9 @@ static void __blk_mq_free_request(struct request *rq)
477477
blk_pm_mark_last_busy(rq);
478478
rq->mq_hctx = NULL;
479479
if (rq->tag != -1)
480-
blk_mq_put_tag(hctx, hctx->tags, ctx, rq->tag);
480+
blk_mq_put_tag(hctx->tags, ctx, rq->tag);
481481
if (sched_tag != -1)
482-
blk_mq_put_tag(hctx, hctx->sched_tags, ctx, sched_tag);
482+
blk_mq_put_tag(hctx->sched_tags, ctx, sched_tag);
483483
blk_mq_sched_restart(hctx);
484484
blk_queue_exit(q);
485485
}
@@ -735,7 +735,7 @@ static void blk_mq_requeue_work(struct work_struct *work)
735735
* merge.
736736
*/
737737
if (rq->rq_flags & RQF_DONTPREP)
738-
blk_mq_request_bypass_insert(rq, false);
738+
blk_mq_request_bypass_insert(rq, false, false);
739739
else
740740
blk_mq_sched_insert_request(rq, true, false, false);
741741
}
@@ -1286,7 +1286,7 @@ bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list,
12861286
q->mq_ops->commit_rqs(hctx);
12871287

12881288
spin_lock(&hctx->lock);
1289-
list_splice_init(list, &hctx->dispatch);
1289+
list_splice_tail_init(list, &hctx->dispatch);
12901290
spin_unlock(&hctx->lock);
12911291

12921292
/*
@@ -1677,12 +1677,16 @@ void __blk_mq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
16771677
* Should only be used carefully, when the caller knows we want to
16781678
* bypass a potential IO scheduler on the target device.
16791679
*/
1680-
void blk_mq_request_bypass_insert(struct request *rq, bool run_queue)
1680+
void blk_mq_request_bypass_insert(struct request *rq, bool at_head,
1681+
bool run_queue)
16811682
{
16821683
struct blk_mq_hw_ctx *hctx = rq->mq_hctx;
16831684

16841685
spin_lock(&hctx->lock);
1685-
list_add_tail(&rq->queuelist, &hctx->dispatch);
1686+
if (at_head)
1687+
list_add(&rq->queuelist, &hctx->dispatch);
1688+
else
1689+
list_add_tail(&rq->queuelist, &hctx->dispatch);
16861690
spin_unlock(&hctx->lock);
16871691

16881692
if (run_queue)
@@ -1849,7 +1853,7 @@ static blk_status_t __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
18491853
if (bypass_insert)
18501854
return BLK_STS_RESOURCE;
18511855

1852-
blk_mq_request_bypass_insert(rq, run_queue);
1856+
blk_mq_request_bypass_insert(rq, false, run_queue);
18531857
return BLK_STS_OK;
18541858
}
18551859

@@ -1876,7 +1880,7 @@ static void blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
18761880

18771881
ret = __blk_mq_try_issue_directly(hctx, rq, cookie, false, true);
18781882
if (ret == BLK_STS_RESOURCE || ret == BLK_STS_DEV_RESOURCE)
1879-
blk_mq_request_bypass_insert(rq, true);
1883+
blk_mq_request_bypass_insert(rq, false, true);
18801884
else if (ret != BLK_STS_OK)
18811885
blk_mq_end_request(rq, ret);
18821886

@@ -1910,7 +1914,7 @@ void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
19101914
if (ret != BLK_STS_OK) {
19111915
if (ret == BLK_STS_RESOURCE ||
19121916
ret == BLK_STS_DEV_RESOURCE) {
1913-
blk_mq_request_bypass_insert(rq,
1917+
blk_mq_request_bypass_insert(rq, false,
19141918
list_empty(list));
19151919
break;
19161920
}
@@ -3398,7 +3402,6 @@ static void blk_mq_poll_stats_fn(struct blk_stat_callback *cb)
33983402
}
33993403

34003404
static unsigned long blk_mq_poll_nsecs(struct request_queue *q,
3401-
struct blk_mq_hw_ctx *hctx,
34023405
struct request *rq)
34033406
{
34043407
unsigned long ret = 0;
@@ -3431,7 +3434,6 @@ static unsigned long blk_mq_poll_nsecs(struct request_queue *q,
34313434
}
34323435

34333436
static bool blk_mq_poll_hybrid_sleep(struct request_queue *q,
3434-
struct blk_mq_hw_ctx *hctx,
34353437
struct request *rq)
34363438
{
34373439
struct hrtimer_sleeper hs;
@@ -3451,7 +3453,7 @@ static bool blk_mq_poll_hybrid_sleep(struct request_queue *q,
34513453
if (q->poll_nsec > 0)
34523454
nsecs = q->poll_nsec;
34533455
else
3454-
nsecs = blk_mq_poll_nsecs(q, hctx, rq);
3456+
nsecs = blk_mq_poll_nsecs(q, rq);
34553457

34563458
if (!nsecs)
34573459
return false;
@@ -3506,7 +3508,7 @@ static bool blk_mq_poll_hybrid(struct request_queue *q,
35063508
return false;
35073509
}
35083510

3509-
return blk_mq_poll_hybrid_sleep(q, hctx, rq);
3511+
return blk_mq_poll_hybrid_sleep(q, rq);
35103512
}
35113513

35123514
/**

block/blk-mq.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ int blk_mq_alloc_rqs(struct blk_mq_tag_set *set, struct blk_mq_tags *tags,
6666
*/
6767
void __blk_mq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
6868
bool at_head);
69-
void blk_mq_request_bypass_insert(struct request *rq, bool run_queue);
69+
void blk_mq_request_bypass_insert(struct request *rq, bool at_head,
70+
bool run_queue);
7071
void blk_mq_insert_requests(struct blk_mq_hw_ctx *hctx, struct blk_mq_ctx *ctx,
7172
struct list_head *list);
7273

@@ -199,7 +200,7 @@ static inline bool blk_mq_get_dispatch_budget(struct blk_mq_hw_ctx *hctx)
199200
static inline void __blk_mq_put_driver_tag(struct blk_mq_hw_ctx *hctx,
200201
struct request *rq)
201202
{
202-
blk_mq_put_tag(hctx, hctx->tags, rq->mq_ctx, rq->tag);
203+
blk_mq_put_tag(hctx->tags, rq->mq_ctx, rq->tag);
203204
rq->tag = -1;
204205

205206
if (rq->rq_flags & RQF_MQ_INFLIGHT) {

drivers/block/null_blk.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
#include <linux/fault-inject.h>
1515

1616
struct nullb_cmd {
17-
struct list_head list;
18-
struct llist_node ll_list;
19-
struct __call_single_data csd;
2017
struct request *rq;
2118
struct bio *bio;
2219
unsigned int tag;

drivers/block/null_blk_main.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,8 +1518,6 @@ static int setup_commands(struct nullb_queue *nq)
15181518

15191519
for (i = 0; i < nq->queue_depth; i++) {
15201520
cmd = &nq->cmds[i];
1521-
INIT_LIST_HEAD(&cmd->list);
1522-
cmd->ll_list.next = NULL;
15231521
cmd->tag = -1U;
15241522
}
15251523

drivers/nvme/host/pci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1078,9 +1078,9 @@ static int nvme_poll(struct blk_mq_hw_ctx *hctx)
10781078

10791079
spin_lock(&nvmeq->cq_poll_lock);
10801080
found = nvme_process_cq(nvmeq, &start, &end, -1);
1081+
nvme_complete_cqes(nvmeq, start, end);
10811082
spin_unlock(&nvmeq->cq_poll_lock);
10821083

1083-
nvme_complete_cqes(nvmeq, start, end);
10841084
return found;
10851085
}
10861086

include/linux/blkdev.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ struct request_queue {
524524
unsigned int sg_reserved_size;
525525
int node;
526526
#ifdef CONFIG_BLK_DEV_IO_TRACE
527-
struct blk_trace *blk_trace;
527+
struct blk_trace __rcu *blk_trace;
528528
struct mutex blk_trace_mutex;
529529
#endif
530530
/*

0 commit comments

Comments
 (0)