Commit b16bdc6d authored by Artur Paszkiewicz's avatar Artur Paszkiewicz Committed by Tomasz Zawadzki
Browse files

FTL: Add L2P API and flat L2P implementation



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


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 b6eecb21
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -21,9 +21,9 @@ 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
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 += 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
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

SPDK_MAP_FILE = $(abspath $(CURDIR)/spdk_ftl.map)
+17 −3
Original line number Diff line number Diff line
@@ -26,14 +26,27 @@ spdk_ftl_io_size(void)
	return sizeof(struct ftl_io);
}

static int
static bool
ftl_shutdown_complete(struct spdk_ftl_dev *dev)
{
	if (dev->num_inflight) {
		return 0;
		return false;
	}

	if (!ftl_l2p_is_halted(dev)) {
		ftl_l2p_halt(dev);
		return false;
	}

	return true;
}

	return 1;
void
ftl_invalidate_addr(struct spdk_ftl_dev *dev, ftl_addr addr)
{
	if (ftl_addr_in_nvc(dev, addr)) {
		return;
	}
}

void
@@ -128,6 +141,7 @@ ftl_core_poller(void *ctx)
	}

	ftl_process_io_queue(dev);
	ftl_l2p_process(dev);

	if (io_activity_total_old != dev->io_activity_total) {
		return SPDK_POLLER_BUSY;
+9 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include "ftl_io.h"
#include "ftl_layout.h"
#include "ftl_sb.h"
#include "ftl_l2p.h"
#include "utils/ftl_log.h"

/* When using VSS on nvcache, FTL sometimes doesn't require the contents of metadata.
@@ -81,6 +82,12 @@ struct spdk_ftl_dev {
	/* Number of free bands */
	uint64_t			num_free;

	/* Logical -> physical table */
	void				*l2p;

	/* l2p deferred pins list */
	TAILQ_HEAD(, ftl_l2p_pin_ctx) l2p_deferred_pins;

	/* Size of the l2p table */
	uint64_t			num_lbas;

@@ -117,6 +124,8 @@ struct spdk_ftl_dev {
	TAILQ_HEAD(, ftl_io)		wr_sq;
};

void ftl_invalidate_addr(struct spdk_ftl_dev *dev, ftl_addr addr);

int ftl_core_poller(void *ctx);

int ftl_io_channel_poll(void *arg);
+35 −0
Original line number Diff line number Diff line
@@ -181,12 +181,47 @@ ftl_io_init(struct spdk_io_channel *_ioch, struct ftl_io *io, uint64_t lba, size
	return 0;
}

static void
ftl_io_complete_verify(struct ftl_io *io)
{
	struct spdk_ftl_dev *dev = io->dev;
	uint64_t i;
	uint64_t lba = io->lba;

	assert(io->num_blocks <= dev->xfer_size);

	if (FTL_IO_WRITE == io->type) {
		return;
	}

	if (spdk_unlikely(io->status)) {
		return;
	}

	for (i = 0; i < io->num_blocks; i++, lba++) {
		ftl_addr current_addr = ftl_l2p_get(dev, lba);

		/* If user read request gets stuck for whatever reason, then it's possible the LBA
		 * has been relocated by GC or compaction and it may no longer be safe to return data
		 * from that address */
		if (spdk_unlikely(current_addr != io->map[i])) {
			io->status = -EAGAIN;
			break;
		}
	}
}

void
ftl_io_complete(struct ftl_io *io)
{
	io->flags &= ~FTL_IO_INITIALIZED;
	io->done = true;

	if (io->flags & FTL_IO_PINNED) {
		ftl_io_complete_verify(io);
		ftl_l2p_unpin(io->dev, io->lba, io->num_blocks);
	}

	ftl_io_cb(io, io->cb_ctx, io->status);
}

+9 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
#include "spdk/util.h"

#include "ftl_internal.h"
#include "ftl_l2p.h"
#include "utils/ftl_md.h"

struct spdk_ftl_dev;
@@ -24,6 +25,8 @@ typedef void (*ftl_io_fn)(struct ftl_io *, void *, int);
enum ftl_io_flags {
	/* Indicates whether IO is already initialized */
	FTL_IO_INITIALIZED	= (1 << 0),
	/* Indicated whether the user IO pinned the L2P pages containing LBAs */
	FTL_IO_PINNED		= (1 << 1),
};

enum ftl_io_type {
@@ -111,6 +114,9 @@ struct ftl_io {
	/* Reference to the chunk within NV cache */
	struct ftl_nv_cache_chunk	*nv_cache_chunk;

	/* For l2p pinning */
	struct ftl_l2p_pin_ctx		l2p_pin_ctx;

	/* Logical to physical mapping for this IO, number of entries equals to
	 * number of transfer blocks */
	ftl_addr			*map;
@@ -141,6 +147,9 @@ struct ftl_rq_entry {
		void *priv;
	} owner;

	/* For l2p pinning */
	struct ftl_l2p_pin_ctx l2p_pin_ctx;

	struct {
		uint64_t offset_blocks;
		uint64_t num_blocks;
Loading