lib/ftl: name ftl_io's LBA / iovec unions

Replaced the unnamed unions with named ones. It makes the assignments
easier (it allows for direct assignment instead of having to choose the
correct union member).

Change-Id: I130233a096070092275a040e73cbaf36106ae1ab
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453682
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 12:46:58 +02:00 committed by Jim Harris
parent f719268ef8
commit 8c6f63a3f1
6 changed files with 32 additions and 32 deletions

View File

@ -789,9 +789,9 @@ ftl_lba_read_next_ppa(struct ftl_io *io, struct ftl_ppa *ppa,
struct ftl_ppa next_ppa;
size_t i;
*ppa = ftl_l2p_get(dev, io->lba + lbk);
*ppa = ftl_l2p_get(dev, io->lba.single + lbk);
SPDK_DEBUGLOG(SPDK_LOG_FTL_CORE, "Read ppa:%lx, lba:%lu\n", ppa->ppa, io->lba);
SPDK_DEBUGLOG(SPDK_LOG_FTL_CORE, "Read ppa:%lx, lba:%lu\n", ppa->ppa, io->lba.single);
/* If the PPA is invalid, skip it (the buffer should already be zero'ed) */
if (ftl_ppa_invalid(*ppa)) {
@ -800,7 +800,7 @@ ftl_lba_read_next_ppa(struct ftl_io *io, struct ftl_ppa *ppa,
}
if (ftl_ppa_cached(*ppa)) {
if (!ftl_ppa_cache_read(io, io->lba + 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;
}
@ -810,7 +810,7 @@ ftl_lba_read_next_ppa(struct ftl_io *io, struct ftl_ppa *ppa,
}
for (i = 1; i < ftl_io_iovec_len_left(io); ++i) {
next_ppa = ftl_l2p_get(dev, io->lba + lbk + i);
next_ppa = ftl_l2p_get(dev, io->lba.single + lbk + i);
if (ftl_ppa_invalid(next_ppa) || ftl_ppa_cached(next_ppa)) {
break;
@ -1040,7 +1040,7 @@ ftl_submit_child_write(struct ftl_wptr *wptr, struct ftl_io *io, int lbk_cnt)
}
rc = spdk_nvme_ns_cmd_write_with_md(dev->ns, ftl_get_write_qpair(dev),
child->iov.iov_base, child->md,
ftl_io_iovec_addr(child), child->md,
ftl_ppa_addr_pack(dev, wptr->ppa),
lbk_cnt, ftl_io_cmpl_cb, child, 0, 0, 0);
if (rc) {
@ -1249,7 +1249,7 @@ ftl_rwb_entry_fill(struct ftl_rwb_entry *entry, struct ftl_io *io)
entry->trace = io->trace;
if (entry->md) {
memcpy(entry->md, &entry->lba, sizeof(io->lba));
memcpy(entry->md, &entry->lba, sizeof(entry->lba));
}
}

View File

@ -76,9 +76,9 @@ struct iovec *
ftl_io_iovec(struct ftl_io *io)
{
if (io->iov_cnt > 1) {
return io->iovs;
return io->iov.vector;
} else {
return &io->iov;
return &io->iov.single;
}
}
@ -86,9 +86,9 @@ uint64_t
ftl_io_current_lba(struct ftl_io *io)
{
if (io->flags & FTL_IO_VECTOR_LBA) {
return io->lbas[io->pos];
return io->lba.vector[io->pos];
} else {
return io->lba + io->pos;
return io->lba.single + io->pos;
}
}
@ -157,12 +157,12 @@ ftl_io_init_iovec(struct ftl_io *io, void *buf,
size_t i;
if (iov_cnt > 1) {
iov = io->iovs = calloc(iov_cnt, sizeof(*iov));
iov = io->iov.vector = calloc(iov_cnt, sizeof(*iov));
if (!iov) {
return -ENOMEM;
}
} else {
iov = &io->iov;
iov = &io->iov.single;
}
io->iov_pos = 0;
@ -182,7 +182,7 @@ ftl_io_init(struct ftl_io *io, struct spdk_ftl_dev *dev,
io->flags |= flags | FTL_IO_INITIALIZED;
io->type = type;
io->dev = dev;
io->lba = FTL_LBA_INVALID;
io->lba.single = FTL_LBA_INVALID;
io->cb.fn = fn;
io->cb.ctx = ctx;
io->trace = ftl_trace_alloc_id(dev);
@ -286,14 +286,14 @@ ftl_io_user_init(struct spdk_ftl_dev *dev, struct ftl_io *io, uint64_t lba, size
ftl_io_init(io, dev, cb_fn, cb_arg, 0, type);
io->lba = lba;
io->lba.single = lba;
io->lbk_cnt = lbk_cnt;
io->iov_cnt = iov_cnt;
if (iov_cnt > 1) {
io->iovs = iov;
io->iov.vector = iov;
} else {
io->iov = *iov;
io->iov.single = *iov;
}
ftl_trace_lba_io_init(io->dev, io);
@ -307,7 +307,7 @@ _ftl_io_free(struct ftl_io *io)
assert(LIST_EMPTY(&io->children));
if ((io->flags & FTL_IO_INTERNAL) && io->iov_cnt > 1) {
free(io->iovs);
free(io->iov.vector);
}
if (pthread_spin_destroy(&io->lock)) {

View File

@ -144,11 +144,11 @@ struct ftl_io {
union {
/* LBA table */
uint64_t *lbas;
uint64_t *vector;
/* First LBA */
uint64_t lba;
};
uint64_t single;
} lba;
/* First PPA */
struct ftl_ppa ppa;
@ -161,11 +161,11 @@ struct ftl_io {
union {
/* IO vector table */
struct iovec *iovs;
struct iovec *vector;
/* Single iovec */
struct iovec iov;
};
struct iovec single;
} iov;
/* Metadata */
void *md;

View File

@ -213,8 +213,8 @@ ftl_reloc_prep(struct ftl_band_reloc *breloc)
static void
ftl_reloc_free_io(struct ftl_band_reloc *breloc, struct ftl_io *io)
{
spdk_dma_free(io->iov.iov_base);
free(io->lbas);
spdk_dma_free(io->iov.single.iov_base);
free(io->lba.vector);
spdk_ring_enqueue(breloc->free_queue, (void **)&io, 1);
}
@ -394,18 +394,18 @@ ftl_reloc_io_reinit(struct ftl_io *io, struct ftl_band_reloc *breloc,
io->ppa = ppa;
io->band = breloc->band;
io->lbas = calloc(io->lbk_cnt, sizeof(uint64_t));
io->lba.vector = calloc(io->lbk_cnt, sizeof(uint64_t));
for (i = 0; i < io->lbk_cnt; ++i) {
ppa.lbk = io->ppa.lbk + i;
lbkoff = ftl_band_lbkoff_from_ppa(breloc->band, ppa);
if (!ftl_band_lbkoff_valid(breloc->band, lbkoff)) {
io->lbas[i] = FTL_LBA_INVALID;
io->lba.vector[i] = FTL_LBA_INVALID;
continue;
}
io->lbas[i] = breloc->band->md.lba_map[lbkoff];
io->lba.vector[i] = breloc->band->md.lba_map[lbkoff];
}
ftl_trace_lba_io_init(io->dev, 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);
spdk_trace_record(tpoint_id, io->trace, io->lbk_cnt, 0, io->lba.single);
}
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 + io->pos);
0, 0, io->lba.single + io->pos);
}
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);
spdk_trace_record(tpoint_id, io->trace, 0, 0, io->lba.single);
}
void

View File

@ -156,7 +156,7 @@ ftl_io_init_internal(const struct ftl_io_init_opts *opts)
io->cb.fn = opts->fn;
io->cb.ctx = io;
io->lbk_cnt = opts->req_size;
io->iov.iov_base = opts->data;
io->iov.single.iov_base = opts->data;
return io;
}