Commit 38bb4bcd authored by Mateusz Kozlowski's avatar Mateusz Kozlowski Committed by Darek Stojaczyk
Browse files

lib/ftl: Fix I/O alignment in dirty shutdown restore



Changed to use 4k alignment in dirty shutdown I/Os. Otherwise the
scatter gather lists used in QEMU for underlying file/block device
would use an extra entry (e.g. 17 for 16 sector writes), and eventually
some I/Os would write to offset 0 in underlying file, corrupting head
metadata.

Signed-off-by: default avatarMateusz Kozlowski <mateusz.kozlowski@intel.com>
Change-Id: If8c88ce708529b094a09c8ee952912cc22cd53b9
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/458090


Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarWojciech Malikowski <wojciech.malikowski@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 67d027ec
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -180,7 +180,6 @@ ftl_restore_check_seq(const struct ftl_restore *restore)

	for (i = 0; i < ftl_dev_num_bands(dev); ++i) {
		rband = &restore->bands[i];

		if (rband->md_status != FTL_MD_SUCCESS) {
			continue;
		}
@@ -533,7 +532,14 @@ ftl_restore_pad_band(struct ftl_restore_band *rband)
		ppa = band->chunk_buf[i].start_ppa;
		ppa.lbk = info.wp;

		buffer = spdk_dma_zmalloc(FTL_BLOCK_SIZE * dev->xfer_size, sizeof(uint32_t), NULL);
		/*
		 * 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);
		if (spdk_unlikely(!buffer)) {
			rc = -ENOMEM;
			goto error;