Skip to content

Commit 3ab6608

Browse files
committed
Merge tag 'block-5.12-2021-02-27' of git://git.kernel.dk/linux-block
Pull more block updates from Jens Axboe: "A few stragglers (and one due to me missing it originally), and fixes for changes in this merge window mostly. In particular: - blktrace cleanups (Chaitanya, Greg) - Kill dead blk_pm_* functions (Bart) - Fixes for the bio alloc changes (Christoph) - Fix for the partition changes (Christoph, Ming) - Fix for turning off iopoll with polled IO inflight (Jeffle) - nbd disconnect fix (Josef) - loop fsync error fix (Mauricio) - kyber update depth fix (Yang) - max_sectors alignment fix (Mikulas) - Add bio_max_segs helper (Matthew)" * tag 'block-5.12-2021-02-27' of git://git.kernel.dk/linux-block: (21 commits) block: Add bio_max_segs blktrace: fix documentation for blk_fill_rw() block: memory allocations in bounce_clone_bio must not fail block: remove the gfp_mask argument to bounce_clone_bio block: fix bounce_clone_bio for passthrough bios block-crypto-fallback: use a bio_set for splitting bios block: fix logging on capacity change blk-settings: align max_sectors on "logical_block_size" boundary block: reopen the device in blkdev_reread_part block: don't skip empty device in in disk_uevent blktrace: remove debugfs file dentries from struct blk_trace nbd: handle device refs for DESTROY_ON_DISCONNECT properly kyber: introduce kyber_depth_updated() loop: fix I/O error on fsync() in detached loop devices block: fix potential IO hang when turning off io_poll block: get rid of the trace rq insert wrapper blktrace: fix blk_rq_merge documentation blktrace: fix blk_rq_issue documentation blktrace: add blk_fill_rwbs documentation comment block: remove superfluous param in blk_fill_rwbs() ...
2 parents 5695e51 + 5f7136d commit 3ab6608

40 files changed

Lines changed: 173 additions & 180 deletions

block/bfq-iosched.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@
125125
#include <linux/delay.h>
126126
#include <linux/backing-dev.h>
127127

128+
#include <trace/events/block.h>
129+
128130
#include "blk.h"
129131
#include "blk-mq.h"
130132
#include "blk-mq-tag.h"
@@ -5621,7 +5623,7 @@ static void bfq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
56215623

56225624
spin_unlock_irq(&bfqd->lock);
56235625

5624-
blk_mq_sched_request_inserted(rq);
5626+
trace_block_rq_insert(rq);
56255627

56265628
spin_lock_irq(&bfqd->lock);
56275629
bfqq = bfq_init_rq(rq);

block/blk-core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(block_rq_remap);
5959
EXPORT_TRACEPOINT_SYMBOL_GPL(block_bio_complete);
6060
EXPORT_TRACEPOINT_SYMBOL_GPL(block_split);
6161
EXPORT_TRACEPOINT_SYMBOL_GPL(block_unplug);
62+
EXPORT_TRACEPOINT_SYMBOL_GPL(block_rq_insert);
6263

6364
DEFINE_IDA(blk_queue_ida);
6465

