Spdk/lib/ftl/ftl_core.c

66 lines
1.4 KiB
C
Raw Normal View History

/* 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"
#include "ftl_debug.h"
#include "ftl_internal.h"
#include "mngt/ftl_mngt.h"
#include "utils/ftl_mempool.h"
static int
ftl_shutdown_complete(struct spdk_ftl_dev *dev)
{
if (dev->num_inflight) {
return 0;
}
return 1;
}
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;
}
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;
}
struct spdk_io_channel *
spdk_ftl_get_io_channel(struct spdk_ftl_dev *dev)
{
return spdk_get_io_channel(dev);
}
SPDK_LOG_REGISTER_COMPONENT(ftl_core)