Skip to content

Commit 4ce01c5

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.dk/linux-block
Pull block layer fixes from Jens Axboe: "A round of fixes/updates for the current series. This looks a little bigger than it is, but that's mainly because we pushed the lightnvm enabled null_blk change out of the merge window so it could be updated a bit. The rest of the volume is also mostly lightnvm. In particular: - Lightnvm. Various fixes, additions, updates from Matias and Javier, as well as from Wenwei Tao. - NVMe: - Fix for potential arithmetic overflow from Keith. - Also from Keith, ensure that we reap pending completions from a completion queue before deleting it. Fixes kernel crashes when resetting a device with IO pending. - Various little lightnvm related tweaks from Matias. - Fixup flushes to go through the IO scheduler, for the cases where a flush is not required. Fixes a case in CFQ where we would be idling and not see this request, hence not break the idling. From Jan Kara. - Use list_{first,prev,next} in elevator.c for cleaner code. From Gelian Tang. - Fix for a warning trigger on btrfs and raid on single queue blk-mq devices, where we would flush plug callbacks with preemption disabled. From me. - A mac partition validation fix from Kees Cook. - Two merge fixes from Ming, marked stable. A third part is adding a new warning so we'll notice this quicker in the future, if we screw up the accounting. - Cleanup of thread name/creation in mtip32xx from Rasmus Villemoes" * 'for-linus' of git://git.kernel.dk/linux-block: (32 commits) blk-merge: warn if figured out segment number is bigger than nr_phys_segments blk-merge: fix blk_bio_segment_split block: fix segment split blk-mq: fix calling unplug callbacks with preempt disabled mac: validate mac_partition is within sector mtip32xx: use formatting capability of kthread_create_on_node NVMe: reap completion entries when deleting queue lightnvm: add free and bad lun info to show luns lightnvm: keep track of block counts nvme: lightnvm: use admin queues for admin cmds lightnvm: missing free on init error lightnvm: wrong return value and redundant free null_blk: do not del gendisk with lightnvm null_blk: use device addressing mode null_blk: use ppa_cache pool NVMe: Fix possible arithmetic overflow for max segments blk-flush: Queue through IO scheduler when flush not required null_blk: register as a LightNVM device elevator: use list_{first,prev,next}_entry lightnvm: cleanup queue before target removal ...
2 parents a293154 + 12e57f5 commit 4ce01c5

17 files changed

Lines changed: 525 additions & 244 deletions

File tree

