Commit dd54dff7 authored by Wojciech Malikowski's avatar Wojciech Malikowski Committed by Jim Harris
Browse files

lib/ftl: Keep DMA buffer for metadata as part of ftl_md structure



This patch is starting point for metadata refactor
which is needed for efficient ANM events support.

Change-Id: I81d864605e69008d8e3922fb61adf504187447a1
Signed-off-by: default avatarWojciech Malikowski <wojciech.malikowski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/449328


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 9b025e17
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -174,7 +174,9 @@ ftl_band_free_md(struct ftl_band *band)
	}

	spdk_mempool_put(dev->lba_pool, md->lba_map);
	spdk_dma_free(md->dma_buf);
	md->lba_map = NULL;
	md->dma_buf = NULL;
}

static void
@@ -660,6 +662,13 @@ ftl_band_alloc_md(struct ftl_band *band)
		return -1;
	}

	md->dma_buf = spdk_dma_zmalloc(ftl_tail_md_num_lbks(dev) * FTL_BLOCK_SIZE,
				       FTL_BLOCK_SIZE, NULL);
	if (!md->dma_buf) {
		spdk_mempool_put(dev->lba_pool, md->lba_map);
		return -1;
	}

	ftl_band_acquire_md(band);
	return 0;
}
+4 −1
Original line number Diff line number Diff line
@@ -100,8 +100,11 @@ struct ftl_md {
	/* Bitmap of valid LBAs */
	struct spdk_bit_array			*vld_map;

	/* LBA map (only valid for open bands) */
	/* LBA map (only valid for open/relocating bands) */
	uint64_t				*lba_map;

	/* Metadata DMA buffer (only valid for open/relocating bands) */
	void					*dma_buf;
};

enum ftl_band_state {
+2 −13
Original line number Diff line number Diff line
@@ -66,9 +66,6 @@ struct ftl_wptr {
	/* Current erase block */
	struct ftl_chunk		*chunk;

	/* Metadata DMA buffer */
	void				*md_buf;

	/* List link */
	LIST_ENTRY(ftl_wptr)		list_entry;
};
@@ -114,7 +111,6 @@ ftl_wptr_free(struct ftl_wptr *wptr)
		return;
	}

	spdk_dma_free(wptr->md_buf);
	free(wptr);
}

@@ -253,7 +249,7 @@ ftl_wptr_close_band(struct ftl_wptr *wptr)
	ftl_band_set_state(band, FTL_BAND_STATE_CLOSING);
	band->tail_md_ppa = wptr->ppa;

	return ftl_band_write_tail_md(band, wptr->md_buf, ftl_md_write_cb);
	return ftl_band_write_tail_md(band, band->md.dma_buf, ftl_md_write_cb);
}

static int
@@ -269,7 +265,7 @@ ftl_wptr_open_band(struct ftl_wptr *wptr)
	assert(band->state == FTL_BAND_STATE_PREP);
	ftl_band_set_state(band, FTL_BAND_STATE_OPENING);

	return ftl_band_write_head_md(band, wptr->md_buf, ftl_md_write_cb);
	return ftl_band_write_head_md(band, band->md.dma_buf, ftl_md_write_cb);
}

static int
@@ -390,13 +386,6 @@ ftl_wptr_init(struct ftl_band *band)
		return NULL;
	}

	wptr->md_buf = spdk_dma_zmalloc(ftl_tail_md_num_lbks(dev) * FTL_BLOCK_SIZE,
					FTL_BLOCK_SIZE, NULL);
	if (!wptr->md_buf) {
		ftl_wptr_free(wptr);
		return NULL;
	}

	wptr->dev = dev;
	wptr->band = band;
	wptr->chunk = CIRCLEQ_FIRST(&band->chunks);
+1 −11
Original line number Diff line number Diff line
@@ -77,9 +77,6 @@ struct ftl_band_reloc {
	struct spdk_ring			*write_queue;

	TAILQ_ENTRY(ftl_band_reloc)		entry;

	/* TODO: get rid of md_buf */
	void					*md_buf;
};

struct ftl_reloc {
@@ -172,7 +169,6 @@ ftl_reloc_read_lba_map_cb(void *arg, int status)
	struct ftl_band_reloc *breloc = ftl_io_get_band_reloc(io);

	assert(status == 0);
	spdk_dma_free(breloc->md_buf);
	ftl_io_free(io);
	_ftl_reloc_prep(breloc);
}
@@ -189,17 +185,11 @@ ftl_reloc_read_lba_map(struct ftl_band_reloc *breloc)
	io->cb.ctx = io;
	io->cb.fn = ftl_reloc_read_lba_map_cb;

	breloc->md_buf = spdk_dma_zmalloc(ftl_lba_map_num_lbks(dev) * FTL_BLOCK_SIZE,
					  FTL_BLOCK_SIZE, NULL);
	if (!breloc->md_buf) {
		return -1;
	}

	if (ftl_band_alloc_md(band)) {
		assert(false);
	}

	return ftl_band_read_lba_map(band, &band->md, breloc->md_buf, &io->cb);
	return ftl_band_read_lba_map(band, &band->md, band->md.dma_buf, &io->cb);
}

static void
+1 −0
Original line number Diff line number Diff line
@@ -133,6 +133,7 @@ test_free_ftl_band(struct ftl_band *band)
	spdk_bit_array_free(&band->md.vld_map);
	free(band->chunk_buf);
	free(band->md.lba_map);
	spdk_dma_free(band->md.dma_buf);
}

uint64_t
Loading