Skip to content

Commit b8517e9

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.dk/linux-block
Pull block layer fixes from Jens Axboe: "A small collection of fixes that has been gathered over the last few weeks. This contains: - A one-liner fix for NVMe, fixing a missing list_head init that could makes us oops on hitting recovery at load time. - Two small blk-mq fixes: - Fixup a bad goto jump on error handling. - Fix for oopsing if running out of reserved tags. - A memory leak fix for NBD. - Two small writeback fixes from Tejun, fixing a missing init to INITIAL_JIFFIES, and a possible underflow introduced recently. - A core merge fixup in sg gap detection, where rq->biotail was indexed with the count of rq->bio" * 'for-linus' of git://git.kernel.dk/linux-block: writeback: fix possible underflow in write bandwidth calculation NVMe: Initialize device list head before starting Fix bug in blk_rq_merge_ok blkmq: Fix NULL pointer deref when all reserved tags in blk-mq: fix use of incorrect goto label in blk_mq_init_queue error path nbd: fix possible memory leak writeback: add missing INITIAL_JIFFIES init in global_update_bandwidth()
2 parents c875f42 + c72efb6 commit b8517e9

File tree

6 files changed

+18
-12
lines changed

6 files changed

+18
-12
lines changed

block/blk-merge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio)
592592
if (q->queue_flags & (1 << QUEUE_FLAG_SG_GAPS)) {
593593
struct bio_vec *bprev;
594594

595-
bprev = &rq->biotail->bi_io_vec[bio->bi_vcnt - 1];
595+
bprev = &rq->biotail->bi_io_vec[rq->biotail->bi_vcnt - 1];
596596
if (bvec_gap_to_prev(bprev, bio->bi_io_vec[0].bv_offset))
597597
return false;
598598
}

block/blk-mq-tag.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,11 @@ static int bt_get(struct blk_mq_alloc_data *data,
278278
/*
279279
* We're out of tags on this hardware queue, kick any
280280
* pending IO submits before going to sleep waiting for
281-
* some to complete.
281+
* some to complete. Note that hctx can be NULL here for
282+
* reserved tag allocation.
282283
*/
283-
blk_mq_run_hw_queue(hctx, false);
284+
if (hctx)
285+
blk_mq_run_hw_queue(hctx, false);
284286

285287
/*
286288
* Retry tag allocation after running the hardware queue,

block/blk-mq.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,7 +1938,7 @@ struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *set)
19381938
*/
19391939
if (percpu_ref_init(&q->mq_usage_counter, blk_mq_usage_counter_release,
19401940
PERCPU_REF_INIT_ATOMIC, GFP_KERNEL))
1941-
goto err_map;
1941+
goto err_mq_usage;
19421942

19431943
setup_timer(&q->timeout, blk_mq_rq_timer, (unsigned long) q);
19441944
blk_queue_rq_timeout(q, 30000);
@@ -1981,7 +1981,7 @@ struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *set)
19811981
blk_mq_init_cpu_queues(q, set->nr_hw_queues);
19821982

19831983
if (blk_mq_init_hw_queues(q, set))
1984-
goto err_hw;
1984+
goto err_mq_usage;
19851985

19861986
mutex_lock(&all_q_mutex);
19871987
list_add_tail(&q->all_q_node, &all_q_list);
@@ -1993,7 +1993,7 @@ struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *set)
19931993

19941994
return q;
19951995

1996-
err_hw:
1996+
err_mq_usage:
19971997
blk_cleanup_queue(q);
19981998
err_hctxs:
19991999
kfree(map);

drivers/block/nbd.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -803,10 +803,6 @@ static int __init nbd_init(void)
803803
return -EINVAL;
804804
}
805805

806-
nbd_dev = kcalloc(nbds_max, sizeof(*nbd_dev), GFP_KERNEL);
807-
if (!nbd_dev)
808-
return -ENOMEM;
809-
810806
part_shift = 0;
811807
if (max_part > 0) {
812808
part_shift = fls(max_part);
@@ -828,6 +824,10 @@ static int __init nbd_init(void)
828824
if (nbds_max > 1UL << (MINORBITS - part_shift))
829825
return -EINVAL;
830826

827+
nbd_dev = kcalloc(nbds_max, sizeof(*nbd_dev), GFP_KERNEL);
828+
if (!nbd_dev)
829+
return -ENOMEM;
830+
831831
for (i = 0; i < nbds_max; i++) {
832832
struct gendisk *disk = alloc_disk(1 << part_shift);
833833
if (!disk)

drivers/block/nvme-core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3003,6 +3003,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
30033003
}
30043004
get_device(dev->device);
30053005

3006+
INIT_LIST_HEAD(&dev->node);
30063007
INIT_WORK(&dev->probe_work, nvme_async_probe);
30073008
schedule_work(&dev->probe_work);
30083009
return 0;

mm/page-writeback.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -857,8 +857,11 @@ static void bdi_update_write_bandwidth(struct backing_dev_info *bdi,
857857
* bw * elapsed + write_bandwidth * (period - elapsed)
858858
* write_bandwidth = ---------------------------------------------------
859859
* period
860+
*
861+
* @written may have decreased due to account_page_redirty().
862+
* Avoid underflowing @bw calculation.
860863
*/
861-
bw = written - bdi->written_stamp;
864+
bw = written - min(written, bdi->written_stamp);
862865
bw *= HZ;
863866
if (unlikely(elapsed > period)) {
864867
do_div(bw, elapsed);
@@ -922,7 +925,7 @@ static void global_update_bandwidth(unsigned long thresh,
922925
unsigned long now)
923926
{
924927
static DEFINE_SPINLOCK(dirty_lock);
925-
static unsigned long update_time;
928+
static unsigned long update_time = INITIAL_JIFFIES;
926929

927930
/*
928931
* check locklessly first to optimize away locking for the most time

0 commit comments

Comments
 (0)