ftl: vss null buffer workaround
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Kozlowski Mateusz <mateusz.kozlowski@intel.com> Change-Id: I94ea399ed30fae29f92b4216eaa9209c02b3478b Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13310 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
d67952540f
commit
884980d0aa
@ -64,6 +64,18 @@ struct spdk_ftl_attrs {
|
||||
typedef void (*spdk_ftl_fn)(void *cb_arg, int status);
|
||||
typedef void (*spdk_ftl_init_fn)(struct spdk_ftl_dev *dev, void *cb_arg, int status);
|
||||
|
||||
/**
|
||||
* Initializes the FTL library.
|
||||
*
|
||||
* @return 0 on success, negative errno otherwise.
|
||||
*/
|
||||
int spdk_ftl_init(void);
|
||||
|
||||
/**
|
||||
* Deinitializes the FTL library.
|
||||
*/
|
||||
void spdk_ftl_fini(void);
|
||||
|
||||
/**
|
||||
* Initialize the FTL on the given pair of bdevs - base and cache bdev.
|
||||
* Upon receiving a successful completion callback user is free to use I/O calls.
|
||||
|
@ -136,6 +136,35 @@ ftl_core_poller(void *ctx)
|
||||
return SPDK_POLLER_IDLE;
|
||||
}
|
||||
|
||||
void *g_ftl_write_buf;
|
||||
void *g_ftl_read_buf;
|
||||
|
||||
int
|
||||
spdk_ftl_init(void)
|
||||
{
|
||||
g_ftl_write_buf = spdk_zmalloc(FTL_ZERO_BUFFER_SIZE, FTL_ZERO_BUFFER_SIZE, NULL,
|
||||
SPDK_ENV_LCORE_ID_ANY, SPDK_MALLOC_DMA);
|
||||
if (!g_ftl_write_buf) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
g_ftl_read_buf = spdk_zmalloc(FTL_ZERO_BUFFER_SIZE, FTL_ZERO_BUFFER_SIZE, NULL,
|
||||
SPDK_ENV_LCORE_ID_ANY, SPDK_MALLOC_DMA);
|
||||
if (!g_ftl_read_buf) {
|
||||
spdk_free(g_ftl_write_buf);
|
||||
g_ftl_write_buf = NULL;
|
||||
return -ENOMEM;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
spdk_ftl_fini(void)
|
||||
{
|
||||
spdk_free(g_ftl_write_buf);
|
||||
spdk_free(g_ftl_read_buf);
|
||||
}
|
||||
|
||||
struct spdk_io_channel *
|
||||
spdk_ftl_get_io_channel(struct spdk_ftl_dev *dev)
|
||||
{
|
||||
|
@ -21,6 +21,13 @@
|
||||
#include "ftl_layout.h"
|
||||
#include "utils/ftl_log.h"
|
||||
|
||||
/* When using VSS on nvcache, FTL sometimes doesn't require the contents of metadata.
|
||||
* Some devices have bugs when sending a NULL pointer as part of metadata when namespace
|
||||
* is formatted with VSS. This buffer is passed to such calls to avoid the bug. */
|
||||
#define FTL_ZERO_BUFFER_SIZE 0x100000
|
||||
extern void *g_ftl_write_buf;
|
||||
extern void *g_ftl_read_buf;
|
||||
|
||||
struct spdk_ftl_dev {
|
||||
/* Configuration */
|
||||
struct spdk_ftl_conf conf;
|
||||
|
@ -43,7 +43,7 @@ ftl_nv_cache_bdev_read_blocks_with_md(struct spdk_ftl_dev *dev,
|
||||
uint64_t offset_blocks, uint64_t num_blocks,
|
||||
spdk_bdev_io_completion_cb cb, void *cb_arg)
|
||||
{
|
||||
return spdk_bdev_read_blocks_with_md(desc, ch, buf, md,
|
||||
return spdk_bdev_read_blocks_with_md(desc, ch, buf, md ? : g_ftl_read_buf,
|
||||
offset_blocks, num_blocks,
|
||||
cb, cb_arg);
|
||||
}
|
||||
@ -56,7 +56,7 @@ ftl_nv_cache_bdev_write_blocks_with_md(struct spdk_ftl_dev *dev,
|
||||
uint64_t offset_blocks, uint64_t num_blocks,
|
||||
spdk_bdev_io_completion_cb cb, void *cb_arg)
|
||||
{
|
||||
return spdk_bdev_write_blocks_with_md(desc, ch, buf, md,
|
||||
return spdk_bdev_write_blocks_with_md(desc, ch, buf, md ? : g_ftl_write_buf,
|
||||
offset_blocks, num_blocks,
|
||||
cb, cb_arg);
|
||||
}
|
||||
|
@ -228,6 +228,12 @@ ftl_mngt_open_cache_bdev(struct spdk_ftl_dev *dev, struct ftl_mngt_process *mngt
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (ftl_md_xfer_blocks(dev) * dev->cache_md_size > FTL_ZERO_BUFFER_SIZE) {
|
||||
FTL_ERRLOG(dev, "Zero buffer too small for bdev %s metadata transfer\n",
|
||||
spdk_bdev_get_name(bdev));
|
||||
goto error;
|
||||
}
|
||||
|
||||
ftl_mngt_next_step(mngt);
|
||||
return;
|
||||
error:
|
||||
|
@ -2,6 +2,8 @@
|
||||
global:
|
||||
|
||||
# public functions
|
||||
spdk_ftl_init;
|
||||
spdk_ftl_fini;
|
||||
spdk_ftl_dev_init;
|
||||
spdk_ftl_dev_free;
|
||||
spdk_ftl_get_default_conf;
|
||||
|
@ -36,6 +36,7 @@ struct ftl_deferred_init {
|
||||
static LIST_HEAD(, ftl_deferred_init) g_deferred_init = LIST_HEAD_INITIALIZER(g_deferred_init);
|
||||
|
||||
static int bdev_ftl_initialize(void);
|
||||
static void bdev_ftl_finish(void);
|
||||
static void bdev_ftl_examine(struct spdk_bdev *bdev);
|
||||
|
||||
static int
|
||||
@ -47,6 +48,7 @@ bdev_ftl_get_ctx_size(void)
|
||||
static struct spdk_bdev_module g_ftl_if = {
|
||||
.name = "ftl",
|
||||
.module_init = bdev_ftl_initialize,
|
||||
.module_fini = bdev_ftl_finish,
|
||||
.examine_disk = bdev_ftl_examine,
|
||||
.get_ctx_size = bdev_ftl_get_ctx_size,
|
||||
};
|
||||
@ -370,7 +372,7 @@ error:
|
||||
static int
|
||||
bdev_ftl_initialize(void)
|
||||
{
|
||||
return 0;
|
||||
return spdk_ftl_init();
|
||||
}
|
||||
|
||||
void
|
||||
@ -384,6 +386,12 @@ bdev_ftl_delete_bdev(const char *name, spdk_bdev_unregister_cb cb_fn, void *cb_a
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
bdev_ftl_finish(void)
|
||||
{
|
||||
spdk_ftl_fini();
|
||||
}
|
||||
|
||||
static void
|
||||
bdev_ftl_create_defered_cb(const struct ftl_bdev_info *info, void *ctx, int status)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user