Skip to content

Commit 0a4b6e2

Browse files
committed
Merge branch 'for-4.16/block' of git://git.kernel.dk/linux-block
Pull block updates from Jens Axboe: "This is the main pull request for block IO related changes for the 4.16 kernel. Nothing major in this pull request, but a good amount of improvements and fixes all over the map. This contains: - BFQ improvements, fixes, and cleanups from Angelo, Chiara, and Paolo. - Support for SMR zones for deadline and mq-deadline from Damien and Christoph. - Set of fixes for bcache by way of Michael Lyle, including fixes from himself, Kent, Rui, Tang, and Coly. - Series from Matias for lightnvm with fixes from Hans Holmberg, Javier, and Matias. Mostly centered around pblk, and the removing rrpc 1.2 in preparation for supporting 2.0. - A couple of NVMe pull requests from Christoph. Nothing major in here, just fixes and cleanups, and support for command tracing from Johannes. - Support for blk-throttle for tracking reads and writes separately. From Joseph Qi. A few cleanups/fixes also for blk-throttle from Weiping. - Series from Mike Snitzer that enables dm to register its queue more logically, something that's alwways been problematic on dm since it's a stacked device. - Series from Ming cleaning up some of the bio accessor use, in preparation for supporting multipage bvecs. - Various fixes from Ming closing up holes around queue mapping and quiescing. - BSD partition fix from Richard Narron, fixing a problem where we can't mount newer (10/11) FreeBSD partitions. - Series from Tejun reworking blk-mq timeout handling. The previous scheme relied on atomic bits, but it had races where we would think a request had timed out if it to reused at the wrong time. - null_blk now supports faking timeouts, to enable us to better exercise and test that functionality separately. From me. - Kill the separate atomic poll bit in the request struct. After this, we don't use the atomic bits on blk-mq anymore at all. From me. - sgl_alloc/free helpers from Bart. - Heavily contended tag case scalability improvement from me. - Various little fixes and cleanups from Arnd, Bart, Corentin, Douglas, Eryu, Goldwyn, and myself" * 'for-4.16/block' of git://git.kernel.dk/linux-block: (186 commits) block: remove smart1,2.h nvme: add tracepoint for nvme_complete_rq nvme: add tracepoint for nvme_setup_cmd nvme-pci: introduce RECONNECTING state to mark initializing procedure nvme-rdma: remove redundant boolean for inline_data nvme: don't free uuid pointer before printing it nvme-pci: Suspend queues after deleting them bsg: use pr_debug instead of hand crafted macros blk-mq-debugfs: don't allow write on attributes with seq_operations set nvme-pci: Fix queue double allocations block: Set BIO_TRACE_COMPLETION on new bio during split blk-throttle: use queue_is_rq_based block: Remove kblockd_schedule_delayed_work{,_on}() blk-mq: Avoid that blk_mq_delay_run_hw_queue() introduces unintended delays blk-mq: Rename blk_mq_request_direct_issue() into blk_mq_request_issue_directly() lib/scatterlist: Fix chaining support in sgl_alloc_order() blk-throttle: track read and write request individually block: add bdev_read_only() checks to common helpers block: fail op_is_write() requests to read-only partitions blk-throttle: export io_serviced_recursive, io_service_bytes_recursive ...
2 parents 9697e9d + 796baee commit 0a4b6e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+3884
-4729
lines changed

block/bfq-cgroup.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,10 +775,11 @@ static void bfq_pd_offline(struct blkg_policy_data *pd)
775775
unsigned long flags;
776776
int i;
777777

778+
spin_lock_irqsave(&bfqd->lock, flags);
779+
778780
if (!entity) /* root group */
779-
return;
781+
goto put_async_queues;
780782

781-
spin_lock_irqsave(&bfqd->lock, flags);
782783
/*
783784
* Empty all service_trees belonging to this group before
784785
* deactivating the group itself.
@@ -809,6 +810,8 @@ static void bfq_pd_offline(struct blkg_policy_data *pd)
809810
}
810811

811812
__bfq_deactivate_entity(entity, false);
813+
814+
put_async_queues:
812815
bfq_put_async_queues(bfqd, bfqg);
813816

814817
spin_unlock_irqrestore(&bfqd->lock, flags);

block/bfq-iosched.c

Lines changed: 374 additions & 155 deletions
Large diffs are not rendered by default.

block/bfq-iosched.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,20 @@ struct bfq_queue {
337337
* last transition from idle to backlogged.
338338
*/
339339
unsigned long service_from_backlogged;
340+
/*
341+
* Cumulative service received from the @bfq_queue since its
342+
* last transition to weight-raised state.
343+
*/
344+
unsigned long service_from_wr;
340345

