Commit e47e16d3 authored by Wojciech Malikowski's avatar Wojciech Malikowski Committed by Tomasz Zawadzki
Browse files

lib/ftl: Replace ftl_ppa struct with ftl_addr



FTL working on top of zoned bdev doesn't need
physical page address (PPA) anymore.
ftl_ppa was replaced with ftl_addr which represents
zoned device addressing schema.

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


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
parent 748785c2
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -31,13 +31,13 @@
 *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef FTL_PPA_H
#define FTL_PPA_H
#ifndef FTL_ADDR_H
#define FTL_ADDR_H

#include "spdk/stdinc.h"

/* Marks PPA as invalid */
#define FTL_PPA_INVALID		(-1)
/* Marks address as invalid */
#define FTL_ADDR_INVALID	(-1)
/* Marks LBA as invalid */
#define FTL_LBA_INVALID		((uint64_t)-1)
/* Smallest data unit size */
@@ -50,7 +50,7 @@
/*        - packed version of the two formats above (can be only used when the */
/*          raw address can be represented in less than 32 bits) */
/* Packed format is used, when possible, to avoid wasting RAM on the L2P table. */
struct ftl_ppa {
struct ftl_addr {
	union {
		struct {
			uint64_t offset	 : 32;
@@ -98,4 +98,4 @@ struct ftl_ppa_fmt {
	unsigned int				grp_mask;
};

#endif /* FTL_PPA_H */
#endif /* FTL_ADDR_H */
+11 −11
Original line number Diff line number Diff line
@@ -118,7 +118,7 @@ ftl_anm_log_range(struct spdk_ocssd_chunk_notification_entry *log)
}

static struct ftl_anm_event *
ftl_anm_event_alloc(struct spdk_ftl_dev *dev, struct ftl_ppa ppa,
ftl_anm_event_alloc(struct spdk_ftl_dev *dev, struct ftl_addr addr,
		    enum ftl_anm_range range, size_t num_lbks)
{
	struct ftl_anm_event *event;
@@ -129,7 +129,7 @@ ftl_anm_event_alloc(struct spdk_ftl_dev *dev, struct ftl_ppa ppa,
	}

	event->dev = dev;
	event->ppa = ppa;
	event->addr = addr;

	switch (range) {
	case FTL_ANM_RANGE_LBK:
@@ -152,7 +152,7 @@ ftl_anm_process_log(struct ftl_anm_poller *poller,
		    struct spdk_ocssd_chunk_notification_entry *log)
{
	struct ftl_anm_event *event;
	struct ftl_ppa ppa = ftl_ppa_addr_unpack(poller->dev, log->lba);
	struct ftl_addr addr = ftl_addr_addr_unpack(poller->dev, log->lba);
	struct spdk_ftl_dev *dev = poller->dev;
	enum ftl_anm_range range = ftl_anm_log_range(log);
	int i, num_bands = 1;
@@ -160,19 +160,19 @@ ftl_anm_process_log(struct ftl_anm_poller *poller,
	num_bands = range != FTL_ANM_RANGE_PU ? 1 : ftl_dev_num_bands(dev);

	for (i = 0; i < num_bands; ++i) {
		struct ftl_zone *zone = ftl_band_zone_from_ppa(&dev->bands[i], ppa);
		struct ftl_zone *zone = ftl_band_zone_from_addr(&dev->bands[i], addr);

		if (zone->state == SPDK_BDEV_ZONE_STATE_OFFLINE) {
			continue;
		}

		event = ftl_anm_event_alloc(dev, ppa, range, log->nlb);
		event = ftl_anm_event_alloc(dev, addr, range, log->nlb);
		if (!event) {
			return -ENOMEM;
		}

		poller->fn(event);
		ppa.zone_id++;
		addr.zone_id++;
	}

	return 0;
@@ -183,16 +183,16 @@ ftl_anm_in_poller_range(struct ftl_anm_poller *poller,
			struct spdk_ocssd_chunk_notification_entry *log)
{
	struct spdk_ftl_dev *dev = poller->dev;
	struct ftl_ppa ppa = ftl_ppa_addr_unpack(dev, log->lba);
	struct ftl_addr addr = ftl_addr_addr_unpack(dev, log->lba);
	char buf[128];

	if (ppa.zone_id >= ftl_dev_num_bands(dev)) {
		SPDK_ERRLOG("ANM log contains invalid @ppa: %s\n",
			    ftl_ppa2str(ppa, buf, sizeof(buf)));
	if (addr.zone_id >= ftl_dev_num_bands(dev)) {
		SPDK_ERRLOG("ANM log contains invalid @addr: %s\n",
			    ftl_addr2str(addr, buf, sizeof(buf)));
		return false;
	}

	if (!ftl_ppa_in_range(dev, ppa)) {
	if (!ftl_addr_in_range(dev, addr)) {
		return false;
	}

+3 −3
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@
#define FTL_ANM_H

#include "spdk/thread.h"
#include "ftl_ppa.h"
#include "ftl_addr.h"

struct ftl_nvme_ctrlr;
struct ftl_anm_event;
@@ -54,8 +54,8 @@ struct ftl_anm_event {
	/* Owner device */
	struct spdk_ftl_dev		*dev;

	/* Start PPA */
	struct ftl_ppa			ppa;
	/* First block address */
	struct ftl_addr			addr;

	/* Number of logical blocks */
	size_t				num_lbks;
+85 −85
Original line number Diff line number Diff line
@@ -382,10 +382,10 @@ ftl_unpack_head_md(struct ftl_band *band)
	return FTL_MD_SUCCESS;
}

struct ftl_ppa
ftl_band_tail_md_ppa(struct ftl_band *band)
struct ftl_addr
ftl_band_tail_md_addr(struct ftl_band *band)
{
	struct ftl_ppa ppa = {};
	struct ftl_addr addr = {};
	struct ftl_zone *zone;
	struct spdk_ftl_dev *dev = band->dev;
	size_t xfer_size = dev->xfer_size;
@@ -393,7 +393,7 @@ ftl_band_tail_md_ppa(struct ftl_band *band)
	size_t i;

	if (spdk_unlikely(!band->num_zones)) {
		return ftl_to_ppa(FTL_PPA_INVALID);
		return ftl_to_addr(FTL_ADDR_INVALID);
	}

	/* Metadata should be aligned to xfer size */
@@ -404,26 +404,26 @@ ftl_band_tail_md_ppa(struct ftl_band *band)
		zone = ftl_band_next_zone(band, zone);
	}

	ppa.offset = (num_req / band->num_zones) * xfer_size;
	ppa.zone_id = band->id;
	ppa.pu = zone->punit->start_ppa.pu;
	addr.offset = (num_req / band->num_zones) * xfer_size;
	addr.zone_id = band->id;
	addr.pu = zone->punit->start_addr.pu;

	return ppa;
	return addr;
}

struct ftl_ppa
ftl_band_head_md_ppa(struct ftl_band *band)
struct ftl_addr
ftl_band_head_md_addr(struct ftl_band *band)
{
	struct ftl_ppa ppa;
	struct ftl_addr addr;

	if (spdk_unlikely(!band->num_zones)) {
		return ftl_to_ppa(FTL_PPA_INVALID);
		return ftl_to_addr(FTL_ADDR_INVALID);
	}

	ppa = CIRCLEQ_FIRST(&band->zones)->punit->start_ppa;
	ppa.zone_id = band->id;
	addr = CIRCLEQ_FIRST(&band->zones)->punit->start_addr;
	addr.zone_id = band->id;

	return ppa;
	return addr;
}

void
@@ -455,14 +455,14 @@ ftl_band_set_state(struct ftl_band *band, enum ftl_band_state state)
}

void
ftl_band_set_addr(struct ftl_band *band, uint64_t lba, struct ftl_ppa ppa)
ftl_band_set_addr(struct ftl_band *band, uint64_t lba, struct ftl_addr addr)
{
	struct ftl_lba_map *lba_map = &band->lba_map;
	uint64_t offset;

	assert(lba != FTL_LBA_INVALID);

	offset = ftl_band_lbkoff_from_ppa(band, ppa);
	offset = ftl_band_lbkoff_from_addr(band, addr);
	pthread_spin_lock(&lba_map->lock);

	lba_map->num_vld++;
@@ -509,51 +509,51 @@ ftl_band_user_lbks(const struct ftl_band *band)
}

struct ftl_band *
ftl_band_from_ppa(struct spdk_ftl_dev *dev, struct ftl_ppa ppa)
ftl_band_from_addr(struct spdk_ftl_dev *dev, struct ftl_addr addr)
{
	assert(ppa.zone_id < ftl_dev_num_bands(dev));
	return &dev->bands[ppa.zone_id];
	assert(addr.zone_id < ftl_dev_num_bands(dev));
	return &dev->bands[addr.zone_id];
}

struct ftl_zone *
ftl_band_zone_from_ppa(struct ftl_band *band, struct ftl_ppa ppa)
ftl_band_zone_from_addr(struct ftl_band *band, struct ftl_addr addr)
{
	struct spdk_ftl_dev *dev = band->dev;
	unsigned int punit;

	punit = ftl_ppa_flatten_punit(dev, ppa);
	punit = ftl_addr_flatten_punit(dev, addr);
	assert(punit < ftl_dev_num_punits(dev));

	return &band->zone_buf[punit];
}

uint64_t
ftl_band_lbkoff_from_ppa(struct ftl_band *band, struct ftl_ppa ppa)
ftl_band_lbkoff_from_addr(struct ftl_band *band, struct ftl_addr addr)
{
	struct spdk_ftl_dev *dev = band->dev;
	unsigned int punit;

	punit = ftl_ppa_flatten_punit(dev, ppa);
	assert(ppa.zone_id == band->id);
	punit = ftl_addr_flatten_punit(dev, addr);
	assert(addr.zone_id == band->id);

	return punit * ftl_dev_lbks_in_zone(dev) + ppa.offset;
	return punit * ftl_dev_lbks_in_zone(dev) + addr.offset;
}

struct ftl_ppa
ftl_band_next_xfer_ppa(struct ftl_band *band, struct ftl_ppa ppa, size_t num_lbks)
struct ftl_addr
ftl_band_next_xfer_addr(struct ftl_band *band, struct ftl_addr addr, size_t num_lbks)
{
	struct spdk_ftl_dev *dev = band->dev;
	struct ftl_zone *zone;
	unsigned int punit_num;
	size_t num_xfers, num_stripes;

	assert(ppa.zone_id == band->id);
	assert(addr.zone_id == band->id);

	punit_num = ftl_ppa_flatten_punit(dev, ppa);
	punit_num = ftl_addr_flatten_punit(dev, addr);
	zone = &band->zone_buf[punit_num];

	num_lbks += (ppa.offset % dev->xfer_size);
	ppa.offset  -= (ppa.offset % dev->xfer_size);
	num_lbks += (addr.offset % dev->xfer_size);
	addr.offset  -= (addr.offset % dev->xfer_size);

#if defined(DEBUG)
	/* Check that the number of zones has not been changed */
@@ -568,11 +568,11 @@ ftl_band_next_xfer_ppa(struct ftl_band *band, struct ftl_ppa ppa, size_t num_lbk
#endif
	assert(band->num_zones != 0);
	num_stripes = (num_lbks / dev->xfer_size) / band->num_zones;
	ppa.offset  += num_stripes * dev->xfer_size;
	addr.offset  += num_stripes * dev->xfer_size;
	num_lbks -= num_stripes * dev->xfer_size * band->num_zones;

	if (ppa.offset > ftl_dev_lbks_in_zone(dev)) {
		return ftl_to_ppa(FTL_PPA_INVALID);
	if (addr.offset > ftl_dev_lbks_in_zone(dev)) {
		return ftl_to_addr(FTL_ADDR_INVALID);
	}

	num_xfers = num_lbks / dev->xfer_size;
@@ -580,42 +580,42 @@ ftl_band_next_xfer_ppa(struct ftl_band *band, struct ftl_ppa ppa, size_t num_lbk
		/* When the last zone is reached the lbk part of the address */
		/* needs to be increased by xfer_size */
		if (ftl_band_zone_is_last(band, zone)) {
			ppa.offset += dev->xfer_size;
			if (ppa.offset > ftl_dev_lbks_in_zone(dev)) {
				return ftl_to_ppa(FTL_PPA_INVALID);
			addr.offset += dev->xfer_size;
			if (addr.offset > ftl_dev_lbks_in_zone(dev)) {
				return ftl_to_addr(FTL_ADDR_INVALID);
			}
		}

		zone = ftl_band_next_operational_zone(band, zone);
		assert(zone);
		ppa.pu = zone->start_ppa.pu;
		addr.pu = zone->start_addr.pu;

		num_lbks -= dev->xfer_size;
	}

	if (num_lbks) {
		ppa.offset += num_lbks;
		if (ppa.offset > ftl_dev_lbks_in_zone(dev)) {
			return ftl_to_ppa(FTL_PPA_INVALID);
		addr.offset += num_lbks;
		if (addr.offset > ftl_dev_lbks_in_zone(dev)) {
			return ftl_to_addr(FTL_ADDR_INVALID);
		}
	}

	return ppa;
	return addr;
}

static size_t
ftl_xfer_offset_from_ppa(struct ftl_band *band, struct ftl_ppa ppa)
ftl_xfer_offset_from_addr(struct ftl_band *band, struct ftl_addr addr)
{
	struct ftl_zone *zone, *current_zone;
	unsigned int punit_offset = 0;
	size_t off, num_stripes, xfer_size = band->dev->xfer_size;

	assert(ppa.zone_id == band->id);
	assert(addr.zone_id == band->id);

	num_stripes = (ppa.offset / xfer_size) * band->num_zones;
	off = ppa.offset % xfer_size;
	num_stripes = (addr.offset / xfer_size) * band->num_zones;
	off = addr.offset % xfer_size;

	current_zone = ftl_band_zone_from_ppa(band, ppa);
	current_zone = ftl_band_zone_from_addr(band, addr);
	CIRCLEQ_FOREACH(zone, &band->zones, circleq) {
		if (current_zone == zone) {
			break;
@@ -626,27 +626,27 @@ ftl_xfer_offset_from_ppa(struct ftl_band *band, struct ftl_ppa ppa)
	return xfer_size * (num_stripes + punit_offset) + off;
}

struct ftl_ppa
ftl_band_ppa_from_lbkoff(struct ftl_band *band, uint64_t lbkoff)
struct ftl_addr
ftl_band_addr_from_lbkoff(struct ftl_band *band, uint64_t lbkoff)
{
	struct ftl_ppa ppa = { .addr = 0 };
	struct ftl_addr addr = { .addr = 0 };
	struct spdk_ftl_dev *dev = band->dev;
	uint64_t punit;

	punit = lbkoff / ftl_dev_lbks_in_zone(dev) + dev->range.begin;

	ppa.offset = lbkoff % ftl_dev_lbks_in_zone(dev);
	ppa.zone_id = band->id;
	ppa.pu = punit;
	addr.offset = lbkoff % ftl_dev_lbks_in_zone(dev);
	addr.zone_id = band->id;
	addr.pu = punit;

	return ppa;
	return addr;
}

struct ftl_ppa
ftl_band_next_ppa(struct ftl_band *band, struct ftl_ppa ppa, size_t offset)
struct ftl_addr
ftl_band_next_addr(struct ftl_band *band, struct ftl_addr addr, size_t offset)
{
	uint64_t lbkoff = ftl_band_lbkoff_from_ppa(band, ppa);
	return ftl_band_ppa_from_lbkoff(band, lbkoff + offset);
	uint64_t lbkoff = ftl_band_lbkoff_from_addr(band, addr);
	return ftl_band_addr_from_lbkoff(band, lbkoff + offset);
}

void
@@ -711,7 +711,7 @@ ftl_read_md_cb(struct ftl_io *io, void *arg, int status)
}

static struct ftl_md_io *
ftl_io_init_md_read(struct spdk_ftl_dev *dev, struct ftl_ppa ppa,
ftl_io_init_md_read(struct spdk_ftl_dev *dev, struct ftl_addr addr,
		    struct ftl_band *band, size_t lbk_cnt, void *buf,
		    ftl_io_fn fn, ftl_md_pack_fn pack_fn, ftl_io_fn cb_fn, void *cb_ctx)
{
@@ -722,7 +722,7 @@ ftl_io_init_md_read(struct spdk_ftl_dev *dev, struct ftl_ppa ppa,
		.rwb_batch	= NULL,
		.band		= band,
		.size		= sizeof(*io),
		.flags		= FTL_IO_MD | FTL_IO_PPA_MODE,
		.flags		= FTL_IO_MD | FTL_IO_PHYSICAL_MODE,
		.type		= FTL_IO_READ,
		.lbk_cnt	= lbk_cnt,
		.cb_fn		= fn,
@@ -734,7 +734,7 @@ ftl_io_init_md_read(struct spdk_ftl_dev *dev, struct ftl_ppa ppa,
		return NULL;
	}

	io->io.ppa = ppa;
	io->io.addr = addr;
	io->pack_fn = pack_fn;
	io->cb_fn = cb_fn;
	io->cb_ctx = cb_ctx;
@@ -752,7 +752,7 @@ ftl_io_init_md_write(struct spdk_ftl_dev *dev, struct ftl_band *band,
		.rwb_batch	= NULL,
		.band		= band,
		.size		= sizeof(struct ftl_io),
		.flags		= FTL_IO_MD | FTL_IO_PPA_MODE,
		.flags		= FTL_IO_MD | FTL_IO_PHYSICAL_MODE,
		.type		= FTL_IO_WRITE,
		.lbk_cnt	= lbk_cnt,
		.cb_fn		= cb,
@@ -804,17 +804,17 @@ ftl_band_write_tail_md(struct ftl_band *band, ftl_io_fn cb)
				 ftl_pack_tail_md, cb);
}

static struct ftl_ppa
ftl_band_lba_map_ppa(struct ftl_band *band, size_t offset)
static struct ftl_addr
ftl_band_lba_map_addr(struct ftl_band *band, size_t offset)
{
	return ftl_band_next_xfer_ppa(band, band->tail_md_ppa,
	return ftl_band_next_xfer_addr(band, band->tail_md_addr,
				       ftl_tail_md_hdr_num_lbks() +
				       ftl_vld_map_num_lbks(band->dev) +
				       offset);
}

static int
ftl_band_read_md(struct ftl_band *band, size_t lbk_cnt, struct ftl_ppa start_ppa,
ftl_band_read_md(struct ftl_band *band, size_t lbk_cnt, struct ftl_addr start_addr,
		 void *buf, ftl_io_fn fn, ftl_md_pack_fn pack_fn, ftl_io_fn cb_fn, void *cb_ctx)
{
	struct spdk_ftl_dev *dev = band->dev;
@@ -824,7 +824,7 @@ ftl_band_read_md(struct ftl_band *band, size_t lbk_cnt, struct ftl_ppa start_ppa
		return -ENOENT;
	}

	io = ftl_io_init_md_read(dev, start_ppa, band, lbk_cnt, buf, fn, pack_fn, cb_fn, cb_ctx);
	io = ftl_io_init_md_read(dev, start_addr, band, lbk_cnt, buf, fn, pack_fn, cb_fn, cb_ctx);
	if (!io) {
		return -ENOMEM;
	}
@@ -834,9 +834,9 @@ ftl_band_read_md(struct ftl_band *band, size_t lbk_cnt, struct ftl_ppa start_ppa
}

int
ftl_band_read_tail_md(struct ftl_band *band, struct ftl_ppa ppa, ftl_io_fn cb_fn, void *cb_ctx)
ftl_band_read_tail_md(struct ftl_band *band, struct ftl_addr addr, ftl_io_fn cb_fn, void *cb_ctx)
{
	return ftl_band_read_md(band, ftl_tail_md_num_lbks(band->dev), ppa, band->lba_map.dma_buf,
	return ftl_band_read_md(band, ftl_tail_md_num_lbks(band->dev), addr, band->lba_map.dma_buf,
				ftl_read_md_cb, ftl_unpack_tail_md, cb_fn, cb_ctx);
}

@@ -895,12 +895,12 @@ ftl_process_lba_map_requests(struct spdk_ftl_dev *dev, struct ftl_lba_map *lba_m
}

static size_t
ftl_lba_map_offset_from_ppa(struct ftl_band *band, struct ftl_ppa ppa)
ftl_lba_map_offset_from_addr(struct ftl_band *band, struct ftl_addr addr)
{
	size_t offset;
	struct ftl_ppa start_ppa = ftl_band_lba_map_ppa(band, 0);
	struct ftl_addr start_addr = ftl_band_lba_map_addr(band, 0);

	offset =  ftl_xfer_offset_from_ppa(band, ppa) - ftl_xfer_offset_from_ppa(band, start_ppa);
	offset =  ftl_xfer_offset_from_addr(band, addr) - ftl_xfer_offset_from_addr(band, start_addr);
	assert(offset < ftl_lba_map_num_lbks(band->dev));

	return offset;
@@ -912,7 +912,7 @@ ftl_read_lba_map_cb(struct ftl_io *io, void *arg, int status)
	struct ftl_lba_map *lba_map = &io->band->lba_map;
	uint64_t lbk_off;

	lbk_off = ftl_lba_map_offset_from_ppa(io->band, io->ppa);
	lbk_off = ftl_lba_map_offset_from_addr(io->band, io->addr);
	assert(lbk_off + io->lbk_cnt <= ftl_lba_map_num_lbks(io->dev));

	if (!status) {
@@ -996,7 +996,7 @@ ftl_band_read_lba_map(struct ftl_band *band, size_t offset, size_t lba_cnt,
		ftl_lba_map_set_segment_state(lba_map, lbk_off, num_read,
					      FTL_LBA_MAP_SEG_PENDING);

		rc = ftl_band_read_md(band, num_read, ftl_band_lba_map_ppa(band, lbk_off),
		rc = ftl_band_read_md(band, num_read, ftl_band_lba_map_addr(band, lbk_off),
				      (char *)band->lba_map.map + lbk_off * FTL_BLOCK_SIZE,
				      ftl_read_lba_map_cb, NULL, cb_fn, cb_ctx);
		if (rc) {
@@ -1024,7 +1024,7 @@ ftl_band_read_head_md(struct ftl_band *band, ftl_io_fn cb_fn, void *cb_ctx)
{
	return ftl_band_read_md(band,
				ftl_head_md_num_lbks(band->dev),
				ftl_band_head_md_ppa(band),
				ftl_band_head_md_addr(band),
				band->lba_map.dma_buf,
				ftl_read_md_cb,
				ftl_unpack_head_md,
@@ -1046,13 +1046,13 @@ ftl_erase_fail(struct ftl_io *io, int status)
	struct ftl_band *band = io->band;
	char buf[128];

	SPDK_ERRLOG("Erase failed @ppa: %s, status: %d\n",
		    ftl_ppa2str(io->ppa, buf, sizeof(buf)), status);
	SPDK_ERRLOG("Erase failed @addr: %s, status: %d\n",
		    ftl_addr2str(io->addr, buf, sizeof(buf)), status);

	zone = ftl_band_zone_from_ppa(band, io->ppa);
	zone = ftl_band_zone_from_addr(band, io->addr);
	zone->state = SPDK_BDEV_ZONE_STATE_OFFLINE;
	ftl_band_remove_zone(band, zone);
	band->tail_md_ppa = ftl_band_tail_md_ppa(band);
	band->tail_md_addr = ftl_band_tail_md_addr(band);
}

static void
@@ -1064,7 +1064,7 @@ ftl_band_erase_cb(struct ftl_io *io, void *ctx, int status)
		ftl_erase_fail(io, status);
		return;
	}
	zone = ftl_band_zone_from_ppa(io->band, io->ppa);
	zone = ftl_band_zone_from_addr(io->band, io->addr);
	zone->state = SPDK_BDEV_ZONE_STATE_EMPTY;
	zone->write_offset = 0;
}
@@ -1092,7 +1092,7 @@ ftl_band_erase(struct ftl_band *band)
			break;
		}

		io->ppa = zone->start_ppa;
		io->addr = zone->start_addr;
		rc = ftl_io_erase(io);
		if (rc) {
			assert(0);
+17 −17
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@
#include "spdk/bdev_zone.h"

#include "ftl_io.h"
#include "ftl_ppa.h"
#include "ftl_addr.h"
#include "ftl_io.h"

/* Number of LBAs that could be stored in a single block */
@@ -59,8 +59,8 @@ struct ftl_zone {
	/* Current logical block's offset */
	uint64_t				write_offset;

	/* First PPA */
	struct ftl_ppa				start_ppa;
	/* First logical block of a zone */
	struct ftl_addr				start_addr;

	/* Pointer to parallel unit */
	struct ftl_punit			*punit;
@@ -178,8 +178,8 @@ struct ftl_band {
	/* Number of defrag cycles */
	uint64_t				wr_cnt;

	/* End metadata start ppa */
	struct ftl_ppa				tail_md_ppa;
	/* End metadata start addr */
	struct ftl_addr				tail_md_addr;

	/* Bitmap of all bands that have its data moved onto this band */
	struct spdk_bit_array			*reloc_bitmap;
@@ -195,8 +195,8 @@ struct ftl_band {
	STAILQ_ENTRY(ftl_band)			prio_stailq;
};

uint64_t	ftl_band_lbkoff_from_ppa(struct ftl_band *band, struct ftl_ppa ppa);
struct ftl_ppa ftl_band_ppa_from_lbkoff(struct ftl_band *band, uint64_t lbkoff);
uint64_t	ftl_band_lbkoff_from_addr(struct ftl_band *band, struct ftl_addr addr);
struct ftl_addr ftl_band_addr_from_lbkoff(struct ftl_band *band, uint64_t lbkoff);
void		ftl_band_set_state(struct ftl_band *band, enum ftl_band_state state);
size_t		ftl_band_age(const struct ftl_band *band);
void		ftl_band_acquire_lba_map(struct ftl_band *band);
@@ -206,25 +206,25 @@ void ftl_band_release_lba_map(struct ftl_band *band);
int		ftl_band_read_lba_map(struct ftl_band *band,
				      size_t offset, size_t lba_cnt,
				      ftl_io_fn cb_fn, void *cb_ctx);
struct ftl_ppa ftl_band_next_xfer_ppa(struct ftl_band *band, struct ftl_ppa ppa,
struct ftl_addr ftl_band_next_xfer_addr(struct ftl_band *band, struct ftl_addr addr,
					size_t num_lbks);
struct ftl_ppa ftl_band_next_ppa(struct ftl_band *band, struct ftl_ppa ppa,
struct ftl_addr ftl_band_next_addr(struct ftl_band *band, struct ftl_addr addr,
				   size_t offset);
size_t		ftl_band_num_usable_lbks(const struct ftl_band *band);
size_t		ftl_band_user_lbks_left(const struct ftl_band *band, size_t offset);
size_t		ftl_band_user_lbks(const struct ftl_band *band);
void		ftl_band_set_addr(struct ftl_band *band, uint64_t lba,
				  struct ftl_ppa ppa);
struct ftl_band *ftl_band_from_ppa(struct spdk_ftl_dev *dev, struct ftl_ppa ppa);
struct ftl_zone *ftl_band_zone_from_ppa(struct ftl_band *band, struct ftl_ppa);
				  struct ftl_addr addr);
struct ftl_band *ftl_band_from_addr(struct spdk_ftl_dev *dev, struct ftl_addr addr);
struct ftl_zone *ftl_band_zone_from_addr(struct ftl_band *band, struct ftl_addr);
void		ftl_band_md_clear(struct ftl_band *band);
int		ftl_band_read_tail_md(struct ftl_band *band, struct ftl_ppa,
int		ftl_band_read_tail_md(struct ftl_band *band, struct ftl_addr,
				      ftl_io_fn cb_fn, void *cb_ctx);
int		ftl_band_read_head_md(struct ftl_band *band, ftl_io_fn cb_fn, void *cb_ctx);
int		ftl_band_write_tail_md(struct ftl_band *band, ftl_io_fn cb);
int		ftl_band_write_head_md(struct ftl_band *band, ftl_io_fn cb);
struct ftl_ppa ftl_band_tail_md_ppa(struct ftl_band *band);
struct ftl_ppa ftl_band_head_md_ppa(struct ftl_band *band);
struct ftl_addr ftl_band_tail_md_addr(struct ftl_band *band);
struct ftl_addr ftl_band_head_md_addr(struct ftl_band *band);
void		ftl_band_write_failed(struct ftl_band *band);
int		ftl_band_full(struct ftl_band *band, size_t offset);
int		ftl_band_erase(struct ftl_band *band);
Loading