block/blk-crypto-fallback.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ static struct blk_crypto_keyslot {
8080
static struct blk_keyslot_manager blk_crypto_ksm;
8181
static struct workqueue_struct *blk_crypto_wq;
8282
static mempool_t *blk_crypto_bounce_page_pool;
83+
static struct bio_set crypto_bio_split;
8384

8485
/*
8586
* This is the key we set when evicting a keyslot. This *should* be the all 0's
@@ -224,7 +225,8 @@ static bool blk_crypto_split_bio_if_needed(struct bio **bio_ptr)
224225
if (num_sectors < bio_sectors(bio)) {
225226
struct bio *split_bio;
226227

227-
split_bio = bio_split(bio, num_sectors, GFP_NOIO, NULL);
228+
split_bio = bio_split(bio, num_sectors, GFP_NOIO,
229+
&crypto_bio_split);
228230
if (!split_bio) {
229231
bio->bi_status = BLK_STS_RESOURCE;
230232
return false;
@@ -538,9 +540,13 @@ static int blk_crypto_fallback_init(void)
538540

539541
prandom_bytes(blank_key, BLK_CRYPTO_MAX_KEY_SIZE);
540542

541-
err = blk_ksm_init(&blk_crypto_ksm, blk_crypto_num_keyslots);
543+
err = bioset_init(&crypto_bio_split, 64, 0, 0);
542544
if (err)
543545
goto out;
546+
547+
err = blk_ksm_init(&blk_crypto_ksm, blk_crypto_num_keyslots);
548+
if (err)
549+
goto fail_free_bioset;
544550
err = -ENOMEM;
545551

546552
blk_crypto_ksm.ksm_ll_ops = blk_crypto_ksm_ll_ops;
@@ -591,6 +597,8 @@ static int blk_crypto_fallback_init(void)
591597
destroy_workqueue(blk_crypto_wq);
592598
fail_free_ksm:
593599
blk_ksm_destroy(&blk_crypto_ksm);
600+
fail_free_bioset:
601+
bioset_exit(&crypto_bio_split);
594602
out:
595603
return err;
596604
}

block/blk-map.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,7 @@ static int bio_copy_user_iov(struct request *rq, struct rq_map_data *map_data,
150150
bmd->is_our_pages = !map_data;
151151
bmd->is_null_mapped = (map_data && map_data->null_mapped);
152152

153-
nr_pages = DIV_ROUND_UP(offset + len, PAGE_SIZE);
154-
if (nr_pages > BIO_MAX_PAGES)
155-
nr_pages = BIO_MAX_PAGES;
153+
nr_pages = bio_max_segs(DIV_ROUND_UP(offset + len, PAGE_SIZE));
156154

157155
ret = -ENOMEM;
158156
bio = bio_kmalloc(gfp_mask, nr_pages);

block/blk-mq-sched.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -384,12 +384,6 @@ bool blk_mq_sched_try_insert_merge(struct request_queue *q, struct request *rq)
384384
}
385385
EXPORT_SYMBOL_GPL(blk_mq_sched_try_insert_merge);
386386

387-
void blk_mq_sched_request_inserted(struct request *rq)
388-
{
389-
trace_block_rq_insert(rq);
390-
}
391-
EXPORT_SYMBOL_GPL(blk_mq_sched_request_inserted);
392-
393387
static bool blk_mq_sched_bypass_insert(struct blk_mq_hw_ctx *hctx,
394388
bool has_sched,
395389
struct request *rq)

block/blk-mq-sched.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
void blk_mq_sched_assign_ioc(struct request *rq);
99

10-
void blk_mq_sched_request_inserted(struct request *rq);
1110
bool blk_mq_sched_try_merge(struct request_queue *q, struct bio *bio,
1211
unsigned int nr_segs, struct request **merged_request);
1312
bool __blk_mq_sched_bio_merge(struct request_queue *q, struct bio *bio,

block/blk-pm.h

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,6 @@ static inline void blk_pm_mark_last_busy(struct request *rq)
2121
if (rq->q->dev && !(rq->rq_flags & RQF_PM))
2222
pm_runtime_mark_last_busy(rq->q->dev);
2323
}
24-
25-
static inline void blk_pm_requeue_request(struct request *rq)
26-
{
27-
lockdep_assert_held(&rq->q->queue_lock);
28-
29-
if (rq->q->dev && !(rq->rq_flags & RQF_PM))
30-
rq->q->nr_pending--;
31-
}
32-
33-
static inline void blk_pm_add_request(struct request_queue *q,
34-
struct request *rq)
35-
{
36-
lockdep_assert_held(&q->queue_lock);
37-
38-
if (q->dev && !(rq->rq_flags & RQF_PM))
39-
q->nr_pending++;
40-
}
41-
42-
static inline void blk_pm_put_request(struct request *rq)
43-
{
44-
lockdep_assert_held(&rq->q->queue_lock);
45-
46-
if (rq->q->dev && !(rq->rq_flags & RQF_PM))
47-
--rq->q->nr_pending;
48-
}
4924
#else
5025
static inline int blk_pm_resume_queue(const bool pm, struct request_queue *q)
5126
{
@@ -55,19 +30,6 @@ static inline int blk_pm_resume_queue(const bool pm, struct request_queue *q)
5530
static inline void blk_pm_mark_last_busy(struct request *rq)
5631
{
5732
}
58-
59-
static inline void blk_pm_requeue_request(struct request *rq)
60-
{
61-
}
62-
63-
static inline void blk_pm_add_request(struct request_queue *q,
64-
struct request *rq)
65-
{
66-
}
67-
68-
static inline void blk_pm_put_request(struct request *rq)
69-
{
70-
}
7133
#endif
7234

7335
#endif /* _BLOCK_BLK_PM_H_ */

block/blk-settings.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,14 @@ void blk_queue_io_opt(struct request_queue *q, unsigned int opt)
504504
}
505505
EXPORT_SYMBOL(blk_queue_io_opt);
506506