341346
/*
342347
* Value of wr start time when switching to soft rt
343348
*/
344349
unsigned long wr_start_at_switch_to_srt;
345350

346351
unsigned long split_time; /* time of last split */
352+
353+
unsigned long first_IO_time; /* time of first I/O for this queue */
347354
};
348355

349356
/**
@@ -627,6 +634,18 @@ struct bfq_data {
627634
struct bfq_io_cq *bio_bic;
628635
/* bfqq associated with the task issuing current bio for merging */
629636
struct bfq_queue *bio_bfqq;
637+
638+
/*
639+
* Cached sbitmap shift, used to compute depth limits in
640+
* bfq_update_depths.
641+
*/
642+
unsigned int sb_shift;
643+
644+
/*
645+
* Depth limits used in bfq_limit_depth (see comments on the
646+
* function)
647+
*/
648+
unsigned int word_depths[2][2];
630649
};
631650

632651
enum bfqq_state_flags {

block/bfq-wf2q.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,13 @@ void bfq_bfqq_served(struct bfq_queue *bfqq, int served)
835835
struct bfq_entity *entity = &bfqq->entity;
836836
struct bfq_service_tree *st;
837837

838+
if (!bfqq->service_from_backlogged)
839+
bfqq->first_IO_time = jiffies;
840+
841+
if (bfqq->wr_coeff > 1)
842+
bfqq->service_from_wr += served;
843+
844+
bfqq->service_from_backlogged += served;
838845
for_each_entity(entity) {
839846
st = bfq_entity_service_tree(entity);
840847

block/bio-integrity.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,6 @@ static void bio_integrity_verify_fn(struct work_struct *work)
374374
/**
375375
* __bio_integrity_endio - Integrity I/O completion function
376376
* @bio: Protected bio
377-
* @error: Pointer to errno
378377
*
379378
* Description: Completion for integrity I/O
380379
*

block/bio.c

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -970,34 +970,6 @@ void bio_advance(struct bio *bio, unsigned bytes)
970970
}
971971
EXPORT_SYMBOL(bio_advance);
972972

973-
/**
974-
* bio_alloc_pages - allocates a single page for each bvec in a bio
975-
* @bio: bio to allocate pages for
976-
* @gfp_mask: flags for allocation
977-
*
978-
* Allocates pages up to @bio->bi_vcnt.
979-
*
980-
* Returns 0 on success, -ENOMEM on failure. On failure, any allocated pages are
981-
* freed.
982-
*/
983-
int bio_alloc_pages(struct bio *bio, gfp_t gfp_mask)
984-
{
985-
int i;
986-
struct bio_vec *bv;
987-
988-
bio_for_each_segment_all(bv, bio, i) {
989-
bv->bv_page = alloc_page(gfp_mask);
990-
if (!bv->bv_page) {
991-
while (--bv >= bio->bi_io_vec)
992-
__free_page(bv->bv_page);
993-
return -ENOMEM;
994-
}
995-
}
996-
997-
return 0;
998-
}
999-
EXPORT_SYMBOL(bio_alloc_pages);
1000-
1001973
/**
1002974
* bio_copy_data - copy contents of data buffers from one chain of bios to
1003975
* another
@@ -1838,7 +1810,7 @@ struct bio *bio_split(struct bio *bio, int sectors,
18381810
bio_advance(bio, split->bi_iter.bi_size);
18391811

18401812
if (bio_flagged(bio, BIO_TRACE_COMPLETION))
1841-
bio_set_flag(bio, BIO_TRACE_COMPLETION);
1813+
bio_set_flag(split, BIO_TRACE_COMPLETION);
18421814

18431815
return split;
18441816
}

block/blk-core.c

Lines changed: 52 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ void blk_rq_init(struct request_queue *q, struct request *rq)
126126
rq->start_time = jiffies;
127127
set_start_time_ns(rq);
128128
rq->part = NULL;
129+
seqcount_init(&rq->gstate_seq);
130+
u64_stats_init(&rq->aborted_gstate_sync);
129131
}
130132
EXPORT_SYMBOL(blk_rq_init);
131133

@@ -699,6 +701,15 @@ void blk_cleanup_queue(struct request_queue *q)
699701
queue_flag_set(QUEUE_FLAG_DEAD, q);
700702
spin_unlock_irq(lock);
701703

704+
/*
705+
* make sure all in-progress dispatch are completed because
706+
* blk_freeze_queue() can only complete all requests, and
707+
* dispatch may still be in-progress since we dispatch requests
708+
* from more than one contexts
709+
*/
710+
if (q->mq_ops)
711+
blk_mq_quiesce_queue(q);
712+
702713
/* for synchronous bio-based driver finish in-flight integrity i/o */
703714
blk_flush_integrity();
704715

@@ -1646,6 +1657,7 @@ void __blk_put_request(struct request_queue *q, struct request *req)
16461657

16471658
lockdep_assert_held(q->queue_lock);
16481659

1660+
blk_req_zone_write_unlock(req);
16491661
blk_pm_put_request(req);
16501662

16511663
elv_completed_request(q, req);
@@ -2055,6 +2067,21 @@ static inline bool should_fail_request(struct hd_struct *part,
20552067

20562068
#endif /* CONFIG_FAIL_MAKE_REQUEST */
20572069

2070+
static inline bool bio_check_ro(struct bio *bio, struct hd_struct *part)
2071+
{
2072+
if (part->policy && op_is_write(bio_op(bio))) {
2073+
char b[BDEVNAME_SIZE];
2074+
2075+
printk(KERN_ERR
2076+
"generic_make_request: Trying to write "
2077+
"to read-only block-device %s (partno %d)\n",
2078+
bio_devname(bio, b), part->partno);
2079+
return true;
2080+
}
2081+
2082+
return false;
2083+
}
2084+
20582085
/*
20592086
* Remap block n of partition p to block n+start(p) of the disk.
20602087
*/
@@ -2063,27 +2090,28 @@ static inline int blk_partition_remap(struct bio *bio)
20632090
struct hd_struct *p;
20642091
int ret = 0;
20652092

2093+
rcu_read_lock();
2094+
p = __disk_get_part(bio->bi_disk, bio->bi_partno);
2095+
if (unlikely(!p || should_fail_request(p, bio->bi_iter.bi_size) ||
2096+
bio_check_ro(bio, p))) {
2097+
ret = -EIO;
2098+
goto out;
2099+
}
2100+
20662101
/*
20672102
* Zone reset does not include bi_size so bio_sectors() is always 0.
20682103
* Include a test for the reset op code and perform the remap if needed.
20692104
*/
2070-
if (!bio->bi_partno ||
2071-
(!bio_sectors(bio) && bio_op(bio) != REQ_OP_ZONE_RESET))
2072-
return 0;
2105+
if (!bio_sectors(bio) && bio_op(bio) != REQ_OP_ZONE_RESET)
2106+
goto out;
20732107

2074-
rcu_read_lock();
2075-
p = __disk_get_part(bio->bi_disk, bio->bi_partno);
2076-
if (likely(p && !should_fail_request(p, bio->bi_iter.bi_size))) {
2077-
bio->bi_iter.bi_sector += p->start_sect;
2078-
bio->bi_partno = 0;
2079-
trace_block_bio_remap(bio->bi_disk->queue, bio, part_devt(p),
2080-
bio->bi_iter.bi_sector - p->start_sect);
2081-
} else {
2082-
printk("%s: fail for partition %d\n", __func__, bio->bi_partno);
2083-
ret = -EIO;
2084-
}
2085-
rcu_read_unlock();
2108+
bio->bi_iter.bi_sector += p->start_sect;
2109+
bio->bi_partno = 0;
2110+
trace_block_bio_remap(bio->bi_disk->queue, bio, part_devt(p),
2111+
bio->bi_iter.bi_sector - p->start_sect);
20862112

2113+
out:
2114+
rcu_read_unlock();
20872115
return ret;
20882116
}
20892117

@@ -2142,15 +2170,19 @@ generic_make_request_checks(struct bio *bio)
21422170
* For a REQ_NOWAIT based request, return -EOPNOTSUPP
21432171
* if queue is not a request based queue.
21442172
*/
2145-
21462173
if ((bio->bi_opf & REQ_NOWAIT) && !queue_is_rq_based(q))
21472174
goto not_supported;
21482175

21492176
if (should_fail_request(&bio->bi_disk->part0, bio->bi_iter.bi_size))
21502177
goto end_io;
21512178

2152-
if (blk_partition_remap(bio))
2153-
goto end_io;
2179+
if (!bio->bi_partno) {
2180+
if (unlikely(bio_check_ro(bio, &bio->bi_disk->part0)))
2181+
goto end_io;
2182+
} else {
2183+
if (blk_partition_remap(bio))
2184+
goto end_io;
2185+
}
21542186

21552187
if (bio_check_eod(bio, nr_sectors))
21562188
goto end_io;
@@ -2493,8 +2525,7 @@ blk_status_t blk_insert_cloned_request(struct request_queue *q, struct request *
24932525
* bypass a potential scheduler on the bottom device for
24942526
* insert.
24952527
*/
2496-
blk_mq_request_bypass_insert(rq, true);
2497-
return BLK_STS_OK;
2528+
return blk_mq_request_issue_directly(rq);
24982529
}
24992530

25002531
spin_lock_irqsave(q->queue_lock, flags);
@@ -2846,7 +2877,7 @@ void blk_start_request(struct request *req)
28462877
wbt_issue(req->q->rq_wb, &req->issue_stat);
28472878
}
28482879

2849-
BUG_ON(test_bit(REQ_ATOM_COMPLETE, &req->atomic_flags));
2880+
BUG_ON(blk_rq_is_complete(req));
28502881
blk_add_timer(req);
28512882
}
28522883
EXPORT_SYMBOL(blk_start_request);
@@ -3415,20 +3446,6 @@ int kblockd_mod_delayed_work_on(int cpu, struct delayed_work *dwork,
34153446
}
34163447
EXPORT_SYMBOL(kblockd_mod_delayed_work_on);
34173448

