Skip to content

Commit 7fbc78e

Browse files
committed
Merge tag 'for-linus-20190524' of git://git.kernel.dk/linux-block
Pull block fixes from Jens Axboe: - NVMe pull request from Keith, with fixes from a few folks. - bio and sbitmap before atomic barrier fixes (Andrea) - Hang fix for blk-mq freeze and unfreeze (Bob) - Single segment count regression fix (Christoph) - AoE now has a new maintainer - tools/io_uring/ Makefile fix, and sync with liburing (me) * tag 'for-linus-20190524' of git://git.kernel.dk/linux-block: (23 commits) tools/io_uring: sync with liburing tools/io_uring: fix Makefile for pthread library link blk-mq: fix hang caused by freeze/unfreeze sequence block: remove the bi_seg_{front,back}_size fields in struct bio block: remove the segment size check in bio_will_gap block: force an unlimited segment size on queues with a virt boundary block: don't decrement nr_phys_segments for physically contigous segments sbitmap: fix improper use of smp_mb__before_atomic() bio: fix improper use of smp_mb__before_atomic() aoe: list new maintainer for aoe driver nvme-pci: use blk-mq mapping for unmanaged irqs nvme: update MAINTAINERS nvme: copy MTFA field from identify controller nvme: fix memory leak for power latency tolerance nvme: release namespace SRCU protection before performing controller ioctls nvme: merge nvme_ns_ioctl into nvme_ioctl nvme: remove the ifdef around nvme_nvm_ioctl nvme: fix srcu locking on error return in nvme_get_ns_from_disk nvme: Fix known effects nvme-pci: Sync queues on reset ...
2 parents 7f8b40e + 096c7a6 commit 7fbc78e

File tree

18 files changed

+241
-246
lines changed

18 files changed

+241
-246
lines changed

MAINTAINERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2627,7 +2627,7 @@ F: Documentation/devicetree/bindings/eeprom/at24.txt
26272627
F: drivers/misc/eeprom/at24.c
26282628

26292629
ATA OVER ETHERNET (AOE) DRIVER
2630-
M: "Ed L. Cashin" <[email protected]>
2630+
M: "Justin Sanders" <[email protected]>
26312631
W: http://www.openaoe.org/
26322632
S: Supported
26332633
F: Documentation/aoe/
@@ -11226,7 +11226,7 @@ F: drivers/video/fbdev/riva/
1122611226
F: drivers/video/fbdev/nvidia/
1122711227

1122811228
NVM EXPRESS DRIVER
11229-
M: Keith Busch <[email protected]>
11229+
M: Keith Busch <[email protected]>
1123011230
M: Jens Axboe <[email protected]>
1123111231
M: Christoph Hellwig <[email protected]>
1123211232
M: Sagi Grimberg <[email protected]>

block/blk-core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ int blk_queue_enter(struct request_queue *q, blk_mq_req_flags_t flags)
413413
smp_rmb();
414414

415415
wait_event(q->mq_freeze_wq,
416-
(atomic_read(&q->mq_freeze_depth) == 0 &&
416+
(!q->mq_freeze_depth &&
417417
(pm || (blk_pm_request_resume(q),
418418
!blk_queue_pm_only(q)))) ||
419419
blk_queue_dying(q));
@@ -503,6 +503,7 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id)
503503
spin_lock_init(&q->queue_lock);
504504

505505
init_waitqueue_head(&q->mq_freeze_wq);
506+
mutex_init(&q->mq_freeze_lock);
506507

