bdev/ftl: write_config_json support
Change-Id: Ifbd2b61ef38b216a8c7071f1206c0370dbe496e6 Signed-off-by: Wojciech Malikowski <wojciech.malikowski@intel.com> Reviewed-on: https://review.gerrithub.io/c/442980 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> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
This commit is contained in:
parent
8cda50fd96
commit
5f959d5f0c
@ -107,7 +107,6 @@ static pthread_mutex_t g_ftl_bdev_lock;
|
||||
|
||||
static int bdev_ftl_initialize(void);
|
||||
static void bdev_ftl_finish(void);
|
||||
static void bdev_ftl_get_spdk_running_config(FILE *fp);
|
||||
|
||||
static int
|
||||
bdev_ftl_get_ctx_size(void)
|
||||
@ -121,8 +120,6 @@ static struct spdk_bdev_module g_ftl_if = {
|
||||
.async_fini = true,
|
||||
.module_init = bdev_ftl_initialize,
|
||||
.module_fini = bdev_ftl_finish,
|
||||
/* TODO: Replace config_text with config_json */
|
||||
.config_text = bdev_ftl_get_spdk_running_config,
|
||||
.get_ctx_size = bdev_ftl_get_ctx_size,
|
||||
};
|
||||
|
||||
@ -401,7 +398,34 @@ bdev_ftl_get_io_channel(void *ctx)
|
||||
static void
|
||||
bdev_ftl_write_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx *w)
|
||||
{
|
||||
/* TODO: implement me! */
|
||||
struct ftl_bdev *ftl_bdev = bdev->ctxt;
|
||||
struct spdk_ftl_attrs attrs;
|
||||
const char *trtype_str;
|
||||
char uuid[SPDK_UUID_STRING_LEN];
|
||||
|
||||
spdk_ftl_dev_get_attrs(ftl_bdev->dev, &attrs);
|
||||
|
||||
spdk_json_write_object_begin(w);
|
||||
|
||||
spdk_json_write_named_string(w, "method", "construct_ftl_bdev");
|
||||
|
||||
spdk_json_write_named_object_begin(w, "params");
|
||||
spdk_json_write_named_string(w, "name", ftl_bdev->bdev.name);
|
||||
|
||||
trtype_str = spdk_nvme_transport_id_trtype_str(ftl_bdev->ctrlr->trid.trtype);
|
||||
if (trtype_str) {
|
||||
spdk_json_write_named_string(w, "trtype", trtype_str);
|
||||
}
|
||||
spdk_json_write_named_string(w, "traddr", ftl_bdev->ctrlr->trid.traddr);
|
||||
|
||||
spdk_json_write_named_string_fmt(w, "punits", "%d-%d", attrs.range.begin, attrs.range.end);
|
||||
|
||||
spdk_uuid_fmt_lower(uuid, sizeof(uuid), &attrs.uuid);
|
||||
spdk_json_write_named_string(w, "uuid", uuid);
|
||||
|
||||
spdk_json_write_object_end(w);
|
||||
|
||||
spdk_json_write_object_end(w);
|
||||
}
|
||||
|
||||
static const struct spdk_bdev_fn_table ftl_fn_table = {
|
||||
@ -909,10 +933,4 @@ bdev_ftl_finish(void)
|
||||
pthread_mutex_unlock(&g_ftl_bdev_lock);
|
||||
}
|
||||
|
||||
static void
|
||||
bdev_ftl_get_spdk_running_config(FILE *fp)
|
||||
{
|
||||
fprintf(fp, "\n[Ftl]\n");
|
||||
}
|
||||
|
||||
SPDK_LOG_REGISTER_COMPONENT("bdev_ftl", SPDK_LOG_BDEV_FTL)
|
||||
|
@ -18,6 +18,7 @@ restore_kill() {
|
||||
fi
|
||||
rm -rf $mount_dir
|
||||
rm -f $testdir/testfile.md5
|
||||
rm -f $testdir/config/ftl.json
|
||||
|
||||
$rpc_py delete_ftl_bdev -b nvme0
|
||||
killprocess $svcpid
|
||||
@ -33,7 +34,7 @@ waitforlisten $svcpid
|
||||
if [ -n "$uuid" ]; then
|
||||
$rpc_py construct_ftl_bdev -b nvme0 -a $device -l 0-3 -u $uuid
|
||||
else
|
||||
uuid=$($rpc_py construct_ftl_bdev -b nvme0 -a $device -l 0-3 | jq -r '.uuid')
|
||||
$rpc_py construct_ftl_bdev -b nvme0 -a $device -l 0-3
|
||||
fi
|
||||
|
||||
# Load the nbd driver
|
||||
@ -41,6 +42,8 @@ modprobe nbd
|
||||
$rpc_py start_nbd_disk nvme0 /dev/nbd0
|
||||
waitfornbd nbd0
|
||||
|
||||
$rpc_py save_config > $testdir/config/ftl.json
|
||||
|
||||
# Prepare the disk by creating ext4 fs and putting a file on it
|
||||
mkfs.ext4 -F /dev/nbd0
|
||||
mount /dev/nbd0 $mount_dir
|
||||
@ -56,9 +59,8 @@ killprocess $svcpid
|
||||
$rootdir/test/app/bdev_svc/bdev_svc --max-delay=0 & svcpid=$!
|
||||
# Wait until bdev_svc starts
|
||||
waitforlisten $svcpid
|
||||
$rpc_py construct_ftl_bdev -b nvme0 -a $device -l 0-3 -u $uuid
|
||||
|
||||
$rpc_py start_nbd_disk nvme0 /dev/nbd0
|
||||
$rpc_py load_config < $testdir/config/ftl.json
|
||||
|
||||
mount /dev/nbd0 $mount_dir
|
||||
md5sum -c $testdir/testfile.md5
|
||||
|
Loading…
Reference in New Issue
Block a user