* [PATCH] NVMe: queue usage fixes in nvme-scsi
@ 2013-04-25 20:39 Keith Busch
2013-04-29 16:24 ` Vishal Verma
0 siblings, 1 reply; 2+ messages in thread
From: Keith Busch @ 2013-04-25 20:39 UTC (permalink / raw)
Fixes nvme queue usages in scsi-to-nvme translation code to not get
a queue more often than it is being put, and not use the queue in an
unsafe way without it being locked.
Signed-off-by: Keith Busch <keith.busch at intel.com>
---
drivers/block/nvme-scsi.c | 25 ++++++++++++++++++++-----
1 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/drivers/block/nvme-scsi.c b/drivers/block/nvme-scsi.c
index bbfb288..913de0a 100644
--- a/drivers/block/nvme-scsi.c
+++ b/drivers/block/nvme-scsi.c
@@ -2039,7 +2039,7 @@ static int nvme_trans_do_nvme_io(struct nvme_ns *ns, struct sg_io_hdr *hdr,
int res = SNTI_TRANSLATION_SUCCESS;
int nvme_sc;
struct nvme_dev *dev = ns->dev;
- struct nvme_queue *nvmeq = get_nvmeq(ns->dev);
+ struct nvme_queue *nvmeq;
u32 num_cmds;
struct nvme_iod *iod;
u64 unit_len;
@@ -2653,7 +2653,8 @@ static int nvme_trans_start_stop(struct nvme_ns *ns, struct sg_io_hdr *hdr,
{
int res = SNTI_TRANSLATION_SUCCESS;
int nvme_sc;
- struct nvme_queue *nvmeq = get_nvmeq(ns->dev);
+ struct nvme_queue *nvmeq;
+ struct nvme_command c;
u8 immed, pcmod, pc, no_flush, start;
immed = GET_U8_FROM_CDB(cmd, START_STOP_UNIT_CDB_IMMED_OFFSET);
@@ -2675,8 +2676,14 @@ static int nvme_trans_start_stop(struct nvme_ns *ns, struct sg_io_hdr *hdr,
} else {
if (no_flush == 0) {
/* Issue NVME FLUSH command prior to START STOP UNIT */
- nvme_sc = nvme_submit_flush_data(nvmeq, ns);
+ memset(&c, 0, sizeof(c));
+ c.common.opcode = nvme_cmd_flush;
+ c.common.nsid = cpu_to_le32(ns->ns_id);
+
+ nvmeq = get_nvmeq(ns->dev);
put_nvmeq(nvmeq);
+ nvme_sc = nvme_submit_sync_cmd(nvmeq, &c, NULL, NVME_IO_TIMEOUT);
+
res = nvme_trans_status_code(hdr, nvme_sc);
if (res)
goto out;
@@ -2698,9 +2705,17 @@ static int nvme_trans_synchronize_cache(struct nvme_ns *ns,
{
int res = SNTI_TRANSLATION_SUCCESS;
int nvme_sc;
- struct nvme_queue *nvmeq = get_nvmeq(ns->dev);
+ struct nvme_command c;
+ struct nvme_queue *nvmeq;
+
+ memset(&c, 0, sizeof(c));
+ c.common.opcode = nvme_cmd_flush;
+ c.common.nsid = cpu_to_le32(ns->ns_id);
+
+ nvmeq = get_nvmeq(ns->dev);
put_nvmeq(nvmeq);
- nvme_sc = nvme_submit_flush_data(nvmeq, ns);
+ nvme_sc = nvme_submit_sync_cmd(nvmeq, &c, NULL, NVME_IO_TIMEOUT);
+
res = nvme_trans_status_code(hdr, nvme_sc);
if (res)
goto out;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH] NVMe: queue usage fixes in nvme-scsi
2013-04-25 20:39 [PATCH] NVMe: queue usage fixes in nvme-scsi Keith Busch
@ 2013-04-29 16:24 ` Vishal Verma
0 siblings, 0 replies; 2+ messages in thread
From: Vishal Verma @ 2013-04-29 16:24 UTC (permalink / raw)
Acked-by: Vishal Verma <vishal.l.verma at linux.intel.com>
On Thu, 2013-04-25@14:39 -0600, Keith Busch wrote:
> Fixes nvme queue usages in scsi-to-nvme translation code to not get
> a queue more often than it is being put, and not use the queue in an
> unsafe way without it being locked.
>
> Signed-off-by: Keith Busch <keith.busch at intel.com>
> ---
> drivers/block/nvme-scsi.c | 25 ++++++++++++++++++++-----
> 1 files changed, 20 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/block/nvme-scsi.c b/drivers/block/nvme-scsi.c
> index bbfb288..913de0a 100644
> --- a/drivers/block/nvme-scsi.c
> +++ b/drivers/block/nvme-scsi.c
> @@ -2039,7 +2039,7 @@ static int nvme_trans_do_nvme_io(struct nvme_ns *ns, struct sg_io_hdr *hdr,
> int res = SNTI_TRANSLATION_SUCCESS;
> int nvme_sc;
> struct nvme_dev *dev = ns->dev;
> - struct nvme_queue *nvmeq = get_nvmeq(ns->dev);
> + struct nvme_queue *nvmeq;
> u32 num_cmds;
> struct nvme_iod *iod;
> u64 unit_len;
> @@ -2653,7 +2653,8 @@ static int nvme_trans_start_stop(struct nvme_ns *ns, struct sg_io_hdr *hdr,
> {
> int res = SNTI_TRANSLATION_SUCCESS;
> int nvme_sc;
> - struct nvme_queue *nvmeq = get_nvmeq(ns->dev);
> + struct nvme_queue *nvmeq;
> + struct nvme_command c;
> u8 immed, pcmod, pc, no_flush, start;
>
> immed = GET_U8_FROM_CDB(cmd, START_STOP_UNIT_CDB_IMMED_OFFSET);
> @@ -2675,8 +2676,14 @@ static int nvme_trans_start_stop(struct nvme_ns *ns, struct sg_io_hdr *hdr,
> } else {
> if (no_flush == 0) {
> /* Issue NVME FLUSH command prior to START STOP UNIT */
> - nvme_sc = nvme_submit_flush_data(nvmeq, ns);
> + memset(&c, 0, sizeof(c));
> + c.common.opcode = nvme_cmd_flush;
> + c.common.nsid = cpu_to_le32(ns->ns_id);
> +
> + nvmeq = get_nvmeq(ns->dev);
> put_nvmeq(nvmeq);
> + nvme_sc = nvme_submit_sync_cmd(nvmeq, &c, NULL, NVME_IO_TIMEOUT);
> +
> res = nvme_trans_status_code(hdr, nvme_sc);
> if (res)
> goto out;
> @@ -2698,9 +2705,17 @@ static int nvme_trans_synchronize_cache(struct nvme_ns *ns,
> {
> int res = SNTI_TRANSLATION_SUCCESS;
> int nvme_sc;
> - struct nvme_queue *nvmeq = get_nvmeq(ns->dev);
> + struct nvme_command c;
> + struct nvme_queue *nvmeq;
> +
> + memset(&c, 0, sizeof(c));
> + c.common.opcode = nvme_cmd_flush;
> + c.common.nsid = cpu_to_le32(ns->ns_id);
> +
> + nvmeq = get_nvmeq(ns->dev);
> put_nvmeq(nvmeq);
> - nvme_sc = nvme_submit_flush_data(nvmeq, ns);
> + nvme_sc = nvme_submit_sync_cmd(nvmeq, &c, NULL, NVME_IO_TIMEOUT);
> +
> res = nvme_trans_status_code(hdr, nvme_sc);
> if (res)
> goto out;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-04-29 16:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-25 20:39 [PATCH] NVMe: queue usage fixes in nvme-scsi Keith Busch
2013-04-29 16:24 ` Vishal Verma
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).