From 001edfaabf0fb1fbebcd909ee46e3a936bdfa23c Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Wed, 20 Jun 2018 09:20:25 -0700 Subject: [PATCH] blob: change lba to uint64_t in serialize_extent Make sure we don't truncate the LBA when using it to serialize the cluster array into an extent list. We also need to add an explicit cast in _spdk_bs_cluster_to_lba to ensure the conversion doesn't get truncated. While here, do the same cast for _spdk_bs_cluster_to_page. Cherry-pick of commit 89426e9bb57e from master. Change-Id: I4fff3ea8248b012bacfda92765088c868efcb218 Signed-off-by: Daniel Verkamp Signed-off-by: Jim Harris Reviewed-on: https://review.gerrithub.io/416231 Tested-by: SPDK Automated Test System Reviewed-by: Ben Walker Reviewed-on: https://review.gerrithub.io/416562 --- lib/blob/blobstore.c | 2 +- lib/blob/blobstore.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/blob/blobstore.c b/lib/blob/blobstore.c index 22c3aa6e2..bc2e3c630 100644 --- a/lib/blob/blobstore.c +++ b/lib/blob/blobstore.c @@ -566,7 +566,7 @@ _spdk_blob_serialize_extent(const struct spdk_blob *blob, struct spdk_blob_md_descriptor_extent *desc; size_t cur_sz; uint64_t i, extent_idx; - uint32_t lba, lba_per_cluster, lba_count; + uint64_t lba, lba_per_cluster, lba_count; /* The buffer must have room for at least one extent */ cur_sz = sizeof(struct spdk_blob_md_descriptor) + sizeof(desc->extents[0]); diff --git a/lib/blob/blobstore.h b/lib/blob/blobstore.h index bd399f1ce..bc95f177f 100644 --- a/lib/blob/blobstore.h +++ b/lib/blob/blobstore.h @@ -426,7 +426,7 @@ _spdk_bs_dev_lba_to_page(struct spdk_bs_dev *bs_dev, uint64_t lba) static inline uint64_t _spdk_bs_cluster_to_page(struct spdk_blob_store *bs, uint32_t cluster) { - return cluster * bs->pages_per_cluster; + return (uint64_t)cluster * bs->pages_per_cluster; } static inline uint32_t @@ -440,7 +440,7 @@ _spdk_bs_page_to_cluster(struct spdk_blob_store *bs, uint64_t page) static inline uint64_t _spdk_bs_cluster_to_lba(struct spdk_blob_store *bs, uint32_t cluster) { - return cluster * (bs->cluster_sz / bs->dev->blocklen); + return (uint64_t)cluster * (bs->cluster_sz / bs->dev->blocklen); } static inline uint32_t