Skip to content

Commit d769139

Browse files
committed
Merge tag 'block-5.10-2020-10-24' of git://git.kernel.dk/linux-block
Pull block fixes from Jens Axboe: - NVMe pull request from Christoph - rdma error handling fixes (Chao Leng) - fc error handling and reconnect fixes (James Smart) - fix the qid displace when tracing ioctl command (Keith Busch) - don't use BLK_MQ_REQ_NOWAIT for passthru (Chaitanya Kulkarni) - fix MTDT for passthru (Logan Gunthorpe) - blacklist Write Same on more devices (Kai-Heng Feng) - fix an uninitialized work struct (zhenwei pi)" - lightnvm out-of-bounds fix (Colin) - SG allocation leak fix (Doug) - rnbd fixes (Gioh, Guoqing, Jack) - zone error translation fixes (Keith) - kerneldoc markup fix (Mauro) - zram lockdep fix (Peter) - Kill unused io_context members (Yufen) - NUMA memory allocation cleanup (Xianting) - NBD config wakeup fix (Xiubo) * tag 'block-5.10-2020-10-24' of git://git.kernel.dk/linux-block: (27 commits) block: blk-mq: fix a kernel-doc markup nvme-fc: shorten reconnect delay if possible for FC nvme-fc: wait for queues to freeze before calling update_hr_hw_queues nvme-fc: fix error loop in create_hw_io_queues nvme-fc: fix io timeout to abort I/O null_blk: use zone status for max active/open nvmet: don't use BLK_MQ_REQ_NOWAIT for passthru nvmet: cleanup nvmet_passthru_map_sg() nvmet: limit passthru MTDS by BIO_MAX_PAGES nvmet: fix uninitialized work for zero kato nvme-pci: disable Write Zeroes on Sandisk Skyhawk nvme: use queuedata for nvme_req_qid nvme-rdma: fix crash due to incorrect cqe nvme-rdma: fix crash when connect rejected block: remove unused members for io_context blk-mq: remove the calling of local_memory_node() zram: Fix __zram_bvec_{read,write}() locking order skd_main: remove unused including <linux/version.h> sgl_alloc_order: fix memory leak lightnvm: fix out-of-bounds write to array devices->info[] ...
2 parents af00418 + 24f7bb8 commit d769139

File tree

21 files changed

+222
-108
lines changed

21 files changed

+222
-108
lines changed

Documentation/block/queue-sysfs.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,21 @@ For zoned block devices (zoned attribute indicating "host-managed" or
124124
EXPLICIT OPEN, IMPLICIT OPEN or CLOSED, is limited by this value.
125125
If this value is 0, there is no limit.
126126

127+
If the host attempts to exceed this limit, the driver should report this error
128+
with BLK_STS_ZONE_ACTIVE_RESOURCE, which user space may see as the EOVERFLOW
129+
errno.
130+
127131
max_open_zones (RO)
128132
-------------------
129133
For zoned block devices (zoned attribute indicating "host-managed" or
130134
"host-aware"), the sum of zones belonging to any of the zone states:
131135
EXPLICIT OPEN or IMPLICIT OPEN, is limited by this value.
132136
If this value is 0, there is no limit.
133137

138+
If the host attempts to exceed this limit, the driver should report this error
139+
with BLK_STS_ZONE_OPEN_RESOURCE, which user space may see as the ETOOMANYREFS
140+
errno.
141+
134142
max_sectors_kb (RW)
135143
-------------------
136144
This is the maximum number of kilobytes that the block layer will allow

block/blk-core.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ static const struct {
186186
/* device mapper special case, should not leak out: */
187187
[BLK_STS_DM_REQUEUE] = { -EREMCHG, "dm internal retry" },
188188

189+
/* zone device specific errors */
190+
[BLK_STS_ZONE_OPEN_RESOURCE] = { -ETOOMANYREFS, "open zones exceeded" },
191+
[BLK_STS_ZONE_ACTIVE_RESOURCE] = { -EOVERFLOW, "active zones exceeded" },
192+
189193
/* everything else not covered above: */
190194
[BLK_STS_IOERR] = { -EIO, "I/O" },
191195
};

block/blk-mq-cpumap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ int blk_mq_hw_queue_to_node(struct blk_mq_queue_map *qmap, unsigned int index)
8989

9090
for_each_possible_cpu(i) {
9191
if (index == qmap->mq_map[i])
92-
return local_memory_node(cpu_to_node(i));
92+
return cpu_to_node(i);
9393
}
9494

9595
return NUMA_NO_NODE;

block/blk-mq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,7 +1664,7 @@ void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async)
16641664
EXPORT_SYMBOL(blk_mq_run_hw_queue);
16651665

