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

lib/ftl: Rename unmap to trim



Change the naming to be consistent within the lib

Change-Id: I51e6d0b983effc6d0f4c39abc8e5662aae54b541
Signed-off-by: default avatarMateusz Kozlowski <mateusz.kozlowski@solidigm.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/23153


Reviewed-by: default avatarBen Walker <ben@nvidia.com>
Reviewed-by: default avatarArtur Paszkiewicz <artur.paszkiewicz@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 5555d51c
Loading
Loading
Loading
Loading
+30 −30
Original line number Diff line number Diff line
@@ -361,8 +361,8 @@ start_io(struct ftl_io *io)
	case FTL_IO_WRITE:
		TAILQ_INSERT_TAIL(&dev->wr_sq, io, queue_entry);
		break;
	case FTL_IO_UNMAP:
		TAILQ_INSERT_TAIL(&dev->unmap_sq, io, queue_entry);
	case FTL_IO_TRIM:
		TAILQ_INSERT_TAIL(&dev->trim_sq, io, queue_entry);
		break;
	default:
		io->status = -EOPNOTSUPP;
@@ -450,12 +450,12 @@ spdk_ftl_readv(struct spdk_ftl_dev *dev, struct ftl_io *io, struct spdk_io_chann
}

int
ftl_unmap(struct spdk_ftl_dev *dev, struct ftl_io *io, struct spdk_io_channel *ch,
ftl_trim(struct spdk_ftl_dev *dev, struct ftl_io *io, struct spdk_io_channel *ch,
	 uint64_t lba, uint64_t lba_cnt, spdk_ftl_fn cb_fn, void *cb_arg)
{
	int rc;

	rc = ftl_io_init(ch, io, lba, lba_cnt, NULL, 0, cb_fn, cb_arg, FTL_IO_UNMAP);
	rc = ftl_io_init(ch, io, lba, lba_cnt, NULL, 0, cb_fn, cb_arg, FTL_IO_TRIM);
	if (rc) {
		return rc;
	}
@@ -493,7 +493,7 @@ spdk_ftl_unmap(struct spdk_ftl_dev *dev, struct ftl_io *io, struct spdk_io_chann
		}

		/* Otherwise unaligned IO requests are NOPs */
		rc = ftl_io_init(ch, io, lba, lba_cnt, NULL, 0, cb_fn, cb_arg, FTL_IO_UNMAP);
		rc = ftl_io_init(ch, io, lba, lba_cnt, NULL, 0, cb_fn, cb_arg, FTL_IO_TRIM);
		if (rc) {
			return rc;
		}
@@ -504,9 +504,9 @@ spdk_ftl_unmap(struct spdk_ftl_dev *dev, struct ftl_io *io, struct spdk_io_chann
	}

	if (io) {
		rc = ftl_unmap(dev, io, ch, lba, lba_cnt, cb_fn, cb_arg);
		rc = ftl_trim(dev, io, ch, lba, lba_cnt, cb_fn, cb_arg);
	} else {
		rc = ftl_mngt_unmap(dev, lba, lba_cnt, cb_fn, cb_arg);
		rc = ftl_mngt_trim(dev, lba, lba_cnt, cb_fn, cb_arg);
	}

	return rc;
@@ -551,15 +551,15 @@ ftl_process_io_channel(struct spdk_ftl_dev *dev, struct ftl_io_channel *ioch)
}

static void
ftl_process_unmap_cb(struct spdk_ftl_dev *dev, struct ftl_md *md, int status)
ftl_process_trim_cb(struct spdk_ftl_dev *dev, struct ftl_md *md, int status)
{
	struct ftl_io *io = md->owner.cb_ctx;

	io->dev->unmap_qd--;
	io->dev->trim_qd--;

	if (spdk_unlikely(status)) {
#ifdef SPDK_FTL_RETRY_ON_ERROR
		TAILQ_INSERT_HEAD(&io->dev->unmap_sq, io, queue_entry);
		TAILQ_INSERT_HEAD(&io->dev->trim_sq, io, queue_entry);
		return;
#else
		io->status = status;
@@ -570,7 +570,7 @@ ftl_process_unmap_cb(struct spdk_ftl_dev *dev, struct ftl_md *md, int status)
}

void
ftl_set_unmap_map(struct spdk_ftl_dev *dev, uint64_t lba, uint64_t num_blocks, uint64_t seq_id)
ftl_set_trim_map(struct spdk_ftl_dev *dev, uint64_t lba, uint64_t num_blocks, uint64_t seq_id)
{
	uint64_t first_page, num_pages;
	uint64_t first_md_block, num_md_blocks, num_pages_in_block;
@@ -584,7 +584,7 @@ ftl_set_unmap_map(struct spdk_ftl_dev *dev, uint64_t lba, uint64_t num_blocks, u
	num_pages = num_blocks / lbas_in_page;

	for (i = first_page; i < first_page + num_pages; ++i) {
		ftl_bitmap_set(dev->unmap_map, i);
		ftl_bitmap_set(dev->trim_map, i);
		page[i] = seq_id;
	}

@@ -593,14 +593,14 @@ ftl_set_unmap_map(struct spdk_ftl_dev *dev, uint64_t lba, uint64_t num_blocks, u
	num_md_blocks = spdk_divide_round_up(num_pages, num_pages_in_block);
	page_vss = ftl_md_get_vss_buffer(md) + first_md_block;
	for (i = first_md_block; i < num_md_blocks; ++i, page_vss++) {
		page_vss->unmap.start_lba = lba;
		page_vss->unmap.num_blocks = num_blocks;
		page_vss->unmap.seq_id = seq_id;
		page_vss->trim.start_lba = lba;
		page_vss->trim.num_blocks = num_blocks;
		page_vss->trim.seq_id = seq_id;
	}
}

static bool
ftl_process_unmap(struct ftl_io *io)
ftl_process_trim(struct ftl_io *io)
{
	struct spdk_ftl_dev *dev = io->dev;
	struct ftl_md *md = dev->layout.md[FTL_LAYOUT_REGION_TYPE_TRIM_MD];
@@ -611,19 +611,19 @@ ftl_process_unmap(struct ftl_io *io)
		return false;
	}

	dev->unmap_in_progress = true;
	dev->unmap_qd++;
	dev->trim_in_progress = true;
	dev->trim_qd++;

	dev->sb_shm->trim.start_lba = io->lba;
	dev->sb_shm->trim.num_blocks = io->num_blocks;
	dev->sb_shm->trim.seq_id = seq_id;
	dev->sb_shm->trim.in_progress = true;
	ftl_set_unmap_map(dev, io->lba, io->num_blocks, seq_id);
	ftl_debug_inject_unmap_error();
	ftl_set_trim_map(dev, io->lba, io->num_blocks, seq_id);
	ftl_debug_inject_trim_error();
	dev->sb_shm->trim.in_progress = false;

	md->owner.cb_ctx = io;
	md->cb = ftl_process_unmap_cb;
	md->cb = ftl_process_trim_cb;

	ftl_md_persist(md);

@@ -658,19 +658,19 @@ ftl_process_io_queue(struct spdk_ftl_dev *dev)
		ftl_add_io_activity(dev);
	}

	if (!TAILQ_EMPTY(&dev->unmap_sq) && dev->unmap_qd == 0) {
		io = TAILQ_FIRST(&dev->unmap_sq);
		TAILQ_REMOVE(&dev->unmap_sq, io, queue_entry);
		assert(io->type == FTL_IO_UNMAP);
	if (!TAILQ_EMPTY(&dev->trim_sq) && dev->trim_qd == 0) {
		io = TAILQ_FIRST(&dev->trim_sq);
		TAILQ_REMOVE(&dev->trim_sq, io, queue_entry);
		assert(io->type == FTL_IO_TRIM);

		/*
		 * Unmap operation requires generating a sequence id for itself, which it gets based on the open chunk
		 * Trim operation requires generating a sequence id for itself, which it gets based on the open chunk
		 * in nv cache. If there are no open chunks (because we're in the middle of state transition or compaction
		 * lagged behind), then we need to wait for the nv cache to resolve the situation - it's fine to just put the
		 * unmap and try again later.
		 * trim and try again later.
		 */
		if (!ftl_process_unmap(io)) {
			TAILQ_INSERT_HEAD(&dev->unmap_sq, io, queue_entry);
		if (!ftl_process_trim(io)) {
			TAILQ_INSERT_HEAD(&dev->trim_sq, io, queue_entry);
		} else {
			ftl_add_io_activity(dev);
		}
+9 −9
Original line number Diff line number Diff line
@@ -166,13 +166,13 @@ struct spdk_ftl_dev {
	TAILQ_HEAD(, ftl_io)		wr_sq;

	/* Trim submission queue */
	TAILQ_HEAD(, ftl_io)		unmap_sq;
	TAILQ_HEAD(, ftl_io)		trim_sq;

	/* Trim valid map */
	struct ftl_bitmap		*unmap_map;
	struct ftl_md			*unmap_map_md;
	size_t				unmap_qd;
	bool				unmap_in_progress;
	struct ftl_bitmap		*trim_map;
	struct ftl_md			*trim_map_md;
	size_t				trim_qd;
	bool				trim_in_progress;

	/* Writer for user IOs */
	struct ftl_writer		writer_user;
@@ -217,7 +217,7 @@ bool ftl_needs_reloc(struct spdk_ftl_dev *dev);

struct ftl_band *ftl_band_get_next_free(struct spdk_ftl_dev *dev);

void ftl_set_unmap_map(struct spdk_ftl_dev *dev, uint64_t lba, uint64_t num_blocks,
void ftl_set_trim_map(struct spdk_ftl_dev *dev, uint64_t lba, uint64_t num_blocks,
		      uint64_t seq_id);

void ftl_recover_max_seq(struct spdk_ftl_dev *dev);
@@ -227,7 +227,7 @@ void ftl_stats_bdev_io_completed(struct spdk_ftl_dev *dev, enum ftl_stats_type t

void ftl_stats_crc_error(struct spdk_ftl_dev *dev, enum ftl_stats_type type);

int ftl_unmap(struct spdk_ftl_dev *dev, struct ftl_io *io, struct spdk_io_channel *ch,
int ftl_trim(struct spdk_ftl_dev *dev, struct ftl_io *io, struct spdk_io_channel *ch,
	     uint64_t lba, size_t lba_cnt, spdk_ftl_fn cb_fn, void *cb_arg);

static inline uint64_t
+4 −4
Original line number Diff line number Diff line
@@ -14,11 +14,11 @@
void ftl_band_validate_md(struct ftl_band *band, ftl_band_validate_md_cb cb);
void ftl_dev_dump_bands(struct spdk_ftl_dev *dev);
static inline void
ftl_debug_inject_unmap_error(void)
ftl_debug_inject_trim_error(void)
{
	static int unmap_no = 0;
	static int trim_no = 0;

	if (getenv("FTL_CRASH_ON_UNMAP") && unmap_no++ == 256) {
	if (getenv("FTL_CRASH_ON_TRIM") && trim_no++ == 256) {
		abort();
	}
}
@@ -45,7 +45,7 @@ ftl_dev_dump_bands(struct spdk_ftl_dev *dev)
{
}
static inline void
ftl_debug_inject_unmap_error(void)
ftl_debug_inject_trim_error(void)
{
}
#endif
+1 −1
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ allocate_dev(const struct spdk_ftl_conf *conf, int *error)

	TAILQ_INIT(&dev->rd_sq);
	TAILQ_INIT(&dev->wr_sq);
	TAILQ_INIT(&dev->unmap_sq);
	TAILQ_INIT(&dev->trim_sq);
	TAILQ_INIT(&dev->ioch_queue);

	ftl_writer_init(dev, &dev->writer_user, SPDK_FTL_LIMIT_HIGH, FTL_BAND_TYPE_COMPACTION);
+2 −2
Original line number Diff line number Diff line
@@ -134,9 +134,9 @@ ftl_io_cb(struct ftl_io *io, void *arg, int status)
				ftl_io_clear(io);
				TAILQ_INSERT_HEAD(&io->dev->wr_sq, io, queue_entry);
				break;
			case FTL_IO_UNMAP:
			case FTL_IO_TRIM:
				ftl_io_clear(io);
				TAILQ_INSERT_HEAD(&io->dev->unmap_sq, io, queue_entry);
				TAILQ_INSERT_HEAD(&io->dev->trim_sq, io, queue_entry);
				break;
			default:
				/* Unknown IO type, complete to the user */
Loading