nvmet: fix building bvec from sg list
authorMing Lei <ming.lei@redhat.com>
Wed, 27 Mar 2019 09:07:22 +0000 (17:07 +0800)
committerChristoph Hellwig <hch@lst.de>
Thu, 28 Mar 2019 17:15:02 +0000 (18:15 +0100)
commit02db99548d3608a625cf481cff2bb7b626829b3f
tree9ca7acd23830eb71cd449c9a58d1d88d02d6fb86
parentcc2278c413c3a06a93c23ee8722e4dd3d621de12
nvmet: fix building bvec from sg list

There are two mistakes for building bvec from sg list for file
backed ns:

- use request data length to compute number of io vector, this way
doesn't consider sg->offset, and the result may be smaller than required
io vectors

- bvec->bv_len isn't capped by sg->length

This patch fixes this issue by building bvec from sg directly, given
the whole IO stack is ready for multi-page bvec.

Reported-by: Yi Zhang <yi.zhang@redhat.com>
Fixes: 3a85a5de29ea ("nvme-loop: add a NVMe loopback host driver")

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/target/io-cmd-file.c