507508
/*
508509
* Init percpu_ref in atomic mode so that it's faster to shutdown.

block/blk-merge.c

Lines changed: 13 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,6 @@
1212

1313
#include "blk.h"
1414

15-
/*
16-
* Check if the two bvecs from two bios can be merged to one segment. If yes,
17-
* no need to check gap between the two bios since the 1st bio and the 1st bvec
18-
* in the 2nd bio can be handled in one segment.
19-
*/
20-
static inline bool bios_segs_mergeable(struct request_queue *q,
21-
struct bio *prev, struct bio_vec *prev_last_bv,
22-
struct bio_vec *next_first_bv)
23-
{
24-
if (!biovec_phys_mergeable(q, prev_last_bv, next_first_bv))
25-
return false;
26-
if (prev->bi_seg_back_size + next_first_bv->bv_len >
27-
queue_max_segment_size(q))
28-
return false;
29-
return true;
30-
}
31-
3215
static inline bool bio_will_gap(struct request_queue *q,
3316
struct request *prev_rq, struct bio *prev, struct bio *next)
3417
{
@@ -60,7 +43,7 @@ static inline bool bio_will_gap(struct request_queue *q,
6043
*/
6144
bio_get_last_bvec(prev, &pb);
6245
bio_get_first_bvec(next, &nb);
63-
if (bios_segs_mergeable(q, prev, &pb, &nb))
46+
if (biovec_phys_mergeable(q, &pb, &nb))
6447
return false;
6548
return __bvec_gap_to_prev(q, &pb, nb.bv_offset);
6649
}
@@ -179,8 +162,7 @@ static unsigned get_max_segment_size(struct request_queue *q,
179162
* variables.
180163
*/
181164
static bool bvec_split_segs(struct request_queue *q, struct bio_vec *bv,
182-
unsigned *nsegs, unsigned *last_seg_size,
183-
unsigned *front_seg_size, unsigned *sectors, unsigned max_segs)
165+
unsigned *nsegs, unsigned *sectors, unsigned max_segs)
184166
{
185167
unsigned len = bv->bv_len;
186168
unsigned total_len = 0;
@@ -202,28 +184,12 @@ static bool bvec_split_segs(struct request_queue *q, struct bio_vec *bv,
202184
break;
203185
}
204186

205-
if (!new_nsegs)
206-
return !!len;
207-
208-
/* update front segment size */
209-
if (!*nsegs) {
210-
unsigned first_seg_size;
211-
212-
if (new_nsegs == 1)
213-
first_seg_size = get_max_segment_size(q, bv->bv_offset);
214-
else
215-
first_seg_size = queue_max_segment_size(q);
216-
217-
if (*front_seg_size < first_seg_size)
218-
*front_seg_size = first_seg_size;
187+
if (new_nsegs) {
188+
*nsegs += new_nsegs;
189+
if (sectors)
190+
*sectors += total_len >> 9;
219191
}
220192

221-
/* update other varibles */
222-
*last_seg_size = seg_size;
223-
*nsegs += new_nsegs;
224-
if (sectors)
225-
*sectors += total_len >> 9;
226-
227193
/* split in the middle of the bvec if len != 0 */
228194
return !!len;
229195
}
@@ -235,8 +201,7 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,
235201
{
236202
struct bio_vec bv, bvprv, *bvprvp = NULL;
237203
struct bvec_iter iter;
238-
unsigned seg_size = 0, nsegs = 0, sectors = 0;
239-
unsigned front_seg_size = bio->bi_seg_front_size;
204+
unsigned nsegs = 0, sectors = 0;
240205
bool do_split = true;
241206
struct bio *new = NULL;
242207
const unsigned max_sectors = get_max_io_size(q, bio);
@@ -260,8 +225,6 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,
260225
/* split in the middle of bvec */
261226
bv.bv_len = (max_sectors - sectors) << 9;
262227
bvec_split_segs(q, &bv, &nsegs,
263-
&seg_size,
264-
&front_seg_size,
265228
&sectors, max_segs);
266229
}
267230
goto split;
@@ -275,12 +238,9 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,
275238

276239
if (bv.bv_offset + bv.bv_len <= PAGE_SIZE) {
277240
nsegs++;
278-
seg_size = bv.bv_len;
279241
sectors += bv.bv_len >> 9;
280-
if (nsegs == 1 && seg_size > front_seg_size)
281-
front_seg_size = seg_size;
282-
} else if (bvec_split_segs(q, &bv, &nsegs, &seg_size,
283-
&front_seg_size, &sectors, max_segs)) {
242+
} else if (bvec_split_segs(q, &bv, &nsegs, &sectors,
243+
max_segs)) {
284244
goto split;
285245
}
286246
}
@@ -295,10 +255,6 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,
295255
bio = new;
296256
}
297257