16661666
/**
1667-
* blk_mq_run_hw_queue - Run all hardware queues in a request queue.
1667+
* blk_mq_run_hw_queues - Run all hardware queues in a request queue.
16681668
* @q: Pointer to the request queue to run.
16691669
* @async: If we want to run the queue asynchronously.
16701670
*/
@@ -2743,7 +2743,7 @@ static void blk_mq_init_cpu_queues(struct request_queue *q,
27432743
for (j = 0; j < set->nr_maps; j++) {
27442744
hctx = blk_mq_map_queue_type(q, j, i);
27452745
if (nr_hw_queues > 1 && hctx->numa_node == NUMA_NO_NODE)
2746-
hctx->numa_node = local_memory_node(cpu_to_node(i));
2746+
hctx->numa_node = cpu_to_node(i);
27472747
}
27482748
}
27492749
}

drivers/block/nbd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,9 +802,9 @@ static void recv_work(struct work_struct *work)
802802
if (likely(!blk_should_fake_timeout(rq->q)))
803803
blk_mq_complete_request(rq);
804804
}
805+
nbd_config_put(nbd);
805806
atomic_dec(&config->recv_threads);
806807
wake_up(&config->recv_wq);
807-
nbd_config_put(nbd);
808808
kfree(args);
809809
}
810810

drivers/block/null_blk_zoned.c

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -220,29 +220,34 @@ static void null_close_first_imp_zone(struct nullb_device *dev)
220220
}
221221
}
222222

223-
static bool null_can_set_active(struct nullb_device *dev)
223+
static blk_status_t null_check_active(struct nullb_device *dev)
224224
{
225225
if (!dev->zone_max_active)
226-
return true;
226+
return BLK_STS_OK;
227+
228+
if (dev->nr_zones_exp_open + dev->nr_zones_imp_open +
229+
dev->nr_zones_closed < dev->zone_max_active)
230+
return BLK_STS_OK;
227231

228-
return dev->nr_zones_exp_open + dev->nr_zones_imp_open +
229-
dev->nr_zones_closed < dev->zone_max_active;
232+
return BLK_STS_ZONE_ACTIVE_RESOURCE;
230233
}
231234

