From 1f49ee235f29ecb409b91ab3b2e22a837f33e950 Mon Sep 17 00:00:00 2001 From: Niklas Cassel Date: Fri, 19 Feb 2021 14:14:51 +0000 Subject: [PATCH] nvme: only reassign start_valid if we fetched a new SGE For a SGL using PRPs, there is always an alignment check of the start address in the beginning of the loop. This is stored in start_valid. If the start is indeed valid, we might fetch a new SGE, and then perform a second alignment check on this new SGE. However, this second alignment check is done unconditionally, meaning that for the last SGE in a request, we check if the same start address is aligned twice. Only perform the second alignment check if we actually fetched a new SGE. Signed-off-by: Niklas Cassel Change-Id: I9df8038c650b0879f838d1d9d895e8dd7172840d Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6493 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto Reviewed-by: Aleksey Marchuk --- lib/nvme/nvme_ns_cmd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/nvme/nvme_ns_cmd.c b/lib/nvme/nvme_ns_cmd.c index d3e27c7db..6441853df 100644 --- a/lib/nvme/nvme_ns_cmd.c +++ b/lib/nvme/nvme_ns_cmd.c @@ -253,13 +253,13 @@ _nvme_ns_cmd_split_request_prp(struct spdk_nvme_ns *ns, req_current_length += sge_length; if (req_current_length < req->payload_size) { next_sge_fn(sgl_cb_arg, (void **)&address, &sge_length); + /* + * If the next SGE is not page aligned, we will need to create a + * child request for what we have so far, and then start a new + * child request for the next SGE. + */ + start_valid = _is_page_aligned(address, page_size); } - /* - * If the next SGE is not page aligned, we will need to create a child - * request for what we have so far, and then start a new child request for - * the next SGE. - */ - start_valid = _is_page_aligned(address, page_size); } if (start_valid && end_valid && !last_sge) {