Commit cea8dade authored by Artur Paszkiewicz's avatar Artur Paszkiewicz Committed by Jim Harris
Browse files

ftl: valid map



Adds P2L validity map tracking - a bitmap marking all physical LBAs
as containing valid (current) user data or not. A clear bit denotes
the location has no valid data and may be skipped during relocation
or compaction. A set bit means it may have valid data (it's still
necessary to do the necessary comparision against L2P).

Signed-off-by: default avatarArtur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: default avatarKozlowski Mateusz <mateusz.kozlowski@intel.com>
Change-Id: I6a831a97b3080eb7c880d9c4feab41b523467885
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13350


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 1e904e2b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -184,6 +184,7 @@ ftl_band_set_addr(struct ftl_band *band, uint64_t lba, ftl_addr addr)

	p2l_map->band_map[offset] = lba;
	p2l_map->num_valid++;
	ftl_bitmap_set(band->dev->valid_map, addr);
}

size_t
+8 −0
Original line number Diff line number Diff line
@@ -202,6 +202,14 @@ ftl_band_qd(const struct ftl_band *band)
	return band->queue_depth;
}

static inline bool
ftl_band_block_offset_valid(struct ftl_band *band, size_t block_off)
{
	struct ftl_p2l_map *p2l_map = &band->p2l_map;

	return ftl_bitmap_get(p2l_map->valid, block_off);
}

static inline void
ftl_band_iter_init(struct ftl_band *band)
{
+8 −3
Original line number Diff line number Diff line
@@ -133,15 +133,20 @@ ftl_invalidate_addr(struct spdk_ftl_dev *dev, ftl_addr addr)
	struct ftl_p2l_map *p2l_map;

	if (ftl_addr_in_nvc(dev, addr)) {
		ftl_bitmap_clear(dev->valid_map, addr);
		return;
	}

	band = ftl_band_from_addr(dev, addr);
	p2l_map = &band->p2l_map;

	/* TODO: fix case when the same address is invalidated from multiple sources */
	/* The bit might be already cleared if two writes are scheduled to the */
	/* same LBA at the same time */
	if (ftl_bitmap_get(dev->valid_map, addr)) {
		assert(p2l_map->num_valid > 0);
		ftl_bitmap_clear(dev->valid_map, addr);
		p2l_map->num_valid--;
	}

	/* Invalidate open/full band p2l_map entry to keep p2l and l2p
	 * consistency when band is going to close state */
+4 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include "ftl_layout.h"
#include "ftl_sb.h"
#include "ftl_l2p.h"
#include "utils/ftl_bitmap.h"
#include "utils/ftl_log.h"

/*
@@ -115,6 +116,9 @@ struct spdk_ftl_dev {
	/* Size of the l2p table */
	uint64_t			num_lbas;

	/* P2L valid map */
	struct ftl_bitmap		*valid_map;

	/* Metadata size */
	uint64_t			md_size;

+5 −0
Original line number Diff line number Diff line
@@ -11,6 +11,8 @@
#include "spdk/util.h"
#include "spdk/uuid.h"

#include "utils/ftl_bitmap.h"

/* Marks address as invalid */
#define FTL_ADDR_INVALID	((ftl_addr)-1)
/* Marks LBA as invalid */
@@ -68,6 +70,9 @@ struct ftl_p2l_map {
	/* P2L map's reference count, prevents premature release of resources during dirty shutdown recovery for open bands */
	size_t					ref_cnt;

	/* Bitmap of valid LBAs */
	struct ftl_bitmap			*valid;

	/* P2L map (only valid for open/relocating bands) */
	union {
		uint64_t	*band_map;
Loading