Skip to content

Commit 2a75184

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.dk/linux-block
Pull block fixes from Jens Axboe: "Small collection of fixes for 3.14-rc. It contains: - Three minor update to blk-mq from Christoph. - Reduce number of unaligned (< 4kb) in-flight writes on mtip32xx to two. From Micron. - Make the blk-mq CPU notify spinlock raw, since it can't be a sleeper spinlock on RT. From Mike Galbraith. - Drop now bogus BUG_ON() for bio iteration with blk integrity. From Nic Bellinger. - Properly propagate the SYNC flag on requests. From Shaohua" * 'for-linus' of git://git.kernel.dk/linux-block: blk-mq: add REQ_SYNC early rt,blk,mq: Make blk_mq_cpu_notify_lock a raw spinlock bio-integrity: Drop bio_integrity_verify BUG_ON in post bip->bip_iter world blk-mq: support partial I/O completions blk-mq: merge blk_mq_insert_request and blk_mq_run_request blk-mq: remove blk_mq_alloc_rq mtip32xx: Reduce the number of unaligned writes to 2
2 parents 8ab47d3 + 739c3ee commit 2a75184

8 files changed

Lines changed: 39 additions & 102 deletions

File tree

‎block/blk-exec.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk,
6565
* be resued after dying flag is set
6666
*/
6767
if (q->mq_ops) {
68-
blk_mq_insert_request(q, rq, at_head, true);
68+
blk_mq_insert_request(rq, at_head, true, false);
6969
return;
7070
}
7171

‎block/blk-flush.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static void mq_flush_run(struct work_struct *work)
137137
rq = container_of(work, struct request, mq_flush_work);
138138

139139
memset(&rq->csd, 0, sizeof(rq->csd));
140-
blk_mq_run_request(rq, true, false);
140+
blk_mq_insert_request(rq, false, true, false);
141141
}
142142

