Skip to content

Commit c6e0e87

Browse files
committed
Merge tag 'block-6.1-2022-10-28' of git://git.kernel.dk/linux
Pull block fixes from Jens Axboe: - NVMe pull request via Christoph: - make the multipath dma alignment match the non-multipath one (Keith Busch) - fix a bogus use of sg_init_marker() (Nam Cao) - fix circulr locking in nvme-tcp (Sagi Grimberg) - Initialization fix for requests allocated via the special hw queue allocator (John) - Fix for a regression added in this release with the batched completions of end_io backed requests (Ming) - Error handling leak fix for rbd (Yang) - Error handling leak fix for add_disk() failure (Yu) * tag 'block-6.1-2022-10-28' of git://git.kernel.dk/linux: blk-mq: Properly init requests from blk_mq_alloc_request_hctx() blk-mq: don't add non-pt request with ->end_io to batch rbd: fix possible memory leak in rbd_sysfs_init() nvme-multipath: set queue dma alignment to 3 nvme-tcp: fix possible circular locking when deleting a controller under memory pressure nvme-tcp: replace sg_init_marker() with sg_init_table() block: fix memory leak for elevator on add_disk failure
2 parents 4d24432 + e3c5a78 commit c6e0e87

File tree

6 files changed

+31
-9
lines changed

6 files changed

+31
-9
lines changed

block/blk-mq.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,7 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q,
611611
.nr_tags = 1,
612612
};
613613
u64 alloc_time_ns = 0;
614+
struct request *rq;
614615
unsigned int cpu;
615616
unsigned int tag;
616617
int ret;
@@ -660,8 +661,12 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q,
660661
tag = blk_mq_get_tag(&data);
661662
if (tag == BLK_MQ_NO_TAG)
662663
goto out_queue_exit;
663-
return blk_mq_rq_ctx_init(&data, blk_mq_tags_from_data(&data), tag,
664+
rq = blk_mq_rq_ctx_init(&data, blk_mq_tags_from_data(&data), tag,
664665
alloc_time_ns);
666+
rq->__data_len = 0;
667+
rq->__sector = (sector_t) -1;
668+
rq->bio = rq->biotail = NULL;
669+
return rq;
665670

666671
out_queue_exit:
667672
blk_queue_exit(q);

block/genhd.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,24 +410,25 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
410410
* Otherwise just allocate the device numbers for both the whole device
411411
* and all partitions from the extended dev_t space.
412412
*/
413+
ret = -EINVAL;
413414
if (disk->major) {
414415
if (WARN_ON(!disk->minors))
415-
return -EINVAL;
416+
goto out_exit_elevator;
416417

417418
if (disk->minors > DISK_MAX_PARTS) {
418419
pr_err("block: can't allocate more than %d partitions\n",
419420
DISK_MAX_PARTS);
420421
disk->minors = DISK_MAX_PARTS;
421422
}
422423
if (disk->first_minor + disk->minors > MINORMASK + 1)
423-
return -EINVAL;
424+
goto out_exit_elevator;
424425
} else {
425426
if (WARN_ON(disk->minors))
426-
return -EINVAL;
427+
goto out_exit_elevator;
427428

428429
ret = blk_alloc_ext_minor();
429430
if (ret < 0)
430-
return ret;
431+
goto out_exit_elevator;
431432
disk->major = BLOCK_EXT_MAJOR;
432433
disk->first_minor = ret;
433434
}
@@ -540,6 +541,9 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
540541
out_free_ext_minor:
541542
if (disk->major == BLOCK_EXT_MAJOR)
542543
blk_free_ext_minor(disk->first_minor);
544+
out_exit_elevator:
545+
if (disk->queue->elevator)
546+
elevator_exit(disk->queue);
543547
return ret;
544548
}
545549
EXPORT_SYMBOL(device_add_disk);

drivers/block/rbd.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7222,8 +7222,10 @@ static int __init rbd_sysfs_init(void)
72227222
int ret;
72237223

72247224
ret = device_register(&rbd_root_dev);
7225-
if (ret < 0)
7225+
if (ret < 0) {
7226+
put_device(&rbd_root_dev);
72267227
return ret;
7228+
}
72277229