232-
static bool null_can_open(struct nullb_device *dev)
235+
static blk_status_t null_check_open(struct nullb_device *dev)
233236
{
234237
if (!dev->zone_max_open)
235-
return true;
238+
return BLK_STS_OK;
236239

237240
if (dev->nr_zones_exp_open + dev->nr_zones_imp_open < dev->zone_max_open)
238-
return true;
241+
return BLK_STS_OK;
239242

240-
if (dev->nr_zones_imp_open && null_can_set_active(dev)) {
241-
null_close_first_imp_zone(dev);
242-
return true;
243+
if (dev->nr_zones_imp_open) {
244+
if (null_check_active(dev) == BLK_STS_OK) {
245+
null_close_first_imp_zone(dev);
246+
return BLK_STS_OK;
247+
}
243248
}
244249

245-
return false;
250+
return BLK_STS_ZONE_OPEN_RESOURCE;
246251
}
247252

248253
/*
@@ -258,19 +263,22 @@ static bool null_can_open(struct nullb_device *dev)
258263
* it is not certain that closing an implicit open zone will allow a new zone
259264
* to be opened, since we might already be at the active limit capacity.
260265
*/
261-
static bool null_has_zone_resources(struct nullb_device *dev, struct blk_zone *zone)
266+
static blk_status_t null_check_zone_resources(struct nullb_device *dev, struct blk_zone *zone)
262267
{
268+
blk_status_t ret;
269+
263270
switch (zone->cond) {
264271
case BLK_ZONE_COND_EMPTY:
265-
if (!null_can_set_active(dev))
266-
return false;
272+
ret = null_check_active(dev);
273+
if (ret != BLK_STS_OK)
274+
return ret;
267275
fallthrough;
268276
case BLK_ZONE_COND_CLOSED:
269-
return null_can_open(dev);
277+
return null_check_open(dev);
270278
default:
271279
/* Should never be called for other states */
272280
WARN_ON(1);
273-
return false;
281+
return BLK_STS_IOERR;
274282
}
275283
}
276284

@@ -293,8 +301,9 @@ static blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector,
293301
return BLK_STS_IOERR;
294302
case BLK_ZONE_COND_EMPTY:
295303
case BLK_ZONE_COND_CLOSED:
296-
if (!null_has_zone_resources(dev, zone))
297-
return BLK_STS_IOERR;
304+
ret = null_check_zone_resources(dev, zone);
305+
if (ret != BLK_STS_OK)
306+
return ret;
298307
break;
299308
case BLK_ZONE_COND_IMP_OPEN:
300309
case BLK_ZONE_COND_EXP_OPEN:
@@ -349,6 +358,8 @@ static blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector,
349358

350359
static blk_status_t null_open_zone(struct nullb_device *dev, struct blk_zone *zone)
351360
{
361+
blk_status_t ret;
362+
352363
if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL)
353364
return BLK_STS_IOERR;
354365

@@ -357,15 +368,17 @@ static blk_status_t null_open_zone(struct nullb_device *dev, struct blk_zone *zo
357368
/* open operation on exp open is not an error */
358369
return BLK_STS_OK;
359370
case BLK_ZONE_COND_EMPTY:
360-
if (!null_has_zone_resources(dev, zone))
361-
return BLK_STS_IOERR;
371+
ret = null_check_zone_resources(dev, zone);
372+
if (ret != BLK_STS_OK)
373+
return ret;
362374
break;
363375
case BLK_ZONE_COND_IMP_OPEN:
364376
dev->nr_zones_imp_open--;
365377
break;
366378
case BLK_ZONE_COND_CLOSED:
367-
if (!null_has_zone_resources(dev, zone))
368-
return BLK_STS_IOERR;
379+
ret = null_check_zone_resources(dev, zone);
380+
if (ret != BLK_STS_OK)
381+
return ret;
369382
dev->nr_zones_closed--;
370383
break;
371384
case BLK_ZONE_COND_FULL:
@@ -381,6 +394,8 @@ static blk_status_t null_open_zone(struct nullb_device *dev, struct blk_zone *zo
381394

382395
static blk_status_t null_finish_zone(struct nullb_device *dev, struct blk_zone *zone)
383396
{
397+
blk_status_t ret;
398+
384399
if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL)
385400
return BLK_STS_IOERR;
386401

@@ -389,8 +404,9 @@ static blk_status_t null_finish_zone(struct nullb_device *dev, struct blk_zone *
389404
/* finish operation on full is not an error */
390405
return BLK_STS_OK;
391406
case BLK_ZONE_COND_EMPTY:
392-
if (!null_has_zone_resources(dev, zone))
393-
return BLK_STS_IOERR;
407+
ret = null_check_zone_resources(dev, zone);
408+
if (ret != BLK_STS_OK)
409+
return ret;
394410
break;
395411
case BLK_ZONE_COND_IMP_OPEN:
396412
dev->nr_zones_imp_open--;
@@ -399,8 +415,9 @@ static blk_status_t null_finish_zone(struct nullb_device *dev, struct blk_zone *
399415
dev->nr_zones_exp_open--;
400416
break;
401417
case BLK_ZONE_COND_CLOSED:
402-
if (!null_has_zone_resources(dev, zone))
403-
return BLK_STS_IOERR;
418+
ret = null_check_zone_resources(dev, zone);
419+
if (ret != BLK_STS_OK)
420+
return ret;
404421
dev->nr_zones_closed--;
405422
break;
406423
default:

drivers/block/rnbd/rnbd-clt.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,6 @@ static int rnbd_clt_set_dev_attr(struct rnbd_clt_dev *dev,
9191
dev->max_hw_sectors = sess->max_io_size / SECTOR_SIZE;
9292
dev->max_segments = BMAX_SEGMENTS;
9393

94-
dev->max_hw_sectors = min_t(u32, dev->max_hw_sectors,
95-
le32_to_cpu(rsp->max_hw_sectors));
96-
dev->max_segments = min_t(u16, dev->max_segments,
97-
le16_to_cpu(rsp->max_segments));
98-
9994
return 0;
10095
}
10196

@@ -427,7 +422,7 @@ enum wait_type {
427422
};
428423

429424
static int send_usr_msg(struct rtrs_clt *rtrs, int dir,
430-
struct rnbd_iu *iu, struct kvec *vec, size_t nr,
425+
struct rnbd_iu *iu, struct kvec *vec,
431426
size_t len, struct scatterlist *sg, unsigned int sg_len,
432427
void (*conf)(struct work_struct *work),
433428
int *errno, enum wait_type wait)
@@ -441,7 +436,7 @@ static int send_usr_msg(struct rtrs_clt *rtrs, int dir,
441436
.conf_fn = msg_conf,
442437
};
443438
err = rtrs_clt_request(dir, &req_ops, rtrs, iu->permit,
444-
vec, nr, len, sg, sg_len);
439+
vec, 1, len, sg, sg_len);
445440
if (!err && wait) {
446441
wait_event(iu->comp.wait, iu->comp.errno != INT_MAX);
447442
*errno = iu->comp.errno;
@@ -486,7 +481,7 @@ static int send_msg_close(struct rnbd_clt_dev *dev, u32 device_id, bool wait)
486481
msg.device_id = cpu_to_le32(device_id);
487482

488483
WARN_ON(!rnbd_clt_get_dev(dev));
489-
err = send_usr_msg(sess->rtrs, WRITE, iu, &vec, 1, 0, NULL, 0,
484+
err = send_usr_msg(sess->rtrs, WRITE, iu, &vec, 0, NULL, 0,
490485
msg_close_conf, &errno, wait);
491486
if (err) {
492487
rnbd_clt_put_dev(dev);
@@ -575,7 +570,7 @@ static int send_msg_open(struct rnbd_clt_dev *dev, bool wait)
575570

576571
WARN_ON(!rnbd_clt_get_dev(dev));
577572
err = send_usr_msg(sess->rtrs, READ, iu,
578-
&vec, 1, sizeof(*rsp), iu->sglist, 1,
573+
&vec, sizeof(*rsp), iu->sglist, 1,
579574
msg_open_conf, &errno, wait);
580575
if (err) {
581576
rnbd_clt_put_dev(dev);
@@ -629,7 +624,7 @@ static int send_msg_sess_info(struct rnbd_clt_session *sess, bool wait)
629624
goto put_iu;
630625
}
631626
err = send_usr_msg(sess->rtrs, READ, iu,
632-
&vec, 1, sizeof(*rsp), iu->sglist, 1,
627+
&vec, sizeof(*rsp), iu->sglist, 1,
633628
msg_sess_info_conf, &errno, wait);
634629
if (err) {
635630
rnbd_clt_put_sess(sess);
@@ -1514,7 +1509,7 @@ struct rnbd_clt_dev *rnbd_clt_map_device(const char *sessname,
15141509
"map_device: Failed to configure device, err: %d\n",
15151510
ret);
15161511
mutex_unlock(&dev->lock);
1517-
goto del_dev;
1512+
goto send_close;
15181513
}
15191514

15201515
rnbd_clt_info(dev,
@@ -1533,6 +1528,8 @@ struct rnbd_clt_dev *rnbd_clt_map_device(const char *sessname,
15331528

15341529
return dev;
15351530

1531+
send_close:
1532+
send_msg_close(dev, dev->device_id, WAIT);
15361533
del_dev:
15371534
delete_dev(dev);
15381535
put_dev:

drivers/block/skd_main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <linux/dma-mapping.h>
2626
#include <linux/completion.h>
2727
#include <linux/scatterlist.h>
28-
#include <linux/version.h>
2928
#include <linux/err.h>
3029
#include <linux/aer.h>
3130
#include <linux/wait.h>

drivers/block/zram/zram_drv.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,10 +1218,11 @@ static void zram_free_page(struct zram *zram, size_t index)
12181218
static int __zram_bvec_read(struct zram *zram, struct page *page, u32 index,
12191219
struct bio *bio, bool partial_io)
12201220
{
1221-
int ret;
1221+
struct zcomp_strm *zstrm;
12221222
unsigned long handle;
12231223
unsigned int size;
12241224
void *src, *dst;
1225+
int ret;
12251226

12261227
zram_slot_lock(zram, index);
12271228
if (zram_test_flag(zram, index, ZRAM_WB)) {
@@ -1252,15 +1253,16 @@ static int __zram_bvec_read(struct zram *zram, struct page *page, u32 index,
12521253

12531254
size = zram_get_obj_size(zram, index);
12541255

1256+
if (size != PAGE_SIZE)
1257+
zstrm = zcomp_stream_get(zram->comp);
1258+
12551259
src = zs_map_object(zram->mem_pool, handle, ZS_MM_RO);
12561260
if (size == PAGE_SIZE) {
12571261
dst = kmap_atomic(page);
12581262
memcpy(dst, src, PAGE_SIZE);
12591263
kunmap_atomic(dst);
12601264
ret = 0;
12611265
} else {
1262-
struct zcomp_strm *zstrm = zcomp_stream_get(zram->comp);
1263-
12641266
dst = kmap_atomic(page);
12651267
ret = zcomp_decompress(zstrm, src, size, dst);
12661268
kunmap_atomic(dst);

drivers/lightnvm/core.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,8 +1311,9 @@ static long nvm_ioctl_get_devices(struct file *file, void __user *arg)
13111311
strlcpy(info->bmname, "gennvm", sizeof(info->bmname));
13121312
i++;
13131313

1314-
if (i > 31) {
1315-
pr_err("max 31 devices can be reported.\n");
1314+
if (i >= ARRAY_SIZE(devices->info)) {
1315+
pr_err("max %zd devices can be reported.\n",
1316+
ARRAY_SIZE(devices->info));
13161317
break;
13171318
}
13181319
}

0 commit comments

Comments
 (0)