Skip to content

Commit

Permalink
Merge tag 'block-5.10-2020-10-24' of git://git.kernel.dk/linux-block
Browse files Browse the repository at this point in the history
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[]
  ...
  • Loading branch information
torvalds committed Oct 24, 2020
2 parents af00418 + 24f7bb8 commit d769139
Show file tree
Hide file tree
Showing 21 changed files with 222 additions and 108 deletions.
8 changes: 8 additions & 0 deletions Documentation/block/queue-sysfs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,21 @@ For zoned block devices (zoned attribute indicating "host-managed" or
EXPLICIT OPEN, IMPLICIT OPEN or CLOSED, is limited by this value.
If this value is 0, there is no limit.

If the host attempts to exceed this limit, the driver should report this error
with BLK_STS_ZONE_ACTIVE_RESOURCE, which user space may see as the EOVERFLOW
errno.

max_open_zones (RO)
-------------------
For zoned block devices (zoned attribute indicating "host-managed" or
"host-aware"), the sum of zones belonging to any of the zone states:
EXPLICIT OPEN or IMPLICIT OPEN, is limited by this value.
If this value is 0, there is no limit.

If the host attempts to exceed this limit, the driver should report this error
with BLK_STS_ZONE_OPEN_RESOURCE, which user space may see as the ETOOMANYREFS
errno.

max_sectors_kb (RW)
-------------------
This is the maximum number of kilobytes that the block layer will allow
Expand Down
4 changes: 4 additions & 0 deletions block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ static const struct {
/* device mapper special case, should not leak out: */
[BLK_STS_DM_REQUEUE] = { -EREMCHG, "dm internal retry" },

/* zone device specific errors */
[BLK_STS_ZONE_OPEN_RESOURCE] = { -ETOOMANYREFS, "open zones exceeded" },
[BLK_STS_ZONE_ACTIVE_RESOURCE] = { -EOVERFLOW, "active zones exceeded" },

/* everything else not covered above: */
[BLK_STS_IOERR] = { -EIO, "I/O" },
};
Expand Down
2 changes: 1 addition & 1 deletion block/blk-mq-cpumap.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ int blk_mq_hw_queue_to_node(struct blk_mq_queue_map *qmap, unsigned int index)

for_each_possible_cpu(i) {
if (index == qmap->mq_map[i])
return local_memory_node(cpu_to_node(i));
return cpu_to_node(i);
}

return NUMA_NO_NODE;
Expand Down
4 changes: 2 additions & 2 deletions block/blk-mq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1664,7 +1664,7 @@ void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async)
EXPORT_SYMBOL(blk_mq_run_hw_queue);

/**
* blk_mq_run_hw_queue - Run all hardware queues in a request queue.
* blk_mq_run_hw_queues - Run all hardware queues in a request queue.
* @q: Pointer to the request queue to run.
* @async: If we want to run the queue asynchronously.
*/
Expand Down Expand Up @@ -2743,7 +2743,7 @@ static void blk_mq_init_cpu_queues(struct request_queue *q,
for (j = 0; j < set->nr_maps; j++) {
hctx = blk_mq_map_queue_type(q, j, i);
if (nr_hw_queues > 1 && hctx->numa_node == NUMA_NO_NODE)
hctx->numa_node = local_memory_node(cpu_to_node(i));
hctx->numa_node = cpu_to_node(i);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/nbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -802,9 +802,9 @@ static void recv_work(struct work_struct *work)
if (likely(!blk_should_fake_timeout(rq->q)))
blk_mq_complete_request(rq);
}
nbd_config_put(nbd);
atomic_dec(&config->recv_threads);
wake_up(&config->recv_wq);
nbd_config_put(nbd);
kfree(args);
}

Expand Down
69 changes: 43 additions & 26 deletions drivers/block/null_blk_zoned.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,29 +220,34 @@ static void null_close_first_imp_zone(struct nullb_device *dev)
}
}

static bool null_can_set_active(struct nullb_device *dev)
static blk_status_t null_check_active(struct nullb_device *dev)
{
if (!dev->zone_max_active)
return true;
return BLK_STS_OK;

if (dev->nr_zones_exp_open + dev->nr_zones_imp_open +
dev->nr_zones_closed < dev->zone_max_active)
return BLK_STS_OK;

return dev->nr_zones_exp_open + dev->nr_zones_imp_open +
dev->nr_zones_closed < dev->zone_max_active;
return BLK_STS_ZONE_ACTIVE_RESOURCE;
}