Documentation/block/null_blk.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,6 @@ use_per_node_hctx=[0/1]: Default: 0
7070
parameter.
7171
1: The multi-queue block layer is instantiated with a hardware dispatch
7272
queue for each CPU node in the system.
73+
74+
use_lightnvm=[0/1]: Default: 0
75+
Register device with LightNVM. Requires blk-mq to be used.

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6366,6 +6366,7 @@ F: arch/*/include/asm/pmem.h
63666366
LIGHTNVM PLATFORM SUPPORT
63676367
M: Matias Bjorling <mb@lightnvm.io>
63686368
W: http://github/OpenChannelSSD
6369+
L: linux-block@vger.kernel.org
63696370
S: Maintained
63706371
F: drivers/lightnvm/
63716372
F: include/linux/lightnvm.h

block/blk-flush.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ void blk_insert_flush(struct request *rq)
422422
if (q->mq_ops) {
423423
blk_mq_insert_request(rq, false, false, true);
424424
} else
425-
list_add_tail(&rq->queuelist, &q->queue_head);
425+
q->elevator->type->ops.elevator_add_req_fn(q, rq);
426426
return;
427427
}
428428

block/blk-merge.c

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,
7676
struct bio_vec bv, bvprv, *bvprvp = NULL;
7777
struct bvec_iter iter;
7878
unsigned seg_size = 0, nsegs = 0, sectors = 0;
79+
unsigned front_seg_size = bio->bi_seg_front_size;
80+
bool do_split = true;
81+
struct bio *new = NULL;
7982

8083
bio_for_each_segment(bv, bio, iter) {
8184
if (sectors + (bv.bv_len >> 9) > queue_max_sectors(q))
@@ -98,7 +101,7 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,
98101

99102
seg_size += bv.bv_len;
100103
bvprv = bv;
101-
bvprvp = &bv;
104+
bvprvp = &bvprv;
102105
sectors += bv.bv_len >> 9;
103106
continue;
104107
}
@@ -108,16 +111,29 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,
108111

109112
nsegs++;
110113
bvprv = bv;
111-
bvprvp = &bv;
114+
bvprvp = &bvprv;
112115
seg_size = bv.bv_len;
113116
sectors += bv.bv_len >> 9;
117+
118+
if (nsegs == 1 && seg_size > front_seg_size)
119+
front_seg_size = seg_size;
114120
}
115121

116-
*segs = nsegs;
117-
return NULL;
122+
do_split = false;
118123
split:
119124
*segs = nsegs;
120-
return bio_split(bio, sectors, GFP_NOIO, bs);
125+
126+
if (do_split) {
127+
new = bio_split(bio, sectors, GFP_NOIO, bs);
128+
if (new)
129+
bio = new;
130+
}
131+
132+
bio->bi_seg_front_size = front_seg_size;
133+
if (seg_size > bio->bi_seg_back_size)
134+
bio->bi_seg_back_size = seg_size;
135+
136+
return do_split ? new : NULL;
121137
}
122138

123139
void blk_queue_split(struct request_queue *q, struct bio **bio,
@@ -412,6 +428,12 @@ int blk_rq_map_sg(struct request_queue *q, struct request *rq,
412428
if (sg)
413429
sg_mark_end(sg);
414430

431+
/*
432+
* Something must have been wrong if the figured number of
433+
* segment is bigger than number of req's physical segments
434+
*/
435+
WARN_ON(nsegs > rq->nr_phys_segments);
436+
415437
return nsegs;
416438
}
417439
EXPORT_SYMBOL(blk_rq_map_sg);

block/blk-mq.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,15 +1291,16 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
12911291
blk_mq_bio_to_request(rq, bio);
12921292

