lib/ftl: report all errors in completion callback

There's no point in synchronously returning an error from ftl_io_write
/ ftl_io_read as they're also reported in the IO's completion callback.
All errors are now reported through io->status.

Change-Id: I4adf4e13221b63715625276042e1172cd63b8f9b
Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/455521
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
Konrad Sztyber 2019-05-10 10:03:05 +02:00 committed by Darek Stojaczyk
parent 2b4609c55b
commit 0ee4bb7789
5 changed files with 38 additions and 77 deletions

View File

@ -780,7 +780,6 @@ ftl_band_write_md(struct ftl_band *band, void *data, size_t lbk_cnt,
{ {
struct spdk_ftl_dev *dev = band->dev; struct spdk_ftl_dev *dev = band->dev;
struct ftl_io *io; struct ftl_io *io;
int rc;
io = ftl_io_init_md_write(dev, band, data, lbk_cnt, cb); io = ftl_io_init_md_write(dev, band, data, lbk_cnt, cb);
if (!io) { if (!io) {
@ -789,12 +788,8 @@ ftl_band_write_md(struct ftl_band *band, void *data, size_t lbk_cnt,
md_fn(dev, &band->md, data); md_fn(dev, &band->md, data);
rc = ftl_io_write(io); ftl_io_write(io);
if (rc == -EAGAIN) { return 0;
rc = 0;
}
return rc;
} }
void void

View File

@ -91,9 +91,6 @@ struct ftl_flush {
LIST_ENTRY(ftl_flush) list_entry; LIST_ENTRY(ftl_flush) list_entry;
}; };
static void _ftl_read(void *);
static void _ftl_write(void *);
static int static int
ftl_rwb_flags_from_io(const struct ftl_io *io) ftl_rwb_flags_from_io(const struct ftl_io *io)
{ {
@ -1584,50 +1581,30 @@ _ftl_io_write(void *ctx)
ftl_io_write((struct ftl_io *)ctx); ftl_io_write((struct ftl_io *)ctx);
} }
int void
ftl_io_write(struct ftl_io *io) ftl_io_write(struct ftl_io *io)
{ {
struct spdk_ftl_dev *dev = io->dev; struct spdk_ftl_dev *dev = io->dev;
/* For normal IOs we just need to copy the data onto the rwb */ /* For normal IOs we just need to copy the data onto the rwb */
if (!(io->flags & FTL_IO_MD)) { if (!(io->flags & FTL_IO_MD)) {
return ftl_rwb_fill(io); /* Other errors should be handled by ftl_rwb_fill */
if (ftl_rwb_fill(io) == -EAGAIN) {
spdk_thread_send_msg(spdk_get_thread(), _ftl_io_write, io);
}
return;
} }
/* Metadata has its own buffer, so it doesn't have to be copied, so just */ /* Metadata has its own buffer, so it doesn't have to be copied, so just */
/* send it the the core thread and schedule the write immediately */ /* send it the the core thread and schedule the write immediately */
if (ftl_check_core_thread(dev)) { if (ftl_check_core_thread(dev)) {
return ftl_submit_write(ftl_wptr_from_band(io->band), io); /* We don't care about the errors, as the IO is either retried or completed
* internally by ftl_submit_write */
ftl_submit_write(ftl_wptr_from_band(io->band), io);
} else {
spdk_thread_send_msg(ftl_get_core_thread(dev), _ftl_io_write, io);
} }
spdk_thread_send_msg(ftl_get_core_thread(dev), _ftl_io_write, io);
return 0;
}
static int
_spdk_ftl_write(struct ftl_io *io)
{
int rc;
rc = ftl_io_write(io);
if (rc == -EAGAIN) {
spdk_thread_send_msg(spdk_io_channel_get_thread(io->ioch),
_ftl_write, io);
return 0;
}
if (rc) {
ftl_io_free(io);
}
return rc;
}
static void
_ftl_write(void *ctx)
{
_spdk_ftl_write(ctx);
} }
int int
@ -1658,26 +1635,29 @@ spdk_ftl_write(struct spdk_ftl_dev *dev, struct spdk_io_channel *ch, uint64_t lb
} }
ftl_io_user_init(dev, io, lba, lba_cnt, iov, iov_cnt, cb_fn, cb_arg, FTL_IO_WRITE); ftl_io_user_init(dev, io, lba, lba_cnt, iov, iov_cnt, cb_fn, cb_arg, FTL_IO_WRITE);
return _spdk_ftl_write(io); ftl_io_write(io);
return 0;
} }
int static void
_ftl_io_read(void *arg)
{
ftl_io_read((struct ftl_io *)arg);
}
void
ftl_io_read(struct ftl_io *io) ftl_io_read(struct ftl_io *io)
{ {
struct spdk_ftl_dev *dev = io->dev; struct spdk_ftl_dev *dev = io->dev;
if (ftl_check_read_thread(dev)) { if (ftl_check_read_thread(dev)) {
return ftl_submit_read(io); /* We don't care about the errors, as the IO is either retried or completed
* internally by ftl_submit_read */
ftl_submit_read(io);
} else {
spdk_thread_send_msg(ftl_get_read_thread(dev), _ftl_io_read, io);
} }
spdk_thread_send_msg(ftl_get_read_thread(dev), _ftl_read, io);
return 0;
}
static void
_ftl_read(void *arg)
{
ftl_io_read((struct ftl_io *)arg);
} }
int int
@ -1798,7 +1778,7 @@ ftl_process_retry_queue(struct spdk_ftl_dev *dev)
/* Retry only if IO is still healthy */ /* Retry only if IO is still healthy */
if (spdk_likely(io->status == 0)) { if (spdk_likely(io->status == 0)) {
rc = ftl_io_read(io); rc = ftl_submit_read(io);
if (rc == -ENOMEM) { if (rc == -ENOMEM) {
break; break;
} }

View File

@ -232,8 +232,8 @@ struct spdk_ftl_dev {
typedef void (*ftl_restore_fn)(struct spdk_ftl_dev *, struct ftl_restore *, int); typedef void (*ftl_restore_fn)(struct spdk_ftl_dev *, struct ftl_restore *, int);
void ftl_apply_limits(struct spdk_ftl_dev *dev); void ftl_apply_limits(struct spdk_ftl_dev *dev);
int ftl_io_read(struct ftl_io *io); void ftl_io_read(struct ftl_io *io);
int ftl_io_write(struct ftl_io *io); void ftl_io_write(struct ftl_io *io);
int ftl_io_erase(struct ftl_io *io); int ftl_io_erase(struct ftl_io *io);
int ftl_io_flush(struct ftl_io *io); int ftl_io_flush(struct ftl_io *io);
int ftl_current_limit(const struct spdk_ftl_dev *dev); int ftl_current_limit(const struct spdk_ftl_dev *dev);

View File

@ -414,21 +414,14 @@ ftl_reloc_io_reinit(struct ftl_io *io, struct ftl_band_reloc *breloc,
static int static int
ftl_reloc_write(struct ftl_band_reloc *breloc, struct ftl_io *io) ftl_reloc_write(struct ftl_band_reloc *breloc, struct ftl_io *io)
{ {
int rc;
if (!(io->flags & FTL_IO_INITIALIZED)) { if (!(io->flags & FTL_IO_INITIALIZED)) {
ftl_reloc_io_reinit(io, breloc, ftl_reloc_write_cb, ftl_reloc_io_reinit(io, breloc, ftl_reloc_write_cb,
FTL_IO_WRITE, FTL_IO_WRITE,
FTL_IO_KEEP_ALIVE | FTL_IO_WEAK | FTL_IO_VECTOR_LBA); FTL_IO_KEEP_ALIVE | FTL_IO_WEAK | FTL_IO_VECTOR_LBA);
} }
rc = ftl_io_write(io); ftl_io_write(io);
if (rc == -EAGAIN) { return 0;
spdk_ring_enqueue(breloc->write_queue, (void **)&io, 1);
return 0;
}
return rc;
} }
static int static int
@ -468,7 +461,6 @@ ftl_reloc_read(struct ftl_band_reloc *breloc, struct ftl_io *io)
{ {
struct ftl_ppa ppa; struct ftl_ppa ppa;
size_t num_lbks; size_t num_lbks;
int rc;
num_lbks = ftl_reloc_next_lbks(breloc, &ppa); num_lbks = ftl_reloc_next_lbks(breloc, &ppa);
@ -482,12 +474,8 @@ ftl_reloc_read(struct ftl_band_reloc *breloc, struct ftl_io *io)
return -1; return -1;
} }
rc = ftl_io_read(io); ftl_io_read(io);
if (rc == -ENOMEM) { return 0;
rc = 0;
}
return rc;
} }
static void static void

View File

@ -125,18 +125,16 @@ ftl_band_ppa_from_lbkoff(struct ftl_band *band, uint64_t lbkoff)
return ppa; return ppa;
} }
int void
ftl_io_read(struct ftl_io *io) ftl_io_read(struct ftl_io *io)
{ {
io->cb.fn(io->cb.ctx, 0); io->cb.fn(io->cb.ctx, 0);
return 0;
} }
int void
ftl_io_write(struct ftl_io *io) ftl_io_write(struct ftl_io *io)
{ {
io->cb.fn(io->cb.ctx, 0); io->cb.fn(io->cb.ctx, 0);
return 0;
} }
struct ftl_io * struct ftl_io *