libnvme: Add better asserts in SGL-to-PRP request conversion.
Taken from upstream (SPDK).
This commit is contained in:
parent
b0460580c5
commit
9a3a70f437
@ -687,6 +687,12 @@ static int _nvme_qpair_build_prps_sgl_request(struct nvme_qpair *qpair,
|
||||
return -1;
|
||||
}
|
||||
|
||||
nvme_assert((phys_addr & 0x3) == 0, "address must be dword aligned\n");
|
||||
nvme_assert((length >= remaining_transfer_len) || ((phys_addr + length) % PAGE_SIZE) == 0,
|
||||
"All SGEs except last must end on a page boundary\n");
|
||||
nvme_assert((sge_count == 0) || (phys_addr % PAGE_SIZE) == 0,
|
||||
"All SGEs except first must start on a page boundary\n");
|
||||
|
||||
data_transferred = nvme_min(remaining_transfer_len, length);
|
||||
|
||||
nseg = data_transferred >> PAGE_SHIFT;
|
||||
@ -732,18 +738,6 @@ static int _nvme_qpair_build_prps_sgl_request(struct nvme_qpair *qpair,
|
||||
}
|
||||
last_nseg++;
|
||||
cur_nseg++;
|
||||
|
||||
/* physical address and length check */
|
||||
if (remaining_transfer_len ||
|
||||
(!remaining_transfer_len &&
|
||||
(cur_nseg < nseg))) {
|
||||
if ((length & (PAGE_SIZE - 1)) ||
|
||||
unaligned) {
|
||||
_nvme_qpair_req_bad_phys(qpair,
|
||||
tr);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user