examples/hello_blob: Use spdk_bdev_create_bs_dev_ext() to pass bdev_name

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I932d46fc4c8e6d2de0e8f92c0c8a7965032ccb17
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4703
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Shuhei Matsumoto 2020-10-15 00:40:42 +09:00 committed by Jim Harris
parent 2e0dafb305
commit 97901dca7c

View File

@ -39,6 +39,7 @@
#include "spdk/blob_bdev.h"
#include "spdk/blob.h"
#include "spdk/log.h"
#include "spdk/string.h"
/*
* We'll use this struct to gather housekeeping hello_context to pass between
@ -393,6 +394,13 @@ bs_init_complete(void *cb_arg, struct spdk_blob_store *bs,
create_blob(hello_context);
}
static void
base_bdev_event_cb(enum spdk_bdev_event_type type, struct spdk_bdev *bdev,
void *event_ctx)
{
SPDK_WARNLOG("Unsupported bdev event: type %d\n", type);
}
/*
* Our initial event that kicks off everything from main().
*/
@ -400,24 +408,16 @@ static void
hello_start(void *arg1)
{
struct hello_context_t *hello_context = arg1;
struct spdk_bdev *bdev = NULL;
struct spdk_bs_dev *bs_dev = NULL;
int rc;
SPDK_NOTICELOG("entry\n");
/*
* Get the bdev. For this example it is our malloc (RAM)
* disk configured via hello_blob.conf that was passed
* in when we started the SPDK app framework so we can
* get it via its name.
*/
bdev = spdk_bdev_get_by_name("Malloc0");
if (bdev == NULL) {
SPDK_ERRLOG("Could not find a bdev\n");
spdk_app_stop(-1);
return;
}
/*
* In this example, use our malloc (RAM) disk configured via
* hello_blob.conf that was passed in when we started the
* SPDK app framework.
*
* spdk_bs_init() requires us to fill out the structure
* spdk_bs_dev with a set of callbacks. These callbacks
* implement read, write, and other operations on the
@ -430,9 +430,10 @@ hello_start(void *arg1)
* However blobstore can be more tightly integrated into
* any lower layer, such as NVMe for example.
*/
bs_dev = spdk_bdev_create_bs_dev(bdev, NULL, NULL);
if (bs_dev == NULL) {
SPDK_ERRLOG("Could not create blob bdev!!\n");
rc = spdk_bdev_create_bs_dev_ext("Malloc0", base_bdev_event_cb, NULL, &bs_dev);
if (rc != 0) {
SPDK_ERRLOG("Could not create blob bdev, %s!!\n",
spdk_strerror(-rc));
spdk_app_stop(-1);
return;
}