Commit 9f7d8ae2 authored by James Smart's avatar James Smart Committed by Jens Axboe

nvme-fc: use nr_phys_segments to determine existence of sgl

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: default avatarChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: default avatarJames Smart <jsmart2021@gmail.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent d11de63f
...@@ -2107,7 +2107,7 @@ nvme_fc_map_data(struct nvme_fc_ctrl *ctrl, struct request *rq, ...@@ -2107,7 +2107,7 @@ nvme_fc_map_data(struct nvme_fc_ctrl *ctrl, struct request *rq,
freq->sg_cnt = 0; freq->sg_cnt = 0;
if (!blk_rq_payload_bytes(rq)) if (!blk_rq_nr_phys_segments(rq))
return 0; return 0;
freq->sg_table.sgl = freq->first_sgl; freq->sg_table.sgl = freq->first_sgl;
...@@ -2304,12 +2304,23 @@ nvme_fc_queue_rq(struct blk_mq_hw_ctx *hctx, ...@@ -2304,12 +2304,23 @@ nvme_fc_queue_rq(struct blk_mq_hw_ctx *hctx,
if (ret) if (ret)
return ret; return ret;
/*
* 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); data_len = blk_rq_payload_bytes(rq);
if (data_len)
io_dir = ((rq_data_dir(rq) == WRITE) ? io_dir = ((rq_data_dir(rq) == WRITE) ?
NVMEFC_FCP_WRITE : NVMEFC_FCP_READ); NVMEFC_FCP_WRITE : NVMEFC_FCP_READ);
else } else {
data_len = 0;
io_dir = NVMEFC_FCP_NODATA; io_dir = NVMEFC_FCP_NODATA;
}
return nvme_fc_start_fcp_op(ctrl, queue, op, data_len, io_dir); return nvme_fc_start_fcp_op(ctrl, queue, op, data_len, io_dir);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment