diff --git a/lib/ftl/ftl_band.c b/lib/ftl/ftl_band.c index d56a01440..52869ab5b 100644 --- a/lib/ftl/ftl_band.c +++ b/lib/ftl/ftl_band.c @@ -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 ftl_io *io; - int rc; io = ftl_io_init_md_write(dev, band, data, lbk_cnt, cb); 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); - rc = ftl_io_write(io); - if (rc == -EAGAIN) { - rc = 0; - } - - return rc; + ftl_io_write(io); + return 0; } void diff --git a/lib/ftl/ftl_core.c b/lib/ftl/ftl_core.c index 512cd4942..ec30240ee 100644 --- a/lib/ftl/ftl_core.c +++ b/lib/ftl/ftl_core.c @@ -91,9 +91,6 @@ struct ftl_flush { LIST_ENTRY(ftl_flush) list_entry; }; -static void _ftl_read(void *); -static void _ftl_write(void *); - static int 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); } -int +void ftl_io_write(struct ftl_io *io) { struct spdk_ftl_dev *dev = io->dev; /* For normal IOs we just need to copy the data onto the rwb */ 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 */ /* send it the the core thread and schedule the write immediately */ 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 @@ -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); - 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) { struct spdk_ftl_dev *dev = io->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 @@ -1798,7 +1778,7 @@ ftl_process_retry_queue(struct spdk_ftl_dev *dev) /* Retry only if IO is still healthy */ if (spdk_likely(io->status == 0)) { - rc = ftl_io_read(io); + rc = ftl_submit_read(io); if (rc == -ENOMEM) { break; } diff --git a/lib/ftl/ftl_core.h b/lib/ftl/ftl_core.h index 1dc35fad3..6ed0504a0 100644 --- a/lib/ftl/ftl_core.h +++ b/lib/ftl/ftl_core.h @@ -232,8 +232,8 @@ struct spdk_ftl_dev { typedef void (*ftl_restore_fn)(struct spdk_ftl_dev *, struct ftl_restore *, int); void ftl_apply_limits(struct spdk_ftl_dev *dev); -int ftl_io_read(struct ftl_io *io); -int ftl_io_write(struct ftl_io *io); +void ftl_io_read(struct ftl_io *io); +void ftl_io_write(struct ftl_io *io); int ftl_io_erase(struct ftl_io *io); int ftl_io_flush(struct ftl_io *io); int ftl_current_limit(const struct spdk_ftl_dev *dev); diff --git a/lib/ftl/ftl_reloc.c b/lib/ftl/ftl_reloc.c index 09c29aff4..2f159c9be 100644 --- a/lib/ftl/ftl_reloc.c +++ b/lib/ftl/ftl_reloc.c @@ -414,21 +414,14 @@ ftl_reloc_io_reinit(struct ftl_io *io, struct ftl_band_reloc *breloc, static int ftl_reloc_write(struct ftl_band_reloc *breloc, struct ftl_io *io) { - int rc; - if (!(io->flags & FTL_IO_INITIALIZED)) { ftl_reloc_io_reinit(io, breloc, ftl_reloc_write_cb, FTL_IO_WRITE, FTL_IO_KEEP_ALIVE | FTL_IO_WEAK | FTL_IO_VECTOR_LBA); } - rc = ftl_io_write(io); - if (rc == -EAGAIN) { - spdk_ring_enqueue(breloc->write_queue, (void **)&io, 1); - return 0; - } - - return rc; + ftl_io_write(io); + return 0; } static int @@ -468,7 +461,6 @@ ftl_reloc_read(struct ftl_band_reloc *breloc, struct ftl_io *io) { struct ftl_ppa ppa; size_t num_lbks; - int rc; 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; } - rc = ftl_io_read(io); - if (rc == -ENOMEM) { - rc = 0; - } - - return rc; + ftl_io_read(io); + return 0; } static void diff --git a/test/unit/lib/ftl/ftl_reloc.c/ftl_reloc_ut.c b/test/unit/lib/ftl/ftl_reloc.c/ftl_reloc_ut.c index 825a32b2b..9e082463a 100644 --- a/test/unit/lib/ftl/ftl_reloc.c/ftl_reloc_ut.c +++ b/test/unit/lib/ftl/ftl_reloc.c/ftl_reloc_ut.c @@ -125,18 +125,16 @@ ftl_band_ppa_from_lbkoff(struct ftl_band *band, uint64_t lbkoff) return ppa; } -int +void ftl_io_read(struct ftl_io *io) { io->cb.fn(io->cb.ctx, 0); - return 0; } -int +void ftl_io_write(struct ftl_io *io) { io->cb.fn(io->cb.ctx, 0); - return 0; } struct ftl_io *