507+
static unsigned int blk_round_down_sectors(unsigned int sectors, unsigned int lbs)
508+
{
509+
sectors = round_down(sectors, lbs >> SECTOR_SHIFT);
510+
if (sectors < PAGE_SIZE >> SECTOR_SHIFT)
511+
sectors = PAGE_SIZE >> SECTOR_SHIFT;
512+
return sectors;
513+
}
514+
507515
/**
508516
* blk_stack_limits - adjust queue_limits for stacked devices
509517
* @t: the stacking driver limits (top device)
@@ -630,6 +638,10 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
630638
ret = -1;
631639
}
632640

641+
t->max_sectors = blk_round_down_sectors(t->max_sectors, t->logical_block_size);
642+
t->max_hw_sectors = blk_round_down_sectors(t->max_hw_sectors, t->logical_block_size);
643+
t->max_dev_sectors = blk_round_down_sectors(t->max_dev_sectors, t->logical_block_size);
644+
633645
/* Discard alignment and granularity */
634646
if (b->discard_granularity) {
635647
alignment = queue_limit_discard_alignment(b, start);

block/blk-sysfs.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,10 +434,13 @@ static ssize_t queue_poll_store(struct request_queue *q, const char *page,
434434
if (ret < 0)
435435
return ret;
436436

437-
if (poll_on)
437+
if (poll_on) {
438438
blk_queue_flag_set(QUEUE_FLAG_POLL, q);
439-
else
439+
} else {
440+
blk_mq_freeze_queue(q);
440441
blk_queue_flag_clear(QUEUE_FLAG_POLL, q);
442+
blk_mq_unfreeze_queue(q);
443+
}
441444

442445
return ret;
443446
}

block/bounce.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,7 @@ static void bounce_end_io_read_isa(struct bio *bio)
214214
__bounce_end_io_read(bio, &isa_page_pool);
215215
}
216216

217-
static struct bio *bounce_clone_bio(struct bio *bio_src, gfp_t gfp_mask,
218-
struct bio_set *bs)
217+
static struct bio *bounce_clone_bio(struct bio *bio_src)
219218
{
220219
struct bvec_iter iter;
221220
struct bio_vec bv;
@@ -242,10 +241,12 @@ static struct bio *bounce_clone_bio(struct bio *bio_src, gfp_t gfp_mask,
242241
* asking for trouble and would force extra work on
243242
* __bio_clone_fast() anyways.
244243
*/
245-
246-
bio = bio_alloc_bioset(gfp_mask, bio_segments(bio_src), bs);
247-
if (!bio)
248-
return NULL;
244+
if (bio_is_passthrough(bio_src))
245+
bio = bio_kmalloc(GFP_NOIO | __GFP_NOFAIL,
246+
bio_segments(bio_src));
247+
else
248+
bio = bio_alloc_bioset(GFP_NOIO, bio_segments(bio_src),
249+
&bounce_bio_set);
249250
bio->bi_bdev = bio_src->bi_bdev;
250251
if (bio_flagged(bio_src, BIO_REMAPPED))
251252
bio_set_flag(bio, BIO_REMAPPED);
@@ -269,11 +270,11 @@ static struct bio *bounce_clone_bio(struct bio *bio_src, gfp_t gfp_mask,
269270
break;
270271
}
271272

272-
if (bio_crypt_clone(bio, bio_src, gfp_mask) < 0)
273+
if (bio_crypt_clone(bio, bio_src, GFP_NOIO) < 0)
273274
goto err_put;
274275

275276
if (bio_integrity(bio_src) &&
276-
bio_integrity_clone(bio, bio_src, gfp_mask) < 0)
277+
bio_integrity_clone(bio, bio_src, GFP_NOIO) < 0)
277278
goto err_put;
278279

279280
bio_clone_blkg_association(bio, bio_src);
@@ -296,7 +297,6 @@ static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig,
296297
unsigned i = 0;
297298
bool bounce = false;
298299
int sectors = 0;
299-
bool passthrough = bio_is_passthrough(*bio_orig);
300300

301301
bio_for_each_segment(from, *bio_orig, iter) {
302302
if (i++ < BIO_MAX_PAGES)
@@ -307,14 +307,14 @@ static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig,
307307
if (!bounce)
308308
return;
309309

310-
if (!passthrough && sectors < bio_sectors(*bio_orig)) {
310+
if (!bio_is_passthrough(*bio_orig) &&
311+
sectors < bio_sectors(*bio_orig)) {
311312
bio = bio_split(*bio_orig, sectors, GFP_NOIO, &bounce_bio_split);
312313
bio_chain(bio, *bio_orig);
313314
submit_bio_noacct(*bio_orig);
314315
*bio_orig = bio;
315316
}
316-
bio = bounce_clone_bio(*bio_orig, GFP_NOIO, passthrough ? NULL :
317-
&bounce_bio_set);
317+
bio = bounce_clone_bio(*bio_orig);
318318

319319
/*
320320
* Bvec table can't be updated by bio_for_each_segment_all(),

0 commit comments

Comments
 (0)