72287230
ret = bus_register(&rbd_bus_type);
72297231
if (ret < 0)

drivers/nvme/host/multipath.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl, struct nvme_ns_head *head)
516516
/* set to a default value of 512 until the disk is validated */
517517
blk_queue_logical_block_size(head->disk->queue, 512);
518518
blk_set_stacking_limits(&head->disk->queue->limits);
519+
blk_queue_dma_alignment(head->disk->queue, 3);
519520

520521
/* we need to propagate up the VMC settings */
521522
if (ctrl->vwc & NVME_CTRL_VWC_PRESENT)

drivers/nvme/host/tcp.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ static inline void nvme_tcp_ddgst_update(struct ahash_request *hash,
387387
{
388388
struct scatterlist sg;
389389

390-
sg_init_marker(&sg, 1);
390+
sg_init_table(&sg, 1);
391391
sg_set_page(&sg, page, len, off);
392392
ahash_request_set_crypt(hash, &sg, NULL, len);
393393
crypto_ahash_update(hash);
@@ -1141,6 +1141,7 @@ static int nvme_tcp_try_send_ddgst(struct nvme_tcp_request *req)
11411141
static int nvme_tcp_try_send(struct nvme_tcp_queue *queue)
11421142
{
11431143
struct nvme_tcp_request *req;
1144+
unsigned int noreclaim_flag;
11441145
int ret = 1;
11451146

11461147
if (!queue->request) {
@@ -1150,12 +1151,13 @@ static int nvme_tcp_try_send(struct nvme_tcp_queue *queue)
11501151
}
11511152
req = queue->request;
11521153

1154+
noreclaim_flag = memalloc_noreclaim_save();
11531155
if (req->state == NVME_TCP_SEND_CMD_PDU) {
11541156
ret = nvme_tcp_try_send_cmd_pdu(req);
11551157
if (ret <= 0)
11561158
goto done;
11571159
if (!nvme_tcp_has_inline_data(req))
1158-
return ret;
1160+
goto out;
11591161
}
11601162

11611163
if (req->state == NVME_TCP_SEND_H2C_PDU) {
@@ -1181,6 +1183,8 @@ static int nvme_tcp_try_send(struct nvme_tcp_queue *queue)
11811183
nvme_tcp_fail_request(queue->request);
11821184
nvme_tcp_done_send_req(queue);
11831185
}
1186+
out:
1187+
memalloc_noreclaim_restore(noreclaim_flag);
11841188
return ret;
11851189
}
11861190

@@ -1296,6 +1300,7 @@ static void nvme_tcp_free_queue(struct nvme_ctrl *nctrl, int qid)
12961300
struct page *page;
12971301
struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl);
12981302
struct nvme_tcp_queue *queue = &ctrl->queues[qid];
1303+
unsigned int noreclaim_flag;
12991304

13001305
if (!test_and_clear_bit(NVME_TCP_Q_ALLOCATED, &queue->flags))
13011306
return;
@@ -1308,7 +1313,11 @@ static void nvme_tcp_free_queue(struct nvme_ctrl *nctrl, int qid)
13081313
__page_frag_cache_drain(page, queue->pf_cache.pagecnt_bias);
13091314
queue->pf_cache.va = NULL;
13101315
}
1316+
1317+
noreclaim_flag = memalloc_noreclaim_save();
13111318
sock_release(queue->sock);
1319+
memalloc_noreclaim_restore(noreclaim_flag);
1320+
13121321
kfree(queue->pdu);
13131322
mutex_destroy(&queue->send_mutex);
13141323
mutex_destroy(&queue->queue_lock);

include/linux/blk-mq.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,8 @@ static inline bool blk_mq_add_to_batch(struct request *req,
853853
struct io_comp_batch *iob, int ioerror,
854854
void (*complete)(struct io_comp_batch *))
855855
{
856-
if (!iob || (req->rq_flags & RQF_ELV) || ioerror)
856+
if (!iob || (req->rq_flags & RQF_ELV) || ioerror ||
857+
(req->end_io && !blk_rq_is_passthrough(req)))
857858
return false;
858859

859860
if (!iob->complete)

0 commit comments

Comments
 (0)