12931293
/*
1294-
* we do limited pluging. If bio can be merged, do merge.
1294+
* We do limited pluging. If the bio can be merged, do that.
12951295
* Otherwise the existing request in the plug list will be
12961296
* issued. So the plug list will have one request at most
12971297
*/
12981298
if (plug) {
12991299
/*
13001300
* The plug list might get flushed before this. If that
1301-
* happens, same_queue_rq is invalid and plug list is empty
1302-
**/
1301+
* happens, same_queue_rq is invalid and plug list is
1302+
* empty
1303+
*/
13031304
if (same_queue_rq && !list_empty(&plug->mq_list)) {
13041305
old_rq = same_queue_rq;
13051306
list_del_init(&old_rq->queuelist);
@@ -1380,12 +1381,15 @@ static blk_qc_t blk_sq_make_request(struct request_queue *q, struct bio *bio)
13801381
blk_mq_bio_to_request(rq, bio);
13811382
if (!request_count)
13821383
trace_block_plug(q);
1383-
else if (request_count >= BLK_MAX_REQUEST_COUNT) {
1384+
1385+
blk_mq_put_ctx(data.ctx);
1386+
1387+
if (request_count >= BLK_MAX_REQUEST_COUNT) {
13841388
blk_flush_plug_list(plug, false);
13851389
trace_block_plug(q);
13861390
}
1391+
13871392
list_add_tail(&rq->queuelist, &plug->mq_list);
1388-
blk_mq_put_ctx(data.ctx);
13891393
return cookie;
13901394
}
13911395

block/noop-iosched.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ static void noop_merged_requests(struct request_queue *q, struct request *rq,
2121
static int noop_dispatch(struct request_queue *q, int force)
2222
{
2323
struct noop_data *nd = q->elevator->elevator_data;
24+
struct request *rq;
2425

25-
if (!list_empty(&nd->queue)) {
26-
struct request *rq;
27-
rq = list_entry(nd->queue.next, struct request, queuelist);
26+
rq = list_first_entry_or_null(&nd->queue, struct request, queuelist);
27+
if (rq) {
2828
list_del_init(&rq->queuelist);
2929
elv_dispatch_sort(q, rq);
3030
return 1;
@@ -46,7 +46,7 @@ noop_former_request(struct request_queue *q, struct request *rq)
4646

4747
if (rq->queuelist.prev == &nd->queue)
4848
return NULL;
49-
return list_entry(rq->queuelist.prev, struct request, queuelist);
49+
return list_prev_entry(rq, queuelist);
5050
}
5151

5252
static struct request *
@@ -56,7 +56,7 @@ noop_latter_request(struct request_queue *q, struct request *rq)
5656

5757
if (rq->queuelist.next == &nd->queue)
5858
return NULL;
59-
return list_entry(rq->queuelist.next, struct request, queuelist);
59+
return list_next_entry(rq, queuelist);
6060
}
6161

6262
static int noop_init_queue(struct request_queue *q, struct elevator_type *e)

block/partitions/mac.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ int mac_partition(struct parsed_partitions *state)
3232
Sector sect;
3333
unsigned char *data;
3434
int slot, blocks_in_map;
35-
unsigned secsize;
35+
unsigned secsize, datasize, partoffset;
3636
#ifdef CONFIG_PPC_PMAC
3737
int found_root = 0;
3838
int found_root_goodness = 0;
@@ -50,10 +50,14 @@ int mac_partition(struct parsed_partitions *state)
5050
}
5151
secsize = be16_to_cpu(md->block_size);
5252
put_dev_sector(sect);
53-
data = read_part_sector(state, secsize/512, &sect);
53+
datasize = round_down(secsize, 512);
54+
data = read_part_sector(state, datasize / 512, &sect);
5455
if (!data)
5556
return -1;
56-
part = (struct mac_partition *) (data + secsize%512);
57+
partoffset = secsize % 512;
58+
if (partoffset + sizeof(*part) > datasize)
59+
return -1;
60+
part = (struct mac_partition *) (data + partoffset);
5761
if (be16_to_cpu(part->signature) != MAC_PARTITION_MAGIC) {
5862
put_dev_sector(sect);
5963
return 0; /* not a MacOS disk */

drivers/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ obj-$(CONFIG_FB_I810) += video/fbdev/i810/
6363
obj-$(CONFIG_FB_INTEL) += video/fbdev/intelfb/
6464

6565
obj-$(CONFIG_PARPORT) += parport/
66+
obj-$(CONFIG_NVM) += lightnvm/
6667
obj-y += base/ block/ misc/ mfd/ nfc/
6768
obj-$(CONFIG_LIBNVDIMM) += nvdimm/
6869
obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf/
6970
obj-$(CONFIG_NUBUS) += nubus/
7071
obj-y += macintosh/
7172
obj-$(CONFIG_IDE) += ide/
7273
obj-$(CONFIG_SCSI) += scsi/
73-
obj-$(CONFIG_NVM) += lightnvm/
7474
obj-y += nvme/
7575
obj-$(CONFIG_ATA) += ata/
7676
obj-$(CONFIG_TARGET_CORE) += target/

drivers/block/mtip32xx/mtip32xx.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3810,7 +3810,6 @@ static int mtip_block_initialize(struct driver_data *dd)
38103810
sector_t capacity;
38113811
unsigned int index = 0;
38123812
struct kobject *kobj;
3813-
unsigned char thd_name[16];
38143813

38153814
if (dd->disk)
38163815
goto skip_create_disk; /* hw init done, before rebuild */
@@ -3958,10 +3957,9 @@ static int mtip_block_initialize(struct driver_data *dd)
39583957
}
39593958

39603959
start_service_thread:
3961-
sprintf(thd_name, "mtip_svc_thd_%02d", index);
39623960
dd->mtip_svc_handler = kthread_create_on_node(mtip_service_thread,
3963-
dd, dd->numa_node, "%s",
3964-
thd_name);
3961+
dd, dd->numa_node,
3962+
"mtip_svc_thd_%02d", index);
39653963

39663964
if (IS_ERR(dd->mtip_svc_handler)) {
39673965
dev_err(&dd->pdev->dev, "service thread failed to start\n");

0 commit comments

Comments
 (0)