From 97901dca7cdf1c69932be8f4c7c5a34ce1cf15cd Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Thu, 15 Oct 2020 00:40:42 +0900 Subject: [PATCH] examples/hello_blob: Use spdk_bdev_create_bs_dev_ext() to pass bdev_name Signed-off-by: Shuhei Matsumoto Change-Id: I932d46fc4c8e6d2de0e8f92c0c8a7965032ccb17 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4703 Tested-by: SPDK CI Jenkins Reviewed-by: Aleksey Marchuk Reviewed-by: Jim Harris --- examples/blob/hello_world/hello_blob.c | 33 +++++++++++++------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/examples/blob/hello_world/hello_blob.c b/examples/blob/hello_world/hello_blob.c index 41730ce86..a8071f14e 100644 --- a/examples/blob/hello_world/hello_blob.c +++ b/examples/blob/hello_world/hello_blob.c @@ -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; }