From 50cbc74a82f9e3dc40b4e82727254cb97b8dc77e Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Fri, 4 Aug 2017 14:57:17 -0700 Subject: [PATCH] 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 Reviewed-on: https://review.gerrithub.io/372862 Reviewed-by: Ben Walker Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris --- lib/bdev/nvme/bdev_nvme.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/lib/bdev/nvme/bdev_nvme.c b/lib/bdev/nvme/bdev_nvme.c index 45332b691..7b876f1ee 100644 --- a/lib/bdev/nvme/bdev_nvme.c +++ b/lib/bdev/nvme/bdev_nvme.c @@ -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;