Commit bdca6e74 authored by Mateusz Kozlowski's avatar Mateusz Kozlowski Committed by Konrad Sztyber
Browse files

lib/ftl: On chunk open/closed for non-vss cache



In non-VSS NV cache device implement operations:
- on chunk open
- on chunk closed

Change-Id: I1231807984b73ede33c911c80c9cb5c490902550
Signed-off-by: default avatarMariusz Barczak <Mariusz.Barczak@solidigmtechnology.com>
Signed-off-by: default avatarMateusz Kozlowski <mateusz.kozlowski@solidigm.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/19622


Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 91de1969
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -246,6 +246,15 @@ void ftl_p2l_log_flush(struct spdk_ftl_dev *dev);
 */
typedef void (*ftl_p2l_log_cb)(struct ftl_io *io);

/**
 * @brief Get layout region type corresponding to the specific P2L log
 *
 * @param p2l P2L log
 *
 * @return Layout region type
 */
enum ftl_layout_region_type ftl_p2l_log_type(struct ftl_p2l_log *p2l);

/**
 * @brief Acquire P2L IO log
 *
+8 −1
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@

#include "ftl_io.h"
#include "ftl_utils.h"
#include "ftl_internal.h"
#include "nvc/ftl_nvc_dev.h"

/*
@@ -91,8 +92,11 @@ struct ftl_nv_cache_chunk_md {
	/* CRC32 checksum of the associated P2L map when chunk is in closed state */
	uint32_t p2l_map_checksum;

	/* P2L IO log type */
	enum ftl_layout_region_type p2l_log_type;

	/* Reserved */
	uint8_t reserved[4044];
	uint8_t reserved[4040];
} __attribute__((packed));

SPDK_STATIC_ASSERT(sizeof(struct ftl_nv_cache_chunk_md) == FTL_BLOCK_SIZE,
@@ -125,6 +129,9 @@ struct ftl_nv_cache_chunk {

	/* For writing metadata */
	struct ftl_md_io_entry_ctx md_persist_entry_ctx;

	/* P2L Log for IOs */
	struct ftl_p2l_log *p2l_log;
};

struct ftl_nv_cache_compactor {
+4 −1
Original line number Diff line number Diff line
@@ -281,7 +281,10 @@ ftl_p2l_log_deinit(struct spdk_ftl_dev *dev)
	}
}


enum ftl_layout_region_type
ftl_p2l_log_type(struct ftl_p2l_log *p2l) {
	return p2l->md->region->type;
}

struct ftl_p2l_log *
ftl_p2l_log_acquire(struct spdk_ftl_dev *dev, uint64_t seq_id, ftl_p2l_log_cb cb)
+24 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
#include "ftl_nvc_dev.h"
#include "ftl_core.h"
#include "ftl_layout.h"
#include "ftl_nv_cache.h"
#include "ftl_nvc_bdev_common.h"

static int
@@ -37,6 +38,27 @@ is_bdev_compatible(struct spdk_ftl_dev *dev, struct spdk_bdev *bdev)
	return true;
}

static void
p2l_log_cb(struct ftl_io *io)
{
}

static void
on_chunk_open(struct spdk_ftl_dev *dev, struct ftl_nv_cache_chunk *chunk)
{
	assert(NULL == chunk->p2l_log);
	chunk->p2l_log = ftl_p2l_log_acquire(dev, chunk->md->seq_id, p2l_log_cb);
	chunk->md->p2l_log_type = ftl_p2l_log_type(chunk->p2l_log);
}

static void
on_chunk_closed(struct spdk_ftl_dev *dev, struct ftl_nv_cache_chunk *chunk)
{
	assert(chunk->p2l_log);
	ftl_p2l_log_release(dev, chunk->p2l_log);
	chunk->p2l_log = NULL;
}

static int
setup_layout(struct spdk_ftl_dev *dev)
{
@@ -68,6 +90,8 @@ struct ftl_nv_cache_device_type nvc_bdev_non_vss = {
	.ops = {
		.init = init,
		.deinit = deinit,
		.on_chunk_open = on_chunk_open,
		.on_chunk_closed = on_chunk_closed,
		.is_bdev_compatible = is_bdev_compatible,
		.is_chunk_active = ftl_nvc_bdev_common_is_chunk_active,
		.setup_layout = setup_layout,