Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.dk/linux-block
Browse files Browse the repository at this point in the history
Pull more block layer patches from Jens Axboe:
 "A few later arrivers that I didn't fold into the first pull request,
  so we had a chance to run some testing.  This contains:

   - NVMe:
        - Set of fixes from Keith
        - 4.4 and earlier gcc build fix from Andrew

   - small set of xen-blk{back,front} fixes from Bob Liu.

   - warnings fix for bogus inline statement in I_BDEV() from Geert.

   - error code fixup for SG_IO ioctl from Paolo Bonzini"

* 'for-linus' of git://git.kernel.dk/linux-block:
  drivers/block/nvme-core.c: fix build with gcc-4.4.4
  bdi: Remove "inline" keyword from exported I_BDEV() implementation
  block: fix bogus EFAULT error from SG_IO ioctl
  NVMe: Fix filesystem deadlock on removal
  NVMe: Failed controller initialization fixes
  NVMe: Unify controller probe and resume
  NVMe: Don't use fake status on cancelled command
  NVMe: Fix device cleanup on initialization failure
  drivers: xen-blkfront: only talk_to_blkback() when in XenbusStateInitialising
  xen/block: add multi-page ring support
  driver: xen-blkfront: move talk_to_blkback to a more suitable place
  drivers: xen-blkback: delay pending_req allocation to connect_ring
  • Loading branch information
torvalds committed Jul 1, 2015
2 parents 6aaf0da + e44ac58 commit 43baed3
Show file tree
Hide file tree
Showing 7 changed files with 308 additions and 171 deletions.
4 changes: 2 additions & 2 deletions block/scsi_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
goto out_put_request;
}

ret = -EFAULT;
if (blk_fill_sghdr_rq(q, rq, hdr, mode))
ret = blk_fill_sghdr_rq(q, rq, hdr, mode);
if (ret < 0)
goto out_free_cdb;

ret = 0;
Expand Down
138 changes: 80 additions & 58 deletions drivers/block/nvme-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@ static int nvme_admin_init_hctx(struct blk_mq_hw_ctx *hctx, void *data,
return 0;
}

static void nvme_admin_exit_hctx(struct blk_mq_hw_ctx *hctx, unsigned int hctx_idx)
{
struct nvme_queue *nvmeq = hctx->driver_data;

nvmeq->tags = NULL;
}

static int nvme_admin_init_request(void *data, struct request *req,
unsigned int hctx_idx, unsigned int rq_idx,
unsigned int numa_node)
Expand Down Expand Up @@ -606,7 +613,10 @@ static void req_completion(struct nvme_queue *nvmeq, void *ctx,
return;
}
if (req->cmd_type == REQ_TYPE_DRV_PRIV) {
req->errors = status;
if (cmd_rq->ctx == CMD_CTX_CANCELLED)
req->errors = -EINTR;
else
req->errors = status;
} else {
req->errors = nvme_error_status(status);
}
Expand Down Expand Up @@ -1161,12 +1171,13 @@ static int adapter_delete_sq(struct nvme_dev *dev, u16 sqid)