298-
bio->bi_seg_front_size = front_seg_size;
299-
if (seg_size > bio->bi_seg_back_size)
300-
bio->bi_seg_back_size = seg_size;
301-
302258
return do_split ? new : NULL;
303259
}
304260

@@ -353,18 +309,13 @@ EXPORT_SYMBOL(blk_queue_split);
353309
static unsigned int __blk_recalc_rq_segments(struct request_queue *q,
354310
struct bio *bio)
355311
{
356-
struct bio_vec uninitialized_var(bv), bvprv = { NULL };
357-
unsigned int seg_size, nr_phys_segs;
358-
unsigned front_seg_size;
359-
struct bio *fbio, *bbio;
312+
unsigned int nr_phys_segs = 0;
360313
struct bvec_iter iter;
361-
bool new_bio = false;
314+
struct bio_vec bv;
362315

363316
if (!bio)
364317
return 0;
365318

366-
front_seg_size = bio->bi_seg_front_size;
367-
368319
switch (bio_op(bio)) {
369320
case REQ_OP_DISCARD:
370321
case REQ_OP_SECURE_ERASE:
@@ -374,42 +325,11 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q,
374325
return 1;
375326
}
376327

377-
fbio = bio;
378-
seg_size = 0;
379-
nr_phys_segs = 0;
380328
for_each_bio(bio) {
381-
bio_for_each_bvec(bv, bio, iter) {
382-
if (new_bio) {
383-
if (seg_size + bv.bv_len
384-
> queue_max_segment_size(q))
385-
goto new_segment;
386-
if (!biovec_phys_mergeable(q, &bvprv, &bv))
387-
goto new_segment;
388-
389-
seg_size += bv.bv_len;
390-
391-
if (nr_phys_segs == 1 && seg_size >
392-
front_seg_size)
393-
front_seg_size = seg_size;
394-
395-
continue;
396-
}
397-
new_segment:
398-
bvec_split_segs(q, &bv, &nr_phys_segs, &seg_size,
399-
&front_seg_size, NULL, UINT_MAX);
400-
new_bio = false;
401-
}
402-
bbio = bio;
403-
if (likely(bio->bi_iter.bi_size)) {
404-
bvprv = bv;
405-
new_bio = true;
406-
}
329+
bio_for_each_bvec(bv, bio, iter)
330+
bvec_split_segs(q, &bv, &nr_phys_segs, NULL, UINT_MAX);
407331
}
408332

409-
fbio->bi_seg_front_size = front_seg_size;
410-
if (seg_size > bbio->bi_seg_back_size)
411-
bbio->bi_seg_back_size = seg_size;
412-
413333
return nr_phys_segs;
414334
}
415335

@@ -429,24 +349,6 @@ void blk_recount_segments(struct request_queue *q, struct bio *bio)
429349
bio_set_flag(bio, BIO_SEG_VALID);
430350
}
431351

