diff --git a/lib/bdev/gpt/gpt.h b/lib/bdev/gpt/gpt.h index afd64ce46f..923bdc1c01 100644 --- a/lib/bdev/gpt/gpt.h +++ b/lib/bdev/gpt/gpt.h @@ -48,6 +48,7 @@ struct spdk_gpt { unsigned char *buf; + uint64_t buf_size; uint64_t lba_start; uint64_t lba_end; uint64_t total_sectors; diff --git a/lib/bdev/gpt/vbdev_gpt.c b/lib/bdev/gpt/vbdev_gpt.c index 1cae051d3c..2dd6a0f371 100644 --- a/lib/bdev/gpt/vbdev_gpt.c +++ b/lib/bdev/gpt/vbdev_gpt.c @@ -132,7 +132,8 @@ spdk_gpt_base_bdev_init(struct spdk_bdev *bdev) } gpt = &gpt_base->gpt; - gpt->buf = spdk_dma_zmalloc(SPDK_GPT_BUFFER_SIZE, 0x1000, NULL); + gpt->buf_size = spdk_max(SPDK_GPT_BUFFER_SIZE, bdev->blocklen); + gpt->buf = spdk_dma_zmalloc(gpt->buf_size, 0x1000, NULL); if (!gpt->buf) { SPDK_ERRLOG("Cannot alloc buf\n"); spdk_bdev_part_base_free(&gpt_base->part_base); @@ -342,7 +343,7 @@ vbdev_gpt_read_gpt(struct spdk_bdev *bdev) } rc = spdk_bdev_read(gpt_base->part_base.desc, gpt_base->ch, gpt_base->gpt.buf, 0, - SPDK_GPT_BUFFER_SIZE, spdk_gpt_bdev_complete, gpt_base); + gpt_base->gpt.buf_size, spdk_gpt_bdev_complete, gpt_base); if (rc < 0) { spdk_put_io_channel(gpt_base->ch); spdk_bdev_part_base_free(&gpt_base->part_base);