int nvme_identify_ctrl(struct nvme_dev *dev, struct nvme_id_ctrl **id)
{
struct nvme_command c = {
.identify.opcode = nvme_admin_identify,
.identify.cns = cpu_to_le32(1),
};
struct nvme_command c = { };
int error;

/* gcc-4.4.4 (at least) has issues with initializers and anon unions */
c.identify.opcode = nvme_admin_identify;
c.identify.cns = cpu_to_le32(1);

*id = kmalloc(sizeof(struct nvme_id_ctrl), GFP_KERNEL);
if (!*id)
return -ENOMEM;
Expand All @@ -1181,12 +1192,13 @@ int nvme_identify_ctrl(struct nvme_dev *dev, struct nvme_id_ctrl **id)
int nvme_identify_ns(struct nvme_dev *dev, unsigned nsid,
struct nvme_id_ns **id)
{
struct nvme_command c = {
.identify.opcode = nvme_admin_identify,
.identify.nsid = cpu_to_le32(nsid),
};
struct nvme_command c = { };
int error;

/* gcc-4.4.4 (at least) has issues with initializers and anon unions */
c.identify.opcode = nvme_admin_identify,
c.identify.nsid = cpu_to_le32(nsid),

*id = kmalloc(sizeof(struct nvme_id_ns), GFP_KERNEL);
if (!*id)
return -ENOMEM;
Expand Down Expand Up @@ -1230,14 +1242,14 @@ int nvme_set_features(struct nvme_dev *dev, unsigned fid, unsigned dword11,

int nvme_get_log_page(struct nvme_dev *dev, struct nvme_smart_log **log)
{
struct nvme_command c = {
.common.opcode = nvme_admin_get_log_page,
.common.nsid = cpu_to_le32(0xFFFFFFFF),
.common.cdw10[0] = cpu_to_le32(
struct nvme_command c = { };
int error;

c.common.opcode = nvme_admin_get_log_page,
c.common.nsid = cpu_to_le32(0xFFFFFFFF),
c.common.cdw10[0] = cpu_to_le32(
(((sizeof(struct nvme_smart_log) / 4) - 1) << 16) |
NVME_LOG_SMART),
};
int error;

*log = kmalloc(sizeof(struct nvme_smart_log), GFP_KERNEL);
if (!*log)
Expand Down Expand Up @@ -1606,6 +1618,7 @@ static struct blk_mq_ops nvme_mq_admin_ops = {
.queue_rq = nvme_queue_rq,
.map_queue = blk_mq_map_queue,
.init_hctx = nvme_admin_init_hctx,
.exit_hctx = nvme_admin_exit_hctx,
.init_request = nvme_admin_init_request,
.timeout = nvme_timeout,
};
Expand Down Expand Up @@ -1648,6 +1661,7 @@ static int nvme_alloc_admin_tags(struct nvme_dev *dev)
}
if (!blk_get_queue(dev->admin_q)) {
nvme_dev_remove_admin(dev);
dev->admin_q = NULL;
return -ENODEV;
}
} else
Expand Down Expand Up @@ -2349,19 +2363,20 @@ static int nvme_dev_add(struct nvme_dev *dev)
}
kfree(ctrl);

dev->tagset.ops = &nvme_mq_ops;
dev->tagset.nr_hw_queues = dev->online_queues - 1;
dev->tagset.timeout = NVME_IO_TIMEOUT;
dev->tagset.numa_node = dev_to_node(dev->dev);
dev->tagset.queue_depth =
if (!dev->tagset.tags) {
dev->tagset.ops = &nvme_mq_ops;
dev->tagset.nr_hw_queues = dev->online_queues - 1;
dev->tagset.timeout = NVME_IO_TIMEOUT;
dev->tagset.numa_node = dev_to_node(dev->dev);
dev->tagset.queue_depth =
min_t(int, dev->q_depth, BLK_MQ_MAX_DEPTH) - 1;
dev->tagset.cmd_size = nvme_cmd_size(dev);
dev->tagset.flags = BLK_MQ_F_SHOULD_MERGE;
dev->tagset.driver_data = dev;

if (blk_mq_alloc_tag_set(&dev->tagset))
return 0;
dev->tagset.cmd_size = nvme_cmd_size(dev);
dev->tagset.flags = BLK_MQ_F_SHOULD_MERGE;
dev->tagset.driver_data = dev;

if (blk_mq_alloc_tag_set(&dev->tagset))
return 0;
}
schedule_work(&dev->scan_work);
return 0;
}
Expand Down Expand Up @@ -2734,8 +2749,10 @@ static void nvme_free_dev(struct kref *kref)
put_device(dev->device);
nvme_free_namespaces(dev);
nvme_release_instance(dev);
blk_mq_free_tag_set(&dev->tagset);
blk_put_queue(dev->admin_q);
if (dev->tagset.tags)
blk_mq_free_tag_set(&dev->tagset);
if (dev->admin_q)
blk_put_queue(dev->admin_q);
kfree(dev->queues);
kfree(dev->entry);
kfree(dev);
Expand Down Expand Up @@ -2866,6 +2883,9 @@ static int nvme_dev_start(struct nvme_dev *dev)

free_tags:
nvme_dev_remove_admin(dev);
blk_put_queue(dev->admin_q);
dev->admin_q = NULL;
dev->queues[0]->tags = NULL;
disable:
nvme_disable_queue(dev, 0);
nvme_dev_list_remove(dev);
Expand Down Expand Up @@ -2907,25 +2927,43 @@ static int nvme_dev_resume(struct nvme_dev *dev)
spin_unlock(&dev_list_lock);
} else {
nvme_unfreeze_queues(dev);
schedule_work(&dev->scan_work);
nvme_dev_add(dev);
nvme_set_irq_hints(dev);
}
return 0;
}

static void nvme_dead_ctrl(struct nvme_dev *dev)
{
dev_warn(dev->dev, "Device failed to resume\n");
kref_get(&dev->kref);
if (IS_ERR(kthread_run(nvme_remove_dead_ctrl, dev, "nvme%d",
dev->instance))) {
dev_err(dev->dev,
"Failed to start controller remove task\n");
kref_put(&dev->kref, nvme_free_dev);
}
}

