lib/ftl: retrieve LBA / iovec via getter functions

Replaced all direct accesses to io->lba / io->iov with getter functions,
as they both should behave differently based on the FTL_IO_VECTOR_LBA
flag and io->iov_cnt respectively.

Change-Id: I0d387a2a908cc37afa9e1b97ca5b408cef0d6b08
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450265
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
Konrad Sztyber 2019-04-05 14:08:42 +02:00 committed by Darek Stojaczyk
parent c967d539d8
commit 3363ab70dd
4 changed files with 21 additions and 11 deletions

View File

@ -790,9 +790,10 @@ ftl_lba_read_next_ppa(struct ftl_io *io, struct ftl_ppa *ppa, size_t lbk)
struct ftl_ppa next_ppa;
size_t i;
*ppa = ftl_l2p_get(dev, io->lba.single + lbk);
*ppa = ftl_l2p_get(dev, ftl_io_current_lba(io));
SPDK_DEBUGLOG(SPDK_LOG_FTL_CORE, "Read ppa:%lx, lba:%lu\n", ppa->ppa, io->lba.single);
SPDK_DEBUGLOG(SPDK_LOG_FTL_CORE, "Read ppa:%lx, lba:%lu\n",
ppa->ppa, ftl_io_current_lba(io));
/* If the PPA is invalid, skip it (the buffer should already be zero'ed) */
if (ftl_ppa_invalid(*ppa)) {
@ -800,7 +801,7 @@ ftl_lba_read_next_ppa(struct ftl_io *io, struct ftl_ppa *ppa, size_t lbk)
}
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, ftl_io_current_lba(io), *ppa, ftl_io_iovec_addr(io))) {
return 0;
}
@ -809,7 +810,7 @@ ftl_lba_read_next_ppa(struct ftl_io *io, struct ftl_ppa *ppa, size_t lbk)
}
for (i = 1; i < ftl_io_iovec_len_left(io); ++i) {
next_ppa = ftl_l2p_get(dev, io->lba.single + lbk + i);
next_ppa = ftl_l2p_get(dev, ftl_io_get_lba(io, io->pos + i));
if (ftl_ppa_invalid(next_ppa) || ftl_ppa_cached(next_ppa)) {
break;

View File

@ -83,15 +83,23 @@ ftl_io_iovec(struct ftl_io *io)
}
uint64_t
ftl_io_current_lba(struct ftl_io *io)
ftl_io_get_lba(const struct ftl_io *io, size_t offset)
{
assert(offset < io->lbk_cnt);
if (io->flags & FTL_IO_VECTOR_LBA) {
return io->lba.vector[io->pos];
return io->lba.vector[offset];
} else {
return io->lba.single + io->pos;
return io->lba.single + offset;
}
}
uint64_t
ftl_io_current_lba(const struct ftl_io *io)
{
return ftl_io_get_lba(io, io->pos);
}
void
ftl_io_advance(struct ftl_io *io, size_t lbk_cnt)
{

View File

@ -267,7 +267,8 @@ void ftl_io_clear(struct ftl_io *io);
void ftl_io_inc_req(struct ftl_io *io);
void ftl_io_dec_req(struct ftl_io *io);
struct iovec *ftl_io_iovec(struct ftl_io *io);
uint64_t ftl_io_current_lba(struct ftl_io *io);
uint64_t ftl_io_current_lba(const struct ftl_io *io);
uint64_t ftl_io_get_lba(const struct ftl_io *io, size_t offset);
void ftl_io_advance(struct ftl_io *io, size_t lbk_cnt);
size_t ftl_iovec_num_lbks(struct iovec *iov, size_t iov_cnt);
void *ftl_io_iovec_addr(struct ftl_io *io);

View File

@ -224,7 +224,7 @@ ftl_trace_lba_io_init(struct spdk_ftl_dev *dev, const struct ftl_io *io)
}
}
spdk_trace_record(tpoint_id, io->trace, io->lbk_cnt, 0, io->lba.single);
spdk_trace_record(tpoint_id, io->trace, io->lbk_cnt, 0, ftl_io_get_lba(io, 0));
}
void
@ -233,7 +233,7 @@ ftl_trace_rwb_fill(struct spdk_ftl_dev *dev, const struct ftl_io *io)
assert(io->trace != FTL_TRACE_INVALID_ID);
spdk_trace_record(FTL_TRACE_WRITE_RWB_FILL(ftl_trace_io_source(io)), io->trace,
0, 0, io->lba.single + io->pos);
0, 0, ftl_io_current_lba(io));
}
void
@ -298,7 +298,7 @@ ftl_trace_completion(struct spdk_ftl_dev *dev, const struct ftl_io *io,
}
}
spdk_trace_record(tpoint_id, io->trace, 0, 0, io->lba.single);
spdk_trace_record(tpoint_id, io->trace, 0, 0, ftl_io_get_lba(io, 0));
}
void