static bool null_can_open(struct nullb_device *dev)
static blk_status_t null_check_open(struct nullb_device *dev)
{
if (!dev->zone_max_open)
return true;
return BLK_STS_OK;

if (dev->nr_zones_exp_open + dev->nr_zones_imp_open < dev->zone_max_open)
return true;
return BLK_STS_OK;

if (dev->nr_zones_imp_open && null_can_set_active(dev)) {
null_close_first_imp_zone(dev);
return true;
if (dev->nr_zones_imp_open) {
if (null_check_active(dev) == BLK_STS_OK) {
null_close_first_imp_zone(dev);
return BLK_STS_OK;
}
}

return false;
return BLK_STS_ZONE_OPEN_RESOURCE;
}

/*
Expand All @@ -258,19 +263,22 @@ static bool null_can_open(struct nullb_device *dev)
* it is not certain that closing an implicit open zone will allow a new zone
* to be opened, since we might already be at the active limit capacity.
*/
static bool null_has_zone_resources(struct nullb_device *dev, struct blk_zone *zone)
static blk_status_t null_check_zone_resources(struct nullb_device *dev, struct blk_zone *zone)
{
blk_status_t ret;

switch (zone->cond) {
case BLK_ZONE_COND_EMPTY:
if (!null_can_set_active(dev))
return false;
ret = null_check_active(dev);
if (ret != BLK_STS_OK)
return ret;
fallthrough;
case BLK_ZONE_COND_CLOSED:
return null_can_open(dev);
return null_check_open(dev);
default:
/* Should never be called for other states */
WARN_ON(1);
return false;
return BLK_STS_IOERR;
}
}

Expand All @@ -293,8 +301,9 @@ static blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector,
return BLK_STS_IOERR;
case BLK_ZONE_COND_EMPTY:
case BLK_ZONE_COND_CLOSED:
if (!null_has_zone_resources(dev, zone))
return BLK_STS_IOERR;
ret = null_check_zone_resources(dev, zone);
if (ret != BLK_STS_OK)
return ret;
break;
case BLK_ZONE_COND_IMP_OPEN:
case BLK_ZONE_COND_EXP_OPEN:
Expand Down Expand Up @@ -349,6 +358,8 @@ static blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector,

static blk_status_t null_open_zone(struct nullb_device *dev, struct blk_zone *zone)
{
blk_status_t ret;

if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL)
return BLK_STS_IOERR;

Expand All @@ -357,15 +368,17 @@ static blk_status_t null_open_zone(struct nullb_device *dev, struct blk_zone *zo
/* open operation on exp open is not an error */
return BLK_STS_OK;
case BLK_ZONE_COND_EMPTY:
if (!null_has_zone_resources(dev, zone))
return BLK_STS_IOERR;
ret = null_check_zone_resources(dev, zone);
if (ret != BLK_STS_OK)
return ret;
break;
case BLK_ZONE_COND_IMP_OPEN:
dev->nr_zones_imp_open--;
break;
case BLK_ZONE_COND_CLOSED:
if (!null_has_zone_resources(dev, zone))
return BLK_STS_IOERR;
ret = null_check_zone_resources(dev, zone);
if (ret != BLK_STS_OK)
return ret;
dev->nr_zones_closed--;
break;
case BLK_ZONE_COND_FULL:
Expand All @@ -381,6 +394,8 @@ static blk_status_t null_open_zone(struct nullb_device *dev, struct blk_zone *zo

static blk_status_t null_finish_zone(struct nullb_device *dev, struct blk_zone *zone)
{
blk_status_t ret;

if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL)
return BLK_STS_IOERR;

Expand All @@ -389,8 +404,9 @@ static blk_status_t null_finish_zone(struct nullb_device *dev, struct blk_zone *
/* finish operation on full is not an error */
return BLK_STS_OK;
case BLK_ZONE_COND_EMPTY:
if (!null_has_zone_resources(dev, zone))
return BLK_STS_IOERR;
ret = null_check_zone_resources(dev, zone);
if (ret != BLK_STS_OK)
return ret;
break;
case BLK_ZONE_COND_IMP_OPEN:
dev->nr_zones_imp_open--;
Expand All @@ -399,8 +415,9 @@ static blk_status_t null_finish_zone(struct nullb_device *dev, struct blk_zone *
dev->nr_zones_exp_open--;
break;
case BLK_ZONE_COND_CLOSED:
if (!null_has_zone_resources(dev, zone))
return BLK_STS_IOERR;
ret = null_check_zone_resources(dev, zone);
if (ret != BLK_STS_OK)
return ret;
dev->nr_zones_closed--;
break;
default:
Expand Down
19 changes: 8 additions & 11 deletions drivers/block/rnbd/rnbd-clt.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ static int rnbd_clt_set_dev_attr(struct rnbd_clt_dev *dev,
dev->max_hw_sectors = sess->max_io_size / SECTOR_SIZE;
dev->max_segments = BMAX_SEGMENTS;

dev->max_hw_sectors = min_t(u32, dev->max_hw_sectors,
le32_to_cpu(rsp->max_hw_sectors));
dev->max_segments = min_t(u16, dev->max_segments,
le16_to_cpu(rsp->max_segments));

return 0;
}

Expand Down Expand Up @@ -427,7 +422,7 @@ enum wait_type {
};

static int send_usr_msg(struct rtrs_clt *rtrs, int dir,
struct rnbd_iu *iu, struct kvec *vec, size_t nr,
struct rnbd_iu *iu, struct kvec *vec,
size_t len, struct scatterlist *sg, unsigned int sg_len,
void (*conf)(struct work_struct *work),
int *errno, enum wait_type wait)
Expand All @@ -441,7 +436,7 @@ static int send_usr_msg(struct rtrs_clt *rtrs, int dir,
.conf_fn = msg_conf,
};
err = rtrs_clt_request(dir, &req_ops, rtrs, iu->permit,
vec, nr, len, sg, sg_len);
vec, 1, len, sg, sg_len);
if (!err && wait) {
wait_event(iu->comp.wait, iu->comp.errno != INT_MAX);
*errno = iu->comp.errno;
Expand Down Expand Up @@ -486,7 +481,7 @@ static int send_msg_close(struct rnbd_clt_dev *dev, u32 device_id, bool wait)
msg.device_id = cpu_to_le32(device_id);

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

WARN_ON(!rnbd_clt_get_dev(dev));
err = send_usr_msg(sess->rtrs, READ, iu,
&vec, 1, sizeof(*rsp), iu->sglist, 1,
&vec, sizeof(*rsp), iu->sglist, 1,
msg_open_conf, &errno, wait);
if (err) {
rnbd_clt_put_dev(dev);
Expand Down Expand Up @@ -629,7 +624,7 @@ static int send_msg_sess_info(struct rnbd_clt_session *sess, bool wait)
goto put_iu;
}
err = send_usr_msg(sess->rtrs, READ, iu,
&vec, 1, sizeof(*rsp), iu->sglist, 1,
&vec, sizeof(*rsp), iu->sglist, 1,
msg_sess_info_conf, &errno, wait);
if (err) {
rnbd_clt_put_sess(sess);
Expand Down Expand Up @@ -1514,7 +1509,7 @@ struct rnbd_clt_dev *rnbd_clt_map_device(const char *sessname,
"map_device: Failed to configure device, err: %d\n",
ret);
mutex_unlock(&dev->lock);
goto del_dev;
goto send_close;
}

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

return dev;

send_close:
send_msg_close(dev, dev->device_id, WAIT);
del_dev:
delete_dev(dev);
put_dev:
Expand Down
1 change: 0 additions & 1 deletion drivers/block/skd_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <linux/dma-mapping.h>
#include <linux/completion.h>
#include <linux/scatterlist.h>
#include <linux/version.h>
#include <linux/err.h>
#include <linux/aer.h>
#include <linux/wait.h>
Expand Down
8 changes: 5 additions & 3 deletions drivers/block/zram/zram_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1218,10 +1218,11 @@ static void zram_free_page(struct zram *zram, size_t index)
static int __zram_bvec_read(struct zram *zram, struct page *page, u32 index,
struct bio *bio, bool partial_io)
{
int ret;
struct zcomp_strm *zstrm;
unsigned long handle;
unsigned int size;
void *src, *dst;
int ret;

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

size = zram_get_obj_size(zram, index);

if (size != PAGE_SIZE)
zstrm = zcomp_stream_get(zram->comp);

src = zs_map_object(zram->mem_pool, handle, ZS_MM_RO);
if (size == PAGE_SIZE) {
dst = kmap_atomic(page);
memcpy(dst, src, PAGE_SIZE);
kunmap_atomic(dst);
ret = 0;
} else {
struct zcomp_strm *zstrm = zcomp_stream_get(zram->comp);

dst = kmap_atomic(page);
ret = zcomp_decompress(zstrm, src, size, dst);
kunmap_atomic(dst);
Expand Down
5 changes: 3 additions & 2 deletions drivers/lightnvm/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1311,8 +1311,9 @@ static long nvm_ioctl_get_devices(struct file *file, void __user *arg)
strlcpy(info->bmname, "gennvm", sizeof(info->bmname));
i++;

if (i > 31) {
pr_err("max 31 devices can be reported.\n");
if (i >= ARRAY_SIZE(devices->info)) {
pr_err("max %zd devices can be reported.\n",
ARRAY_SIZE(devices->info));
break;
}
}
Expand Down
4 changes: 4 additions & 0 deletions drivers/nvme/host/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ static blk_status_t nvme_error_status(u16 status)
return BLK_STS_NEXUS;
case NVME_SC_HOST_PATH_ERROR:
return BLK_STS_TRANSPORT;
case NVME_SC_ZONE_TOO_MANY_ACTIVE:
return BLK_STS_ZONE_ACTIVE_RESOURCE;
case NVME_SC_ZONE_TOO_MANY_OPEN:
return BLK_STS_ZONE_OPEN_RESOURCE;
default:
return BLK_STS_IOERR;
}
Expand Down
Loading

0 comments on commit d769139

Please sign in to comment.