From aac30ff3f468de73faa08d139b7c8eb508d720af Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Tue, 8 Nov 2016 23:00:43 -0700 Subject: [PATCH] bdev/nvme: reorganize queued_next_sge() No functional change, but removes a few assumptions that will be invalid in a future patch that fixes a bug in this function. Primarily we no longer assume that this function will always increment the iovpos and reset iov_offset to 0. Signed-off-by: Jim Harris Change-Id: I770f2f24c37626063e113af850a2af792aed332a --- lib/bdev/nvme/blockdev_nvme.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/bdev/nvme/blockdev_nvme.c b/lib/bdev/nvme/blockdev_nvme.c index fe1d51888..61ee35ab8 100644 --- a/lib/bdev/nvme/blockdev_nvme.c +++ b/lib/bdev/nvme/blockdev_nvme.c @@ -648,7 +648,6 @@ queued_next_sge(void *ref, void **address, uint32_t *length) assert(bio->iovpos < bio->iovcnt); iov = &bio->iovs[bio->iovpos]; - bio->iovpos++; *address = iov->iov_base; *length = iov->iov_len; @@ -657,6 +656,11 @@ queued_next_sge(void *ref, void **address, uint32_t *length) assert(bio->iov_offset <= iov->iov_len); *address += bio->iov_offset; *length -= bio->iov_offset; + } + + bio->iov_offset += *length; + if (bio->iov_offset == iov->iov_len) { + bio->iovpos++; bio->iov_offset = 0; }