3418-
int kblockd_schedule_delayed_work(struct delayed_work *dwork,
3419-
unsigned long delay)
3420-
{
3421-
return queue_delayed_work(kblockd_workqueue, dwork, delay);
3422-
}
3423-
EXPORT_SYMBOL(kblockd_schedule_delayed_work);
3424-
3425-
int kblockd_schedule_delayed_work_on(int cpu, struct delayed_work *dwork,
3426-
unsigned long delay)
3427-
{
3428-
return queue_delayed_work_on(cpu, kblockd_workqueue, dwork, delay);
3429-
}
3430-
EXPORT_SYMBOL(kblockd_schedule_delayed_work_on);
3431-
34323449
/**
34333450
* blk_start_plug - initialize blk_plug and track it inside the task_struct
34343451
* @plug: The &struct blk_plug that needs to be initialized

block/blk-exec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk,
6161
* be reused after dying flag is set
6262
*/
6363
if (q->mq_ops) {
64-
blk_mq_sched_insert_request(rq, at_head, true, false, false);
64+
blk_mq_sched_insert_request(rq, at_head, true, false);
6565
return;
6666
}
6767

block/blk-lib.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
3737
if (!q)
3838
return -ENXIO;
3939

40+
if (bdev_read_only(bdev))
41+
return -EPERM;
42+
4043
if (flags & BLKDEV_DISCARD_SECURE) {
4144
if (!blk_queue_secure_erase(q))
4245
return -EOPNOTSUPP;
@@ -156,6 +159,9 @@ static int __blkdev_issue_write_same(struct block_device *bdev, sector_t sector,
156159
if (!q)
157160
return -ENXIO;
158161

162+
if (bdev_read_only(bdev))
163+
return -EPERM;
164+
159165
bs_mask = (bdev_logical_block_size(bdev) >> 9) - 1;
160166
if ((sector | nr_sects) & bs_mask)
161167
return -EINVAL;
@@ -233,6 +239,9 @@ static int __blkdev_issue_write_zeroes(struct block_device *bdev,
233239
if (!q)
234240
return -ENXIO;
235241

242+
if (bdev_read_only(bdev))
243+
return -EPERM;
244+
236245
/* Ensure that max_write_zeroes_sectors doesn't overflow bi_size */
237246
max_write_zeroes_sectors = bdev_write_zeroes_sectors(bdev);
238247

@@ -287,6 +296,9 @@ static int __blkdev_issue_zero_pages(struct block_device *bdev,
287296
if (!q)
288297
return -ENXIO;
289298

299+
if (bdev_read_only(bdev))
300+
return -EPERM;
301+
290302
while (nr_sects != 0) {
291303
bio = next_bio(bio, __blkdev_sectors_to_bio_pages(nr_sects),
292304
gfp_mask);

block/blk-map.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
119119
unsigned long align = q->dma_pad_mask | queue_dma_alignment(q);
120120
struct bio *bio = NULL;
121121
struct iov_iter i;
122-
int ret;
122+
int ret = -EINVAL;
123123

124124
if (!iter_is_iovec(iter))
125125
goto fail;
@@ -148,7 +148,7 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
148148
__blk_rq_unmap_user(bio);
149149
fail:
150150
rq->bio = NULL;
151-
return -EINVAL;
151+
return ret;
152152
}
153153
EXPORT_SYMBOL(blk_rq_map_user_iov);
154154

0 commit comments

Comments
 (0)