blobfs/mkfs: adopt func in module blobfs_bdev
Let test application "mkfs" adopt spdk_blobfs_bdev_create function in module blobfs_bdev directly. Change-Id: I7ba95df099d6e42a52b3399e5c8fdae1ccb2689d Signed-off-by: Xiaodong Liu <xiaodong.liu@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/469081 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com>
This commit is contained in:
parent
6433c1037d
commit
5583ee9d05
@ -42,6 +42,6 @@ C_SRCS := mkfs.c
|
||||
SPDK_LIB_LIST = $(ALL_MODULES_LIST)
|
||||
SPDK_LIB_LIST += event_bdev event_copy event_vmd
|
||||
SPDK_LIB_LIST += bdev copy event thread util conf trace \
|
||||
log jsonrpc json rpc sock notify
|
||||
log jsonrpc json rpc sock notify blobfs_bdev
|
||||
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk
|
||||
|
@ -33,68 +33,34 @@
|
||||
|
||||
#include "spdk/stdinc.h"
|
||||
|
||||
#include "spdk/blobfs.h"
|
||||
#include "spdk/bdev.h"
|
||||
#include "spdk/event.h"
|
||||
#include "spdk/blob_bdev.h"
|
||||
#include "spdk/blobfs.h"
|
||||
#include "spdk/blobfs_bdev.h"
|
||||
#include "spdk/log.h"
|
||||
#include "spdk/string.h"
|
||||
|
||||
struct spdk_bs_dev *g_bs_dev;
|
||||
const char *g_bdev_name;
|
||||
static uint64_t g_cluster_size;
|
||||
|
||||
static void
|
||||
stop_cb(void *ctx, int fserrno)
|
||||
shutdown_cb(void *cb_arg, int fserrno)
|
||||
{
|
||||
spdk_app_stop(0);
|
||||
}
|
||||
|
||||
static void
|
||||
shutdown_cb(void *arg1, void *arg2)
|
||||
{
|
||||
struct spdk_filesystem *fs = arg1;
|
||||
if (fserrno) {
|
||||
printf("\nFailed to initialize filesystem on bdev %s...", g_bdev_name);
|
||||
}
|
||||
|
||||
printf("done.\n");
|
||||
spdk_fs_unload(fs, stop_cb, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
init_cb(void *ctx, struct spdk_filesystem *fs, int fserrno)
|
||||
{
|
||||
struct spdk_event *event;
|
||||
|
||||
event = spdk_event_allocate(0, shutdown_cb, fs, NULL);
|
||||
spdk_event_call(event);
|
||||
spdk_app_stop(0);
|
||||
}
|
||||
|
||||
static void
|
||||
spdk_mkfs_run(void *arg1)
|
||||
{
|
||||
struct spdk_bdev *bdev;
|
||||
struct spdk_blobfs_opts blobfs_opt;
|
||||
|
||||
bdev = spdk_bdev_get_by_name(g_bdev_name);
|
||||
|
||||
if (bdev == NULL) {
|
||||
SPDK_ERRLOG("bdev %s not found\n", g_bdev_name);
|
||||
spdk_app_stop(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Initializing filesystem on bdev %s...", g_bdev_name);
|
||||
fflush(stdout);
|
||||
|
||||
spdk_fs_opts_init(&blobfs_opt);
|
||||
if (g_cluster_size) {
|
||||
blobfs_opt.cluster_sz = g_cluster_size;
|
||||
}
|
||||
g_bs_dev = spdk_bdev_create_bs_dev(bdev, NULL, NULL);
|
||||
if (blobfs_opt.cluster_sz) {
|
||||
spdk_fs_init(g_bs_dev, &blobfs_opt, NULL, init_cb, NULL);
|
||||
} else {
|
||||
spdk_fs_init(g_bs_dev, NULL, NULL, init_cb, NULL);
|
||||
}
|
||||
spdk_blobfs_bdev_create(g_bdev_name, g_cluster_size, shutdown_cb, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user