Skip to content

Commit 725f441

Browse files
nickyc975dsharma-dc
authored andcommitted
blob: use uint64_t for cluster start page index
When creating blobstore on devices with more than 16 TiB space, the start page index of clusters can execeed UINT32_MAX and result in overflow in uint32_t representation. Use uint64_t instead of uint32_t to avoid the overflow. Change-Id: I8e2586251b1b31ef7520b870af537c3f5792508e Signed-off-by: Jinlong Chen <[email protected]> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/24619 Reviewed-by: Konrad Sztyber <[email protected]> Community-CI: Broadcom CI <[email protected]> Reviewed-by: Jim Harris <[email protected]> Community-CI: Mellanox Build Bot Reviewed-by: Changpeng Liu <[email protected]> Tested-by: SPDK CI Jenkins <[email protected]> Reviewed-by: GangCao <[email protected]>
1 parent 6fa3420 commit 725f441

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/blob/blobstore.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2830,7 +2830,7 @@ blob_write_copy(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
28302830
}
28312831

28322832
static bool
2833-
blob_can_copy(struct spdk_blob *blob, uint32_t cluster_start_page, uint64_t *base_lba)
2833+
blob_can_copy(struct spdk_blob *blob, uint64_t cluster_start_page, uint64_t *base_lba)
28342834
{
28352835
uint64_t lba = bs_dev_page_to_lba(blob->back_bs_dev, cluster_start_page);
28362836

@@ -2859,7 +2859,7 @@ bs_allocate_and_copy_cluster(struct spdk_blob *blob,
28592859
struct spdk_bs_cpl cpl;
28602860
struct spdk_bs_channel *ch;
28612861
struct spdk_blob_copy_cluster_ctx *ctx;
2862-
uint32_t cluster_start_page;
2862+
uint64_t cluster_start_page;
28632863
uint32_t cluster_number;
28642864
bool is_zeroes;
28652865
bool can_copy;
@@ -3296,7 +3296,7 @@ blob_request_submit_op_single(struct spdk_io_channel *_ch, struct spdk_blob *blo
32963296
if (spdk_blob_is_thin_provisioned(blob) && is_allocated &&
32973297
bs_io_units_per_cluster(blob) == length && g_cluster_unmap_enabled) {
32983298
struct spdk_bs_channel *bs_channel = spdk_io_channel_get_ctx(_ch);
3299-
uint32_t cluster_start_page;
3299+
uint64_t cluster_start_page;
33003300
uint32_t cluster_number;
33013301

33023302
assert(offset % bs_io_units_per_cluster(blob) == 0);

lib/blob/blobstore.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ bs_num_io_units_to_cluster_boundary(struct spdk_blob *blob, uint64_t io_unit)
637637
}
638638

639639
/* Given an io_unit offset into a blob, look up the number of pages into blob to beginning of current cluster */
640-
static inline uint32_t
640+
static inline uint64_t
641641
bs_io_unit_to_cluster_start(struct spdk_blob *blob, uint64_t io_unit)
642642
{
643643
uint64_t pages_per_cluster;
@@ -655,7 +655,7 @@ bs_io_unit_to_cluster_number(struct spdk_blob *blob, uint64_t io_unit)
655655
{
656656
uint64_t pages_per_cluster = blob->bs->pages_per_cluster;
657657
uint8_t shift = blob->bs->pages_per_cluster_shift;
658-
uint32_t page_offset;
658+
uint64_t page_offset;
659659

660660
page_offset = io_unit / bs_io_unit_per_page(blob->bs);
661661
if (shift != 0) {

0 commit comments

Comments
 (0)