lib/ftl: Enable ANM events handling
Added ANM events processing by relocation module. Change-Id: I6d20b2dd66309fd7cf0fddb44b6027848b29446b Signed-off-by: Wojciech Malikowski <wojciech.malikowski@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/455253 Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Mateusz Kozlowski <mateusz.kozlowski@intel.com> Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
fdf3c5a30f
commit
e0bf5e3e4f
@ -38,6 +38,8 @@
|
|||||||
#include "spdk/ftl.h"
|
#include "spdk/ftl.h"
|
||||||
#include "ftl_anm.h"
|
#include "ftl_anm.h"
|
||||||
#include "ftl_core.h"
|
#include "ftl_core.h"
|
||||||
|
#include "ftl_band.h"
|
||||||
|
#include "ftl_debug.h"
|
||||||
|
|
||||||
/* Number of log pages read in single get_log_page call */
|
/* Number of log pages read in single get_log_page call */
|
||||||
#define FTL_ANM_LOG_ENTRIES 16
|
#define FTL_ANM_LOG_ENTRIES 16
|
||||||
@ -116,7 +118,8 @@ ftl_anm_log_range(struct spdk_ocssd_chunk_notification_entry *log)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct ftl_anm_event *
|
static struct ftl_anm_event *
|
||||||
ftl_anm_event_alloc(struct spdk_ftl_dev *dev, struct ftl_ppa ppa, enum ftl_anm_range range)
|
ftl_anm_event_alloc(struct spdk_ftl_dev *dev, struct ftl_ppa ppa,
|
||||||
|
enum ftl_anm_range range, size_t num_lbks)
|
||||||
{
|
{
|
||||||
struct ftl_anm_event *event;
|
struct ftl_anm_event *event;
|
||||||
|
|
||||||
@ -127,32 +130,78 @@ ftl_anm_event_alloc(struct spdk_ftl_dev *dev, struct ftl_ppa ppa, enum ftl_anm_r
|
|||||||
|
|
||||||
event->dev = dev;
|
event->dev = dev;
|
||||||
event->ppa = ppa;
|
event->ppa = ppa;
|
||||||
event->range = range;
|
|
||||||
|
switch (range) {
|
||||||
|
case FTL_ANM_RANGE_LBK:
|
||||||
|
event->num_lbks = num_lbks;
|
||||||
|
break;
|
||||||
|
case FTL_ANM_RANGE_CHK:
|
||||||
|
case FTL_ANM_RANGE_PU:
|
||||||
|
event->num_lbks = ftl_dev_lbks_in_chunk(dev);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ftl_anm_process_log(struct ftl_anm_poller *poller, struct ftl_anm_ctrlr *ctrlr,
|
ftl_anm_process_log(struct ftl_anm_poller *poller,
|
||||||
struct spdk_ocssd_chunk_notification_entry *log)
|
struct spdk_ocssd_chunk_notification_entry *log)
|
||||||
{
|
{
|
||||||
struct ftl_anm_event *event;
|
struct ftl_anm_event *event;
|
||||||
struct ftl_ppa ppa = ftl_ppa_addr_unpack(poller->dev, log->lba);
|
struct ftl_ppa ppa = ftl_ppa_addr_unpack(poller->dev, log->lba);
|
||||||
|
struct spdk_ftl_dev *dev = poller->dev;
|
||||||
|
enum ftl_anm_range range = ftl_anm_log_range(log);
|
||||||
|
int i, num_bands = 1;
|
||||||
|
|
||||||
/* TODO We need to parse log and decide if action is needed. */
|
num_bands = range != FTL_ANM_RANGE_PU ? 1 : ftl_dev_num_bands(dev);
|
||||||
/* For now we check only if ppa is in device range. */
|
|
||||||
if (!ftl_ppa_in_range(poller->dev, ppa)) {
|
for (i = 0; i < num_bands; ++i) {
|
||||||
return -1;
|
struct ftl_chunk *chk = ftl_band_chunk_from_ppa(&dev->bands[i], ppa);
|
||||||
|
|
||||||
|
if (chk->state == FTL_CHUNK_STATE_BAD) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
event = ftl_anm_event_alloc(dev, ppa, range, log->nlb);
|
||||||
|
if (!event) {
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
poller->fn(event);
|
||||||
|
ppa.chk++;
|
||||||
}
|
}
|
||||||
|
|
||||||
event = ftl_anm_event_alloc(poller->dev, ppa, ftl_anm_log_range(log));
|
|
||||||
poller->fn(event);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
ftl_anm_in_poller_range(struct ftl_anm_poller *poller,
|
||||||
|
struct spdk_ocssd_chunk_notification_entry *log)
|
||||||
|
{
|
||||||
|
struct spdk_ftl_dev *dev = poller->dev;
|
||||||
|
struct ftl_ppa ppa = ftl_ppa_addr_unpack(dev, log->lba);
|
||||||
|
char buf[128];
|
||||||
|
|
||||||
|
if (ppa.chk >= ftl_dev_num_bands(dev)) {
|
||||||
|
SPDK_ERRLOG("ANM log contains invalid @ppa: %s\n",
|
||||||
|
ftl_ppa2str(ppa, buf, sizeof(buf)));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ftl_ppa_in_range(dev, ppa)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ftl_anm_log_valid(struct ftl_anm_ctrlr *ctrlr, struct spdk_ocssd_chunk_notification_entry *log)
|
ftl_anm_log_valid(struct ftl_anm_ctrlr *ctrlr,
|
||||||
|
struct spdk_ocssd_chunk_notification_entry *log)
|
||||||
{
|
{
|
||||||
/* Initialize ctrlr->nc during the first log page read */
|
/* Initialize ctrlr->nc during the first log page read */
|
||||||
if (!ctrlr->nc && log->nc) {
|
if (!ctrlr->nc && log->nc) {
|
||||||
@ -187,9 +236,16 @@ ftl_anm_log_page_cb(void *ctx, const struct spdk_nvme_cpl *cpl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
LIST_FOREACH(poller, &ctrlr->pollers, list_entry) {
|
LIST_FOREACH(poller, &ctrlr->pollers, list_entry) {
|
||||||
if (!ftl_anm_process_log(poller, ctrlr, &ctrlr->log[i])) {
|
struct spdk_ocssd_chunk_notification_entry *log = &ctrlr->log[i];
|
||||||
break;
|
|
||||||
|
if (!ftl_anm_in_poller_range(poller, log)) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ftl_anm_process_log(poller, log)) {
|
||||||
|
SPDK_ERRLOG("Failed to process ANM log by dev: %p\n", poller->dev);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,8 +57,8 @@ struct ftl_anm_event {
|
|||||||
/* Start PPA */
|
/* Start PPA */
|
||||||
struct ftl_ppa ppa;
|
struct ftl_ppa ppa;
|
||||||
|
|
||||||
/* ANM range */
|
/* Number of logical blocks */
|
||||||
enum ftl_anm_range range;
|
size_t num_lbks;
|
||||||
};
|
};
|
||||||
|
|
||||||
int ftl_anm_init(struct spdk_thread *thread, spdk_ftl_fn cb, void *cb_arg);
|
int ftl_anm_init(struct spdk_thread *thread, spdk_ftl_fn cb, void *cb_arg);
|
||||||
|
@ -1904,13 +1904,18 @@ void
|
|||||||
ftl_process_anm_event(struct ftl_anm_event *event)
|
ftl_process_anm_event(struct ftl_anm_event *event)
|
||||||
{
|
{
|
||||||
struct spdk_ftl_dev *dev = event->dev;
|
struct spdk_ftl_dev *dev = event->dev;
|
||||||
|
struct ftl_band *band;
|
||||||
|
size_t lbkoff;
|
||||||
|
|
||||||
if (!ftl_check_core_thread(dev)) {
|
if (!ftl_check_core_thread(dev)) {
|
||||||
spdk_thread_send_msg(ftl_get_core_thread(dev), _ftl_process_anm_event, event);
|
spdk_thread_send_msg(ftl_get_core_thread(dev), _ftl_process_anm_event, event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_FTL_CORE, "Unconsumed ANM received for dev: %p...\n", event->dev);
|
band = ftl_band_from_ppa(dev, event->ppa);
|
||||||
|
lbkoff = ftl_band_lbkoff_from_ppa(band, event->ppa);
|
||||||
|
|
||||||
|
ftl_reloc_add(dev->reloc, band, lbkoff, event->num_lbks, 0);
|
||||||
ftl_anm_event_complete(event);
|
ftl_anm_event_complete(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user