Commit 50cbc74a authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

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: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/372862


Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 3754eedc
Loading
Loading
Loading
Loading
+1 −15
Original line number Diff line number Diff line
@@ -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,
		    uint64_t offset)
{
	uint32_t ss = spdk_nvme_ns_get_sector_size(bdev->ns);
	uint32_t lba_count;
	uint32_t lba_count = nbytes / bdev->disk.blocklen;
	uint64_t lba = offset / bdev->disk.blocklen;
	int rc;

	if (nbytes % ss) {
		SPDK_ERRLOG("Unaligned IO request length\n");
		return -EINVAL;
	}


	lba_count = nbytes / ss;

	bio->iovs = iov;
	bio->iovcnt = iovcnt;
	bio->iovpos = 0;
@@ -1244,11 +1235,6 @@ bdev_nvme_unmap(struct nvme_bdev *nbdev, struct spdk_io_channel *ch,
	int rc = 0;
	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.length = nbytes / nbdev->disk.blocklen;