432-
static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio,
433-
struct bio *nxt)
434-
{
435-
struct bio_vec end_bv = { NULL }, nxt_bv;
436-
437-
if (bio->bi_seg_back_size + nxt->bi_seg_front_size >
438-
queue_max_segment_size(q))
439-
return 0;
440-
441-
if (!bio_has_data(bio))
442-
return 1;
443-
444-
bio_get_last_bvec(bio, &end_bv);
445-
bio_get_first_bvec(nxt, &nxt_bv);
446-
447-
return biovec_phys_mergeable(q, &end_bv, &nxt_bv);
448-
}
449-
450352
static inline struct scatterlist *blk_next_sg(struct scatterlist **sg,
451353
struct scatterlist *sglist)
452354
{
@@ -706,8 +608,6 @@ static int ll_merge_requests_fn(struct request_queue *q, struct request *req,
706608
struct request *next)
707609
{
708610
int total_phys_segments;
709-
unsigned int seg_size =
710-
req->biotail->bi_seg_back_size + next->bio->bi_seg_front_size;
711611

712612
if (req_gap_back_merge(req, next->bio))
713613
return 0;
@@ -720,14 +620,6 @@ static int ll_merge_requests_fn(struct request_queue *q, struct request *req,
720620
return 0;
721621

722622
total_phys_segments = req->nr_phys_segments + next->nr_phys_segments;
723-
if (blk_phys_contig_segment(q, req->biotail, next->bio)) {
724-
if (req->nr_phys_segments == 1)
725-
req->bio->bi_seg_front_size = seg_size;
726-
if (next->nr_phys_segments == 1)
727-
next->biotail->bi_seg_back_size = seg_size;
728-
total_phys_segments--;
729-
}
730-
731623
if (total_phys_segments > queue_max_segments(q))
732624
return 0;
733625

block/blk-mq.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,14 @@ void blk_mq_in_flight_rw(struct request_queue *q, struct hd_struct *part,
144144

145145
void blk_freeze_queue_start(struct request_queue *q)
146146
{
147-
int freeze_depth;
148-
149-
freeze_depth = atomic_inc_return(&q->mq_freeze_depth);
150-
if (freeze_depth == 1) {
147+
mutex_lock(&q->mq_freeze_lock);
148+
if (++q->mq_freeze_depth == 1) {
151149
percpu_ref_kill(&q->q_usage_counter);
150+
mutex_unlock(&q->mq_freeze_lock);
152151
if (queue_is_mq(q))
153152
blk_mq_run_hw_queues(q, false);
153+
} else {
154+
mutex_unlock(&q->mq_freeze_lock);
154155
}
155156
}
156157
EXPORT_SYMBOL_GPL(blk_freeze_queue_start);
@@ -199,14 +200,14 @@ EXPORT_SYMBOL_GPL(blk_mq_freeze_queue);
199200

200201
void blk_mq_unfreeze_queue(struct request_queue *q)
201202
{
202-
int freeze_depth;
203-
204-
freeze_depth = atomic_dec_return(&q->mq_freeze_depth);
205-
WARN_ON_ONCE(freeze_depth < 0);
206-
if (!freeze_depth) {
203+
mutex_lock(&q->mq_freeze_lock);
204+
q->mq_freeze_depth--;
205+
WARN_ON_ONCE(q->mq_freeze_depth < 0);
206+
if (!q->mq_freeze_depth) {
207207
percpu_ref_resurrect(&q->q_usage_counter);
208208
wake_up_all(&q->mq_freeze_wq);
209209
}
210+
mutex_unlock(&q->mq_freeze_lock);
210211
}
211212
EXPORT_SYMBOL_GPL(blk_mq_unfreeze_queue);
212213

block/blk-settings.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,9 @@ void blk_queue_max_segment_size(struct request_queue *q, unsigned int max_size)
310310
__func__, max_size);
311311
}
312312

313+
/* see blk_queue_virt_boundary() for the explanation */
314+
WARN_ON_ONCE(q->limits.virt_boundary_mask);
315+
313316
q->limits.max_segment_size = max_size;
314317
}
315318
EXPORT_SYMBOL(blk_queue_max_segment_size);
@@ -742,6 +745,14 @@ EXPORT_SYMBOL(blk_queue_segment_boundary);
742745
void blk_queue_virt_boundary(struct request_queue *q, unsigned long mask)
743746
{
744747
q->limits.virt_boundary_mask = mask;
748+
749+
/*
750+
* Devices that require a virtual boundary do not support scatter/gather
751+
* I/O natively, but instead require a descriptor list entry for each
752+
* page (which might not be idential to the Linux PAGE_SIZE). Because
753+
* of that they are not limited by our notion of "segment size".
754+
*/
755+
q->limits.max_segment_size = UINT_MAX;
745756
}
746757
EXPORT_SYMBOL(blk_queue_virt_boundary);
747758

0 commit comments

Comments
 (0)