From a4b348124299a3abdae0c5e5893a8199a70d8db3 Mon Sep 17 00:00:00 2001 From: Mateusz Kozlowski Date: Tue, 2 Jul 2019 09:33:38 +0200 Subject: [PATCH] lib/ftl: Remove buffer alignment requirements Ftl should no longer require 4k alignment for I/O buffers for either internal or external requests. The 4k alignment was needed due to a bug in QEMU when handling internal SGL buffers in LNVM commands. Signed-off-by: Mateusz Kozlowski Change-Id: Icafc14b7811c9c0ffa13789e341c453503cf2821 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/460106 Tested-by: SPDK CI Jenkins Reviewed-by: Wojciech Malikowski Reviewed-by: Ben Walker Reviewed-by: Darek Stojaczyk Reviewed-by: Konrad Sztyber --- lib/bdev/nvme/bdev_ftl.c | 2 -- lib/ftl/ftl_band.c | 3 +-- lib/ftl/ftl_restore.c | 11 ++--------- lib/ftl/ftl_rwb.c | 3 +-- 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/lib/bdev/nvme/bdev_ftl.c b/lib/bdev/nvme/bdev_ftl.c index c19ab3e8d..793366441 100644 --- a/lib/bdev/nvme/bdev_ftl.c +++ b/lib/bdev/nvme/bdev_ftl.c @@ -725,8 +725,6 @@ bdev_ftl_create_cb(struct spdk_ftl_dev *dev, void *ctx, int status) ftl_bdev->bdev.write_cache = 0; ftl_bdev->bdev.blocklen = attrs.lbk_size; ftl_bdev->bdev.blockcnt = attrs.lbk_cnt; - /* TODO: Investigate why nbd test are failing without this alignment */ - ftl_bdev->bdev.required_alignment = spdk_u32log2(attrs.lbk_size); ftl_bdev->bdev.uuid = attrs.uuid; SPDK_DEBUGLOG(SPDK_LOG_BDEV_FTL, "Creating bdev %s:\n", ftl_bdev->bdev.name); diff --git a/lib/ftl/ftl_band.c b/lib/ftl/ftl_band.c index 9b2b82c20..f5b2f1471 100644 --- a/lib/ftl/ftl_band.c +++ b/lib/ftl/ftl_band.c @@ -698,8 +698,7 @@ ftl_band_alloc_lba_map(struct ftl_band *band) lba_map->segments = (char *)lba_map->map + ftl_lba_map_num_lbks(dev) * FTL_BLOCK_SIZE; - lba_map->dma_buf = spdk_dma_zmalloc(ftl_tail_md_num_lbks(dev) * FTL_BLOCK_SIZE, - FTL_BLOCK_SIZE, NULL); + lba_map->dma_buf = spdk_dma_zmalloc(ftl_tail_md_num_lbks(dev) * FTL_BLOCK_SIZE, 0, NULL); if (!lba_map->dma_buf) { spdk_mempool_put(dev->lba_pool, lba_map->map); return -1; diff --git a/lib/ftl/ftl_restore.c b/lib/ftl/ftl_restore.c index 7229d7b13..dca7324a5 100644 --- a/lib/ftl/ftl_restore.c +++ b/lib/ftl/ftl_restore.c @@ -196,7 +196,7 @@ ftl_restore_init(struct spdk_ftl_dev *dev, ftl_restore_fn cb) md_size = spdk_max(ftl_dev_num_bands(dev) * ftl_head_md_num_lbks(dev) * FTL_BLOCK_SIZE, ftl_tail_md_num_lbks(dev) * FTL_BLOCK_SIZE); - restore->md_buf = spdk_dma_zmalloc(md_size, FTL_BLOCK_SIZE, NULL); + restore->md_buf = spdk_dma_zmalloc(md_size, 0, NULL); if (!restore->md_buf) { goto error; } @@ -1173,14 +1173,7 @@ ftl_restore_pad_band(struct ftl_restore_band *rband) ppa = band->chunk_buf[i].start_ppa; ppa.lbk = info.wp; - /* - * We need 4k alignment for lightnvm writes; otherwise, due to a bug in QEMU, - * scatter gather lists to underlying block device become broken as the number of - * incoming offsets (dev->xfer_size) would be smaller than the calculated size of - * sgl (dev->xfer_size+1), which eventually results in some part of the write - * hitting offset 0 of the drive, overwriting head_md of band 0. - */ - buffer = spdk_dma_zmalloc(FTL_BLOCK_SIZE * dev->xfer_size, FTL_BLOCK_SIZE, NULL); + buffer = spdk_dma_zmalloc(FTL_BLOCK_SIZE * dev->xfer_size, 0, NULL); if (spdk_unlikely(!buffer)) { rc = -ENOMEM; goto error; diff --git a/lib/ftl/ftl_rwb.c b/lib/ftl/ftl_rwb.c index 16e5ee197..854c9ae23 100644 --- a/lib/ftl/ftl_rwb.c +++ b/lib/ftl/ftl_rwb.c @@ -161,8 +161,7 @@ ftl_rwb_batch_init(struct ftl_rwb *rwb, struct ftl_rwb_batch *batch, unsigned in LIST_INIT(&batch->entry_list); - batch->buffer = spdk_dma_zmalloc(FTL_BLOCK_SIZE * rwb->xfer_size, - FTL_BLOCK_SIZE, NULL); + batch->buffer = spdk_dma_zmalloc(FTL_BLOCK_SIZE * rwb->xfer_size, 0, NULL); if (!batch->buffer) { return -1; }