2022-06-22 12:54:05 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
* Copyright (c) Intel Corporation.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "spdk/likely.h"
|
|
|
|
#include "spdk/stdinc.h"
|
|
|
|
#include "spdk/nvme.h"
|
|
|
|
#include "spdk/thread.h"
|
|
|
|
#include "spdk/bdev_module.h"
|
|
|
|
#include "spdk/string.h"
|
|
|
|
#include "spdk/ftl.h"
|
|
|
|
#include "spdk/crc32.h"
|
|
|
|
|
|
|
|
#include "ftl_core.h"
|
2022-06-20 09:44:35 +00:00
|
|
|
#include "ftl_debug.h"
|
2022-06-22 12:01:59 +00:00
|
|
|
#include "ftl_internal.h"
|
2022-06-22 10:11:47 +00:00
|
|
|
#include "mngt/ftl_mngt.h"
|
2022-06-15 09:55:53 +00:00
|
|
|
#include "utils/ftl_mempool.h"
|
2022-06-22 12:54:05 +00:00
|
|
|
|
2022-06-21 11:04:41 +00:00
|
|
|
static int
|
|
|
|
ftl_shutdown_complete(struct spdk_ftl_dev *dev)
|
|
|
|
{
|
|
|
|
if (dev->num_inflight) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2022-06-21 11:03:44 +00:00
|
|
|
void
|
|
|
|
spdk_ftl_dev_get_attrs(const struct spdk_ftl_dev *dev, struct spdk_ftl_attrs *attrs)
|
|
|
|
{
|
|
|
|
attrs->num_blocks = dev->num_lbas;
|
|
|
|
attrs->block_size = FTL_BLOCK_SIZE;
|
|
|
|
attrs->num_zones = ftl_get_num_zones(dev);
|
|
|
|
attrs->zone_size = ftl_get_num_blocks_in_zone(dev);
|
|
|
|
attrs->optimum_io_size = dev->xfer_size;
|
|
|
|
}
|
|
|
|
|
2022-06-21 11:04:41 +00:00
|
|
|
int
|
|
|
|
ftl_core_poller(void *ctx)
|
|
|
|
{
|
|
|
|
struct spdk_ftl_dev *dev = ctx;
|
|
|
|
uint64_t io_activity_total_old = dev->io_activity_total;
|
|
|
|
|
|
|
|
if (dev->halt && ftl_shutdown_complete(dev)) {
|
|
|
|
spdk_poller_unregister(&dev->core_poller);
|
|
|
|
return SPDK_POLLER_IDLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (io_activity_total_old != dev->io_activity_total) {
|
|
|
|
return SPDK_POLLER_BUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
return SPDK_POLLER_IDLE;
|
|
|
|
}
|
|
|
|
|
2022-06-21 09:20:47 +00:00
|
|
|
struct spdk_io_channel *
|
|
|
|
spdk_ftl_get_io_channel(struct spdk_ftl_dev *dev)
|
|
|
|
{
|
|
|
|
return spdk_get_io_channel(dev);
|
|
|
|
}
|
|
|
|
|
2022-06-22 12:54:05 +00:00
|
|
|
SPDK_LOG_REGISTER_COMPONENT(ftl_core)
|