static void nvme_dev_reset(struct nvme_dev *dev)
{
bool in_probe = work_busy(&dev->probe_work);

nvme_dev_shutdown(dev);
if (nvme_dev_resume(dev)) {
dev_warn(dev->dev, "Device failed to resume\n");
kref_get(&dev->kref);
if (IS_ERR(kthread_run(nvme_remove_dead_ctrl, dev, "nvme%d",
dev->instance))) {
dev_err(dev->dev,
"Failed to start controller remove task\n");
kref_put(&dev->kref, nvme_free_dev);
}

/* Synchronize with device probe so that work will see failure status
* and exit gracefully without trying to schedule another reset */
flush_work(&dev->probe_work);

/* Fail this device if reset occured during probe to avoid
* infinite initialization loops. */
if (in_probe) {
nvme_dead_ctrl(dev);
return;
}
/* Schedule device resume asynchronously so the reset work is available
* to cleanup errors that may occur during reinitialization */
schedule_work(&dev->probe_work);
}

static void nvme_reset_failed_dev(struct work_struct *ws)
Expand Down Expand Up @@ -2957,6 +2995,7 @@ static int nvme_reset(struct nvme_dev *dev)

if (!ret) {
flush_work(&dev->reset_work);
flush_work(&dev->probe_work);
return 0;
}

Expand Down Expand Up @@ -3053,26 +3092,9 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
static void nvme_async_probe(struct work_struct *work)
{
struct nvme_dev *dev = container_of(work, struct nvme_dev, probe_work);
int result;

result = nvme_dev_start(dev);
if (result)
goto reset;

if (dev->online_queues > 1)
result = nvme_dev_add(dev);
if (result)
goto reset;

nvme_set_irq_hints(dev);
return;
reset:
spin_lock(&dev_list_lock);
if (!work_busy(&dev->reset_work)) {
dev->reset_workfn = nvme_reset_failed_dev;
queue_work(nvme_workq, &dev->reset_work);
}
spin_unlock(&dev_list_lock);
if (nvme_dev_resume(dev) && !work_busy(&dev->reset_work))
nvme_dead_ctrl(dev);
}

static void nvme_reset_notify(struct pci_dev *pdev, bool prepare)
Expand Down Expand Up @@ -3104,8 +3126,8 @@ static void nvme_remove(struct pci_dev *pdev)
flush_work(&dev->reset_work);
flush_work(&dev->scan_work);
device_remove_file(dev->device, &dev_attr_reset_controller);
nvme_dev_shutdown(dev);
nvme_dev_remove(dev);
nvme_dev_shutdown(dev);
nvme_dev_remove_admin(dev);
device_destroy(nvme_class, MKDEV(nvme_char_major, dev->instance));
nvme_free_queues(dev, 0);
Expand Down
13 changes: 13 additions & 0 deletions drivers/block/xen-blkback/blkback.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ module_param_named(max_persistent_grants, xen_blkif_max_pgrants, int, 0644);
MODULE_PARM_DESC(max_persistent_grants,
"Maximum number of grants to map persistently");

/*
* Maximum order of pages to be used for the shared ring between front and
* backend, 4KB page granularity is used.
*/
unsigned int xen_blkif_max_ring_order = XENBUS_MAX_RING_PAGE_ORDER;
module_param_named(max_ring_page_order, xen_blkif_max_ring_order, int, S_IRUGO);
MODULE_PARM_DESC(max_ring_page_order, "Maximum order of pages to be used for the shared ring");
/*
* The LRU mechanism to clean the lists of persistent grants needs to
* be executed periodically. The time interval between consecutive executions
Expand Down Expand Up @@ -1438,6 +1445,12 @@ static int __init xen_blkif_init(void)
if (!xen_domain())
return -ENODEV;

if (xen_blkif_max_ring_order > XENBUS_MAX_RING_PAGE_ORDER) {
pr_info("Invalid max_ring_order (%d), will use default max: %d.\n",
xen_blkif_max_ring_order, XENBUS_MAX_RING_PAGE_ORDER);
xen_blkif_max_ring_order = XENBUS_MAX_RING_PAGE_ORDER;
}

rc = xen_blkif_interface_init();
if (rc)
goto failed_init;
Expand Down
4 changes: 3 additions & 1 deletion drivers/block/xen-blkback/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <xen/interface/io/blkif.h>
#include <xen/interface/io/protocols.h>

extern unsigned int xen_blkif_max_ring_order;
/*
* This is the maximum number of segments that would be allowed in indirect
* requests. This value will also be passed to the frontend.
Expand Down Expand Up @@ -248,7 +249,7 @@ struct backend_info;
#define PERSISTENT_GNT_WAS_ACTIVE 1

/* Number of requests that we can fit in a ring */
#define XEN_BLKIF_REQS 32
#define XEN_BLKIF_REQS_PER_PAGE 32

struct persistent_gnt {
struct page *page;
Expand Down Expand Up @@ -320,6 +321,7 @@ struct xen_blkif {
struct work_struct free_work;
/* Thread shutdown wait queue. */
wait_queue_head_t shutdown_wq;
unsigned int nr_ring_pages;
};

struct seg_buf {
Expand Down
Loading

0 comments on commit 43baed3

Please sign in to comment.