Commit a68a12a4 authored by Kozlowski Mateusz's avatar Kozlowski Mateusz Committed by Tomasz Zawadzki
Browse files

FTL: Initial nv cache structure



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


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent ae6a3525
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ CFLAGS += -I.
FTL_SUBDIRS := mngt utils

C_SRCS = ftl_core.c ftl_init.c ftl_layout.c ftl_debug.c ftl_io.c ftl_sb.c ftl_l2p.c ftl_l2p_flat.c
C_SRCS += ftl_nv_cache.c
C_SRCS += mngt/ftl_mngt.c mngt/ftl_mngt_bdev.c mngt/ftl_mngt_shutdown.c mngt/ftl_mngt_startup.c
C_SRCS += mngt/ftl_mngt_md.c mngt/ftl_mngt_misc.c mngt/ftl_mngt_ioch.c mngt/ftl_mngt_l2p.c
C_SRCS += utils/ftl_conf.c utils/ftl_md.c utils/ftl_mempool.c
+10 −1
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
#include "ftl_debug.h"
#include "ftl_internal.h"
#include "mngt/ftl_mngt.h"
#include "utils/ftl_mempool.h"


size_t
@@ -33,6 +32,15 @@ ftl_shutdown_complete(struct spdk_ftl_dev *dev)
		return false;
	}

	if (!ftl_nv_cache_is_halted(&dev->nv_cache)) {
		ftl_nv_cache_halt(&dev->nv_cache);
		return false;
	}

	if (!ftl_nv_cache_chunks_busy(&dev->nv_cache)) {
		return false;
	}

	if (!ftl_l2p_is_halted(dev)) {
		ftl_l2p_halt(dev);
		return false;
@@ -141,6 +149,7 @@ ftl_core_poller(void *ctx)
	}

	ftl_process_io_queue(dev);
	ftl_nv_cache_process(dev);
	ftl_l2p_process(dev);

	if (io_activity_total_old != dev->io_activity_total) {
+4 −9
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@

#include "ftl_internal.h"
#include "ftl_io.h"
#include "ftl_nv_cache.h"
#include "ftl_layout.h"
#include "ftl_sb.h"
#include "ftl_l2p.h"
@@ -46,12 +47,6 @@ struct spdk_ftl_dev {
	/* Underlying device */
	struct spdk_bdev_desc		*base_bdev_desc;

	/* Cache device */
	struct spdk_bdev_desc		*cache_bdev_desc;

	/* Cache VSS metadata size */
	uint64_t			cache_md_size;

	/* Cached properties of the underlying device */
	uint64_t			num_blocks_in_band;
	uint64_t			num_zones_in_band;
@@ -70,6 +65,9 @@ struct spdk_ftl_dev {
	/* Management process to be continued after IO device unregistration completes */
	struct ftl_mngt_process		*unregister_process;

	/* Non-volatile write buffer cache */
	struct ftl_nv_cache		nv_cache;

	/* counters for poller busy, include
	   1. nv cache read/write
	   2. metadata read/write
@@ -111,9 +109,6 @@ struct spdk_ftl_dev {
	/* Underlying device IO channel */
	struct spdk_io_channel		*base_ioch;

	/* Cache IO channel */
	struct spdk_io_channel		*cache_ioch;

	/* Poller */
	struct spdk_poller		*core_poller;

+1 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include "ftl_core.h"
#include "ftl_io.h"
#include "ftl_debug.h"
#include "ftl_nv_cache.h"
#include "ftl_utils.h"
#include "mngt/ftl_mngt.h"

+29 −0
Original line number Diff line number Diff line
@@ -27,4 +27,33 @@ typedef uint64_t ftl_addr;
/* Number of LBAs that could be stored in a single block */
#define FTL_NUM_LBA_IN_BLOCK	(FTL_BLOCK_SIZE / sizeof(uint64_t))

/*
 * Mapping of physical (actual location on disk) to logical (user's POV) addresses. Used in two main scenarios:
 * - during relocation FTL needs to pin L2P pages (this allows to check which pages to pin) and move still valid blocks
 * (valid map allows for preliminary elimination of invalid physical blocks, but user data could invalidate a location
 * during read/write operation, so actual comparision against L2P needs to be done)
 * - After dirty shutdown the state of the L2P is unknown and needs to be rebuilt - it is done by applying all P2L, taking
 * into account ordering of user writes
 */
struct ftl_p2l_map {
	/* Number of valid LBAs */
	size_t					num_valid;

	/* P2L map's reference count, prevents premature release of resources during dirty shutdown recovery for open bands */
	size_t					ref_cnt;

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

	/* DMA buffer for region's metadata entry */
	union {
		struct ftl_band_md		*band_dma_md;

		struct ftl_nv_cache_chunk_md	*chunk_dma_md;
	};
};

#endif /* FTL_INTERNAL_H */
Loading