lib/ftl: trace early read completion in one place

Moved early read completion (due to cache hit or reading unwritten
data) traces to ftl_submit_read to keep them in one place. Also removed
the context parameter from next_ppa function, as it was unused.

Change-Id: Ic69174a6cdc0e626550cd673789e86bb891094bf
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453683
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Konrad Sztyber 2019-05-08 14:45:50 +02:00 committed by Jim Harris
parent 8c6f63a3f1
commit 4c03cae6f5

View File

@ -90,7 +90,7 @@ struct ftl_flush {
LIST_ENTRY(ftl_flush) list_entry; LIST_ENTRY(ftl_flush) list_entry;
}; };
typedef int (*ftl_next_ppa_fn)(struct ftl_io *, struct ftl_ppa *, size_t, void *); typedef int (*ftl_next_ppa_fn)(struct ftl_io *, struct ftl_ppa *, size_t);
static void _ftl_read(void *); static void _ftl_read(void *);
static void _ftl_write(void *); static void _ftl_write(void *);
@ -214,8 +214,7 @@ ftl_md_write_cb(void *arg, int status)
} }
static int static int
ftl_ppa_read_next_ppa(struct ftl_io *io, struct ftl_ppa *ppa, ftl_ppa_read_next_ppa(struct ftl_io *io, struct ftl_ppa *ppa, size_t lbk)
size_t lbk, void *ctx)
{ {
struct spdk_ftl_dev *dev = io->dev; struct spdk_ftl_dev *dev = io->dev;
size_t lbk_cnt, max_lbks; size_t lbk_cnt, max_lbks;
@ -692,7 +691,7 @@ ftl_read_retry(int rc)
static int static int
ftl_read_canceled(int rc) ftl_read_canceled(int rc)
{ {
return rc == 0; return rc == -EFAULT || rc == 0;
} }
static void static void
@ -714,7 +713,7 @@ ftl_submit_read(struct ftl_io *io, ftl_next_ppa_fn next_ppa,
while (io->pos < io->lbk_cnt) { while (io->pos < io->lbk_cnt) {
/* We might hit the cache here, if so, skip the read */ /* We might hit the cache here, if so, skip the read */
lbk_cnt = rc = next_ppa(io, &ppa, io->pos, ctx); lbk_cnt = rc = next_ppa(io, &ppa, io->pos);
/* We might need to retry the read from scratch (e.g. */ /* We might need to retry the read from scratch (e.g. */
/* because write was under way and completed before */ /* because write was under way and completed before */
@ -726,6 +725,9 @@ ftl_submit_read(struct ftl_io *io, ftl_next_ppa_fn next_ppa,
/* We don't have to schedule the read, as it was read from cache */ /* We don't have to schedule the read, as it was read from cache */
if (ftl_read_canceled(rc)) { if (ftl_read_canceled(rc)) {
ftl_io_advance(io, 1); ftl_io_advance(io, 1);
ftl_trace_completion(io->dev, io, rc ? FTL_TRACE_COMPLETION_INVALID :
FTL_TRACE_COMPLETION_CACHE);
rc = 0;
continue; continue;
} }
@ -782,8 +784,7 @@ out:
} }
static int static int
ftl_lba_read_next_ppa(struct ftl_io *io, struct ftl_ppa *ppa, ftl_lba_read_next_ppa(struct ftl_io *io, struct ftl_ppa *ppa, size_t lbk)
size_t lbk, void *ctx)
{ {
struct spdk_ftl_dev *dev = io->dev; struct spdk_ftl_dev *dev = io->dev;
struct ftl_ppa next_ppa; struct ftl_ppa next_ppa;
@ -795,13 +796,11 @@ ftl_lba_read_next_ppa(struct ftl_io *io, struct ftl_ppa *ppa,
/* If the PPA is invalid, skip it (the buffer should already be zero'ed) */ /* If the PPA is invalid, skip it (the buffer should already be zero'ed) */
if (ftl_ppa_invalid(*ppa)) { if (ftl_ppa_invalid(*ppa)) {
ftl_trace_completion(io->dev, io, FTL_TRACE_COMPLETION_INVALID); return -EFAULT;
return 0;
} }
if (ftl_ppa_cached(*ppa)) { if (ftl_ppa_cached(*ppa)) {
if (!ftl_ppa_cache_read(io, io->lba.single + lbk, *ppa, ftl_io_iovec_addr(io))) { if (!ftl_ppa_cache_read(io, io->lba.single + lbk, *ppa, ftl_io_iovec_addr(io))) {
ftl_trace_completion(io->dev, io, FTL_TRACE_COMPLETION_CACHE);
return 0; return 0;
} }