From: Christoph Hellwig <hch@lst.de> To: Jens Axboe <axboe@kernel.dk> Cc: Keith Busch <keith.busch@intel.com>, Sagi Grimberg <sagi@grimberg.me>, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, James Smart <jsmart2021@gmail.com>, Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Subject: [PATCH 07/17] nvme-fc: use nr_phys_segments to determine existence of sgl Date: Wed, 13 Mar 2019 18:55:00 +0100 [thread overview] Message-ID: <20190313175510.20725-8-hch@lst.de> (raw) In-Reply-To: <20190313175510.20725-1-hch@lst.de> From: James Smart <jsmart2021@gmail.com> For some nvme command, when issued by the nvme core layer, there is an internal buffer which can cause blk_rq_payload_bytes() to return a non-zero value yet there is no actual/real command payload and sg list. An example is the WRITE ZEROES command. To address this, when making choices on whether to dma map an sgl, use blk_rq_nr_phys_segments() instead of blk_rq_payload_bytes(). When there is a sgl, blk_rq_payload_bytes() will return the amount of data to be transferred by the sgl. Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Signed-off-by: James Smart <jsmart2021@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de> --- drivers/nvme/host/fc.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index b29b12498a1a..ba8f2a9cbdaf 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -2107,7 +2107,7 @@ nvme_fc_map_data(struct nvme_fc_ctrl *ctrl, struct request *rq, freq->sg_cnt = 0; - if (!blk_rq_payload_bytes(rq)) + if (!blk_rq_nr_phys_segments(rq)) return 0; freq->sg_table.sgl = freq->first_sgl; @@ -2304,12 +2304,23 @@ nvme_fc_queue_rq(struct blk_mq_hw_ctx *hctx, if (ret) return ret; - data_len = blk_rq_payload_bytes(rq); - if (data_len) + /* + * nvme core doesn't quite treat the rq opaquely. Commands such + * as WRITE ZEROES will return a non-zero rq payload_bytes yet + * there is no actual payload to be transferred. + * To get it right, key data transmission on there being 1 or + * more physical segments in the sg list. If there is no + * physical segments, there is no payload. + */ + if (blk_rq_nr_phys_segments(rq)) { + data_len = blk_rq_payload_bytes(rq); io_dir = ((rq_data_dir(rq) == WRITE) ? NVMEFC_FCP_WRITE : NVMEFC_FCP_READ); - else + } else { + data_len = 0; io_dir = NVMEFC_FCP_NODATA; + } + return nvme_fc_start_fcp_op(ctrl, queue, op, data_len, io_dir); } -- 2.20.1
WARNING: multiple messages have this Message-ID (diff)
From: hch@lst.de (Christoph Hellwig) Subject: [PATCH 07/17] nvme-fc: use nr_phys_segments to determine existence of sgl Date: Wed, 13 Mar 2019 18:55:00 +0100 [thread overview] Message-ID: <20190313175510.20725-8-hch@lst.de> (raw) In-Reply-To: <20190313175510.20725-1-hch@lst.de> From: James Smart <jsmart2021@gmail.com> For some nvme command, when issued by the nvme core layer, there is an internal buffer which can cause blk_rq_payload_bytes() to return a non-zero value yet there is no actual/real command payload and sg list. An example is the WRITE ZEROES command. To address this, when making choices on whether to dma map an sgl, use blk_rq_nr_phys_segments() instead of blk_rq_payload_bytes(). When there is a sgl, blk_rq_payload_bytes() will return the amount of data to be transferred by the sgl. Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com> Signed-off-by: James Smart <jsmart2021 at gmail.com> Signed-off-by: Christoph Hellwig <hch at lst.de> --- drivers/nvme/host/fc.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index b29b12498a1a..ba8f2a9cbdaf 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -2107,7 +2107,7 @@ nvme_fc_map_data(struct nvme_fc_ctrl *ctrl, struct request *rq, freq->sg_cnt = 0; - if (!blk_rq_payload_bytes(rq)) + if (!blk_rq_nr_phys_segments(rq)) return 0; freq->sg_table.sgl = freq->first_sgl; @@ -2304,12 +2304,23 @@ nvme_fc_queue_rq(struct blk_mq_hw_ctx *hctx, if (ret) return ret; - data_len = blk_rq_payload_bytes(rq); - if (data_len) + /* + * nvme core doesn't quite treat the rq opaquely. Commands such + * as WRITE ZEROES will return a non-zero rq payload_bytes yet + * there is no actual payload to be transferred. + * To get it right, key data transmission on there being 1 or + * more physical segments in the sg list. If there is no + * physical segments, there is no payload. + */ + if (blk_rq_nr_phys_segments(rq)) { + data_len = blk_rq_payload_bytes(rq); io_dir = ((rq_data_dir(rq) == WRITE) ? NVMEFC_FCP_WRITE : NVMEFC_FCP_READ); - else + } else { + data_len = 0; io_dir = NVMEFC_FCP_NODATA; + } + return nvme_fc_start_fcp_op(ctrl, queue, op, data_len, io_dir); } -- 2.20.1
next prev parent reply other threads:[~2019-03-13 17:55 UTC|newest] Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-03-13 17:54 [PATCHBOMB] nvme fixes for 5.1 Christoph Hellwig 2019-03-13 17:54 ` Christoph Hellwig 2019-03-13 17:54 ` [PATCH 01/17] nvme: add get-feature to admin cmds tracer Christoph Hellwig 2019-03-13 17:54 ` Christoph Hellwig 2019-03-13 17:54 ` [PATCH 02/17] nvme: don't warn on block content change effects Christoph Hellwig 2019-03-13 17:54 ` Christoph Hellwig 2019-03-13 17:54 ` [PATCH 03/17] nvme-trace: fix cdw10 buffer overrun Christoph Hellwig 2019-03-13 17:54 ` Christoph Hellwig 2019-03-13 17:54 ` [PATCH 04/17] nvme: put ns_head ref if namespace fails allocation Christoph Hellwig 2019-03-13 17:54 ` Christoph Hellwig 2019-03-13 17:54 ` [PATCH 05/17] nvme: update comment to make the code easier to read Christoph Hellwig 2019-03-13 17:54 ` Christoph Hellwig 2019-03-13 17:54 ` [PATCH 06/17] nvme-loop: init nvmet_ctrl fatal_err_work when allocate Christoph Hellwig 2019-03-13 17:54 ` Christoph Hellwig 2019-03-13 17:55 ` Christoph Hellwig [this message] 2019-03-13 17:55 ` [PATCH 07/17] nvme-fc: use nr_phys_segments to determine existence of sgl Christoph Hellwig 2019-03-14 9:57 ` Max Gurtovoy 2019-03-14 9:57 ` Max Gurtovoy 2019-03-14 21:43 ` Sagi Grimberg 2019-03-14 21:43 ` Sagi Grimberg 2019-03-13 17:55 ` [PATCH 08/17] nvme-fc: fix numa_node when dev is null Christoph Hellwig 2019-03-13 17:55 ` Christoph Hellwig 2019-03-13 17:55 ` [PATCH 09/17] nvme-fc: reject reconnect if io queue count is reduced to zero Christoph Hellwig 2019-03-13 17:55 ` Christoph Hellwig 2019-03-13 17:55 ` [PATCH 10/17] nvmet-fc: fix issues with targetport assoc_list list walking Christoph Hellwig 2019-03-13 17:55 ` Christoph Hellwig 2019-03-13 18:53 ` James Smart 2019-03-13 18:53 ` James Smart 2019-03-13 18:58 ` Jens Axboe 2019-03-13 18:58 ` Jens Axboe 2019-03-13 17:55 ` [PATCH 11/17] nvmet-fc: bring Disconnect into compliance with FC-NVME spec Christoph Hellwig 2019-03-13 17:55 ` Christoph Hellwig 2019-03-13 17:55 ` [PATCH 12/17] nvme: disable Write Zeroes for qemu controllers Christoph Hellwig 2019-03-13 17:55 ` Christoph Hellwig 2019-03-13 17:55 ` [PATCH 13/17] nvme: remove nvme_ns_config_oncs Christoph Hellwig 2019-03-13 17:55 ` Christoph Hellwig 2019-03-13 17:55 ` [PATCH 14/17] nvme: add proper discard setup for the multipath device Christoph Hellwig 2019-03-13 17:55 ` Christoph Hellwig 2019-03-13 17:55 ` [PATCH 15/17] nvme: add proper write zeroes " Christoph Hellwig 2019-03-13 17:55 ` Christoph Hellwig 2019-03-13 17:55 ` [PATCH 16/17] nvmet: ignore EOPNOTSUPP for discard Christoph Hellwig 2019-03-13 17:55 ` Christoph Hellwig 2019-03-13 17:55 ` [PATCH 17/17] nvme-tcp: support C2HData with SUCCESS flag Christoph Hellwig 2019-03-13 17:55 ` Christoph Hellwig 2019-03-13 19:12 ` Sagi Grimberg 2019-03-13 19:12 ` Sagi Grimberg 2019-03-13 19:14 ` Sagi Grimberg 2019-03-13 19:14 ` Sagi Grimberg 2019-03-13 18:06 ` [PATCHBOMB] nvme fixes for 5.1 Jens Axboe 2019-03-13 18:06 ` Jens Axboe
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190313175510.20725-8-hch@lst.de \ --to=hch@lst.de \ --cc=axboe@kernel.dk \ --cc=chaitanya.kulkarni@wdc.com \ --cc=jsmart2021@gmail.com \ --cc=keith.busch@intel.com \ --cc=linux-block@vger.kernel.org \ --cc=linux-nvme@lists.infradead.org \ --cc=sagi@grimberg.me \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.