143143
static bool blk_flush_queue_rq(struct request *rq)
@@ -411,7 +411,7 @@ void blk_insert_flush(struct request *rq)
411411
if ((policy & REQ_FSEQ_DATA) &&
412412
!(policy & (REQ_FSEQ_PREFLUSH | REQ_FSEQ_POSTFLUSH))) {
413413
if (q->mq_ops) {
414-
blk_mq_run_request(rq, false, true);
414+
blk_mq_insert_request(rq, false, false, true);
415415
} else
416416
list_add_tail(&rq->queuelist, &q->queue_head);
417417
return;

‎block/blk-mq-cpu.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,37 @@
1111
#include "blk-mq.h"
1212

1313
static LIST_HEAD(blk_mq_cpu_notify_list);
14-
static DEFINE_SPINLOCK(blk_mq_cpu_notify_lock);
14+
static DEFINE_RAW_SPINLOCK(blk_mq_cpu_notify_lock);
1515

1616
static int blk_mq_main_cpu_notify(struct notifier_block *self,
1717
unsigned long action, void *hcpu)
1818
{
1919
unsigned int cpu = (unsigned long) hcpu;
2020
struct blk_mq_cpu_notifier *notify;
2121

22-
spin_lock(&blk_mq_cpu_notify_lock);
22+
raw_spin_lock(&blk_mq_cpu_notify_lock);
2323

2424
list_for_each_entry(notify, &blk_mq_cpu_notify_list, list)
2525
notify->notify(notify->data, action, cpu);
2626

27-
spin_unlock(&blk_mq_cpu_notify_lock);
27+
raw_spin_unlock(&blk_mq_cpu_notify_lock);
2828
return NOTIFY_OK;
2929
}
3030

3131
void blk_mq_register_cpu_notifier(struct blk_mq_cpu_notifier *notifier)
3232
{
3333
BUG_ON(!notifier->notify);
3434

35-
spin_lock(&blk_mq_cpu_notify_lock);
35+
raw_spin_lock(&blk_mq_cpu_notify_lock);
3636
list_add_tail(&notifier->list, &blk_mq_cpu_notify_list);
37-
spin_unlock(&blk_mq_cpu_notify_lock);
37+
raw_spin_unlock(&blk_mq_cpu_notify_lock);
3838
}
3939

4040
void blk_mq_unregister_cpu_notifier(struct blk_mq_cpu_notifier *notifier)
4141
{
42-
spin_lock(&blk_mq_cpu_notify_lock);
42+
raw_spin_lock(&blk_mq_cpu_notify_lock);
4343
list_del(&notifier->list);
44-
spin_unlock(&blk_mq_cpu_notify_lock);
44+
raw_spin_unlock(&blk_mq_cpu_notify_lock);
4545
}
4646

4747
void blk_mq_init_cpu_notifier(struct blk_mq_cpu_notifier *notifier,

‎block/blk-mq.c‎

Lines changed: 19 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ static void blk_mq_hctx_mark_pending(struct blk_mq_hw_ctx *hctx,
7373
set_bit(ctx->index_hw, hctx->ctx_map);
7474
}
7575

76-
static struct request *blk_mq_alloc_rq(struct blk_mq_hw_ctx *hctx, gfp_t gfp,
77-
bool reserved)
76+
static struct request *__blk_mq_alloc_request(struct blk_mq_hw_ctx *hctx,
77+
gfp_t gfp, bool reserved)
7878
{
7979
struct request *rq;
8080
unsigned int tag;
@@ -193,12 +193,6 @@ static void blk_mq_rq_ctx_init(struct request_queue *q, struct blk_mq_ctx *ctx,
193193
ctx->rq_dispatched[rw_is_sync(rw_flags)]++;
194194
}
195195

196-
static struct request *__blk_mq_alloc_request(struct blk_mq_hw_ctx *hctx,
197-
gfp_t gfp, bool reserved)
198-
{
199-
return blk_mq_alloc_rq(hctx, gfp, reserved);
200-
}
201-
202196
static struct request *blk_mq_alloc_request_pinned(struct request_queue *q,
203197
int rw, gfp_t gfp,
204198
bool reserved)
@@ -289,47 +283,20 @@ void blk_mq_free_request(struct request *rq)
289283
__blk_mq_free_request(hctx, ctx, rq);
290284
}
291285

292-
static void blk_mq_bio_endio(struct request *rq, struct bio *bio, int error)
293-
{
294-
if (error)
295-
clear_bit(BIO_UPTODATE, &bio->bi_flags);
296-
else if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
297-
error = -EIO;
298-
299-
if (unlikely(rq->cmd_flags & REQ_QUIET))
300-
set_bit(BIO_QUIET, &bio->bi_flags);
301-
302-
/* don't actually finish bio if it's part of flush sequence */
303-
if (!(rq->cmd_flags & REQ_FLUSH_SEQ))
304-
bio_endio(bio, error);
305-
}
306-
307-
void blk_mq_end_io(struct request *rq, int error)
286+
bool blk_mq_end_io_partial(struct request *rq, int error, unsigned int nr_bytes)
308287
{
309-
struct bio *bio = rq->bio;
310-
unsigned int bytes = 0;
311-
312-
trace_block_rq_complete(rq->q, rq);
313-
314-
while (bio) {
315-
struct bio *next = bio->bi_next;
316-
317-
bio->bi_next = NULL;
318-
bytes += bio->bi_iter.bi_size;
319-
blk_mq_bio_endio(rq, bio, error);
320-
bio = next;
321-
}
322-
323-
blk_account_io_completion(rq, bytes);
288+
if (blk_update_request(rq, error, blk_rq_bytes(rq)))
289+
return true;
324290

325291
blk_account_io_done(rq);
326292

327293
if (rq->end_io)
328294
rq->end_io(rq, error);
329295
else
330296
blk_mq_free_request(rq);
297+
return false;
331298
}
332-
EXPORT_SYMBOL(blk_mq_end_io);
299+
EXPORT_SYMBOL(blk_mq_end_io_partial);
333300

334301
static void __blk_mq_complete_request_remote(void *data)
335302
{
@@ -730,60 +697,27 @@ static void __blk_mq_insert_request(struct blk_mq_hw_ctx *hctx,
730697
blk_mq_add_timer(rq);
731698
}
732699

733-
void blk_mq_insert_request(struct request_queue *q, struct request *rq,
734-
bool at_head, bool run_queue)
700+
void blk_mq_insert_request(struct request *rq, bool at_head, bool run_queue,
701+
bool async)
735702
{
703+
struct request_queue *q = rq->q;
736704
struct blk_mq_hw_ctx *hctx;
737-
struct blk_mq_ctx *ctx, *current_ctx;
705+
struct blk_mq_ctx *ctx = rq->mq_ctx, *current_ctx;
706+
707+
current_ctx = blk_mq_get_ctx(q);
708+
if (!cpu_online(ctx->cpu))
709+
rq->mq_ctx = ctx = current_ctx;
738710

739-
ctx = rq->mq_ctx;
740711
hctx = q->mq_ops->map_queue(q, ctx->cpu);
741712

742-
if (rq->cmd_flags & (REQ_FLUSH | REQ_FUA)) {
713+
if (rq->cmd_flags & (REQ_FLUSH | REQ_FUA) &&
714+
!(rq->cmd_flags & (REQ_FLUSH_SEQ))) {
743715
blk_insert_flush(rq);
744716
} else {
745-
current_ctx = blk_mq_get_ctx(q);
746-
747-
if (!cpu_online(ctx->cpu)) {
748-
ctx = current_ctx;
749-
hctx = q->mq_ops->map_queue(q, ctx->cpu);
750-
rq->mq_ctx = ctx;
751-
}
752717
spin_lock(&ctx->lock);
753718
__blk_mq_insert_request(hctx, rq, at_head);
754719
spin_unlock(&ctx->lock);
755-
756-
blk_mq_put_ctx(current_ctx);
757-
}
758-
759-
if (run_queue)
760-
__blk_mq_run_hw_queue(hctx);
761-
}
762-
EXPORT_SYMBOL(blk_mq_insert_request);
763-
764-
/*
765-
* This is a special version of blk_mq_insert_request to bypass FLUSH request
766-
* check. Should only be used internally.
767-
*/
768-
void blk_mq_run_request(struct request *rq, bool run_queue, bool async)
769-
{
770-
struct request_queue *q = rq->q;
771-
struct blk_mq_hw_ctx *hctx;
772-
struct blk_mq_ctx *ctx, *current_ctx;
773-
774-
current_ctx = blk_mq_get_ctx(q);
775-
776-
ctx = rq->mq_ctx;
777-
if (!cpu_online(ctx->cpu)) {
778-
ctx = current_ctx;
779-
rq->mq_ctx = ctx;
780720
}
781-
hctx = q->mq_ops->map_queue(q, ctx->cpu);
782-
783-
/* ctx->cpu might be offline */
784-
spin_lock(&ctx->lock);
785-
__blk_mq_insert_request(hctx, rq, false);
786-
spin_unlock(&ctx->lock);
787721

788722
blk_mq_put_ctx(current_ctx);
789723

@@ -926,6 +860,8 @@ static void blk_mq_make_request(struct request_queue *q, struct bio *bio)
926860
ctx = blk_mq_get_ctx(q);
927861
hctx = q->mq_ops->map_queue(q, ctx->cpu);
928862

863+
if (is_sync)
864+
rw |= REQ_SYNC;
929865
trace_block_getrq(q, bio, rw);
930866
rq = __blk_mq_alloc_request(hctx, GFP_ATOMIC, false);
931867
if (likely(rq))

‎block/blk-mq.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ struct blk_mq_ctx {
2323
};
2424

2525
void __blk_mq_complete_request(struct request *rq);
26-
void blk_mq_run_request(struct request *rq, bool run_queue, bool async);
2726
void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async);
2827
void blk_mq_init_flush(struct request_queue *q);
2928
void blk_mq_drain_queue(struct request_queue *q);

‎drivers/block/mtip32xx/mtip32xx.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
#define MTIP_FTL_REBUILD_TIMEOUT_MS 2400000
5454

5555
/* unaligned IO handling */
56-
#define MTIP_MAX_UNALIGNED_SLOTS 8
56+
#define MTIP_MAX_UNALIGNED_SLOTS 2
5757

5858
/* Macro to extract the tag bit number from a tag value. */
5959
#define MTIP_TAG_BIT(tag) (tag & 0x1F)

‎fs/bio-integrity.c‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,11 +458,10 @@ static int bio_integrity_verify(struct bio *bio)
458458
struct blk_integrity_exchg bix;
459459
struct bio_vec *bv;
460460
sector_t sector = bio->bi_integrity->bip_iter.bi_sector;
461-
unsigned int sectors, total, ret;
461+
unsigned int sectors, ret = 0;
462462
void *prot_buf = bio->bi_integrity->bip_buf;
463463
int i;
464464

465-
ret = total = 0;
466465
bix.disk_name = bio->bi_bdev->bd_disk->disk_name;
467466
bix.sector_size = bi->sector_size;
468467

@@ -484,8 +483,6 @@ static int bio_integrity_verify(struct bio *bio)
484483
sectors = bv->bv_len / bi->sector_size;
485484
sector += sectors;
486485
prot_buf += sectors * bi->tuple_size;
487-
total += sectors * bi->tuple_size;
488-
BUG_ON(total > bio->bi_integrity->bip_iter.bi_size);
489486

490487
kunmap_atomic(kaddr);
491488
}

‎include/linux/blk-mq.h‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ void blk_mq_init_commands(struct request_queue *, void (*init)(void *data, struc
121121

122122
void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule);
123123

124-
void blk_mq_insert_request(struct request_queue *, struct request *,
125-
bool, bool);
124+
void blk_mq_insert_request(struct request *, bool, bool, bool);
126125
void blk_mq_run_queues(struct request_queue *q, bool async);
127126
void blk_mq_free_request(struct request *rq);
128127
bool blk_mq_can_queue(struct blk_mq_hw_ctx *);
@@ -134,7 +133,13 @@ struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *, const int ctx_ind
134133
struct blk_mq_hw_ctx *blk_mq_alloc_single_hw_queue(struct blk_mq_reg *, unsigned int);
135134
void blk_mq_free_single_hw_queue(struct blk_mq_hw_ctx *, unsigned int);
136135

137-
void blk_mq_end_io(struct request *rq, int error);
136+
bool blk_mq_end_io_partial(struct request *rq, int error,
137+
unsigned int nr_bytes);
138+
static inline void blk_mq_end_io(struct request *rq, int error)
139+
{
140+
bool done = !blk_mq_end_io_partial(rq, error, blk_rq_bytes(rq));
141+
BUG_ON(!done);
142+
}
138143

139144
void blk_mq_complete_request(struct request *rq);
140145

0 commit comments

Comments
 (0)