bdev/nvme: simplify I/O command block size math

Remove the redundant sector size check; the generic bdev code already
checks for this.

Also use the bdev blocklen field for both offset and size calculations.
The bdev blocklen is the same as the namespace sector size.

Change-Id: Ia8061eb4cfc229d4b6fbe2caabf2dd81656bc697
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/372862
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Daniel Verkamp 2017-08-04 14:57:17 -07:00
parent 3754eedc9b
commit 50cbc74a82

View File

@ -1200,19 +1200,10 @@ bdev_nvme_queue_cmd(struct nvme_bdev *bdev, struct spdk_nvme_qpair *qpair,
int direction, struct iovec *iov, int iovcnt, uint64_t nbytes, int direction, struct iovec *iov, int iovcnt, uint64_t nbytes,
uint64_t offset) uint64_t offset)
{ {
uint32_t ss = spdk_nvme_ns_get_sector_size(bdev->ns); uint32_t lba_count = nbytes / bdev->disk.blocklen;
uint32_t lba_count;
uint64_t lba = offset / bdev->disk.blocklen; uint64_t lba = offset / bdev->disk.blocklen;
int rc; int rc;
if (nbytes % ss) {
SPDK_ERRLOG("Unaligned IO request length\n");
return -EINVAL;
}
lba_count = nbytes / ss;
bio->iovs = iov; bio->iovs = iov;
bio->iovcnt = iovcnt; bio->iovcnt = iovcnt;
bio->iovpos = 0; bio->iovpos = 0;
@ -1244,11 +1235,6 @@ bdev_nvme_unmap(struct nvme_bdev *nbdev, struct spdk_io_channel *ch,
int rc = 0; int rc = 0;
struct spdk_nvme_dsm_range dsm_range = {}; struct spdk_nvme_dsm_range dsm_range = {};
if (nbytes % nbdev->disk.blocklen) {
SPDK_ERRLOG("Unaligned IO request length\n");
return -EINVAL;
}
dsm_range.starting_lba = offset / nbdev->disk.blocklen; dsm_range.starting_lba = offset / nbdev->disk.blocklen;
dsm_range.length = nbytes / nbdev->disk.blocklen; dsm_range.length = nbytes / nbdev->disk.blocklen;