lib/ftl: separate non-volatile scrub function
The cache needs to be scrubbed during the initial device creation as well as after power loss recovery. This patch extracts the scrubbing code into a separate function. Change-Id: I2cb32e6993a3531470f29f466d990f0d96e45def Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459621 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Wojciech Malikowski <wojciech.malikowski@intel.com> Reviewed-by: Mateusz Kozlowski <mateusz.kozlowski@intel.com>
This commit is contained in:
parent
8d1bb260ea
commit
45372c5768
@ -1276,6 +1276,21 @@ ftl_nv_cache_write_header(struct ftl_nv_cache *nv_cache, spdk_bdev_io_completion
|
||||
cb_fn, cb_arg);
|
||||
}
|
||||
|
||||
int
|
||||
ftl_nv_cache_scrub(struct ftl_nv_cache *nv_cache, spdk_bdev_io_completion_cb cb_fn, void *cb_arg)
|
||||
{
|
||||
struct spdk_ftl_dev *dev = SPDK_CONTAINEROF(nv_cache, struct spdk_ftl_dev, nv_cache);
|
||||
struct ftl_io_channel *ioch;
|
||||
struct spdk_bdev *bdev;
|
||||
|
||||
ioch = spdk_io_channel_get_ctx(dev->ioch);
|
||||
bdev = spdk_bdev_desc_get_bdev(nv_cache->bdev_desc);
|
||||
|
||||
return spdk_bdev_write_zeroes_blocks(nv_cache->bdev_desc, ioch->cache_ioch, 1,
|
||||
spdk_bdev_get_num_blocks(bdev) - 1,
|
||||
cb_fn, cb_arg);
|
||||
}
|
||||
|
||||
static void
|
||||
ftl_write_fail(struct ftl_io *io, int status)
|
||||
{
|
||||
|
@ -296,6 +296,8 @@ bool ftl_ppa_is_written(struct ftl_band *band, struct ftl_ppa ppa);
|
||||
int ftl_flush_active_bands(struct spdk_ftl_dev *dev, spdk_ftl_fn cb_fn, void *cb_arg);
|
||||
int ftl_nv_cache_write_header(struct ftl_nv_cache *nv_cache, spdk_bdev_io_completion_cb cb_fn,
|
||||
void *cb_arg);
|
||||
int ftl_nv_cache_scrub(struct ftl_nv_cache *nv_cache, spdk_bdev_io_completion_cb cb_fn,
|
||||
void *cb_arg);
|
||||
|
||||
#define ftl_to_ppa(addr) \
|
||||
(struct ftl_ppa) { .ppa = (uint64_t)(addr) }
|
||||
|
@ -907,9 +907,6 @@ static int
|
||||
ftl_setup_initial_state(struct spdk_ftl_dev *dev)
|
||||
{
|
||||
struct spdk_ftl_conf *conf = &dev->conf;
|
||||
struct ftl_nv_cache *nv_cache = &dev->nv_cache;
|
||||
struct spdk_bdev *bdev;
|
||||
struct ftl_io_channel *ioch;
|
||||
size_t i;
|
||||
int rc;
|
||||
|
||||
@ -935,12 +932,7 @@ ftl_setup_initial_state(struct spdk_ftl_dev *dev)
|
||||
if (!ftl_dev_has_nv_cache(dev)) {
|
||||
ftl_init_complete(dev);
|
||||
} else {
|
||||
ioch = spdk_io_channel_get_ctx(dev->ioch);
|
||||
bdev = spdk_bdev_desc_get_bdev(nv_cache->bdev_desc);
|
||||
|
||||
rc = spdk_bdev_write_zeroes_blocks(nv_cache->bdev_desc, ioch->cache_ioch,
|
||||
1, spdk_bdev_get_num_blocks(bdev) - 1,
|
||||
ftl_clear_nv_cache_cb, dev);
|
||||
rc = ftl_nv_cache_scrub(&dev->nv_cache, ftl_clear_nv_cache_cb, dev);
|
||||
if (spdk_unlikely(rc != 0)) {
|
||||
SPDK_ERRLOG("Unable to clear the non-volatile cache bdev: %s\n",
|
||||
spdk_strerror(-rc));
|
||||
|
Loading…
Reference in New Issue
Block a user