summaryrefslogtreecommitdiffstats
path: root/src/spdk/test/blobfs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/spdk/test/blobfs
parentInitial commit. (diff)
downloadceph-upstream/16.2.11+ds.tar.xz
ceph-upstream/16.2.11+ds.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/spdk/test/blobfs')
-rw-r--r--src/spdk/test/blobfs/Makefile45
-rwxr-xr-xsrc/spdk/test/blobfs/blobfs.sh141
-rw-r--r--src/spdk/test/blobfs/fuse/.gitignore1
-rw-r--r--src/spdk/test/blobfs/fuse/Makefile50
-rw-r--r--src/spdk/test/blobfs/fuse/fuse.c114
-rw-r--r--src/spdk/test/blobfs/mkfs/.gitignore1
-rw-r--r--src/spdk/test/blobfs/mkfs/Makefile52
-rw-r--r--src/spdk/test/blobfs/mkfs/mkfs.c115
-rw-r--r--src/spdk/test/blobfs/rocksdb/.gitignore1
-rw-r--r--src/spdk/test/blobfs/rocksdb/common_flags.txt27
-rwxr-xr-xsrc/spdk/test/blobfs/rocksdb/postprocess.py70
-rwxr-xr-xsrc/spdk/test/blobfs/rocksdb/rocksdb.sh155
-rw-r--r--src/spdk/test/blobfs/rocksdb/rocksdb_commit_id1
13 files changed, 773 insertions, 0 deletions
diff --git a/src/spdk/test/blobfs/Makefile b/src/spdk/test/blobfs/Makefile
new file mode 100644
index 000000000..d4275544b
--- /dev/null
+++ b/src/spdk/test/blobfs/Makefile
@@ -0,0 +1,45 @@
+#
+# BSD LICENSE
+#
+# Copyright (c) Intel Corporation.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Intel Corporation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
+include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
+
+DIRS-y = mkfs
+DIRS-$(CONFIG_FUSE) += fuse
+
+.PHONY: all clean $(DIRS-y)
+
+all: $(DIRS-y)
+clean: $(DIRS-y)
+
+include $(SPDK_ROOT_DIR)/mk/spdk.subdirs.mk
diff --git a/src/spdk/test/blobfs/blobfs.sh b/src/spdk/test/blobfs/blobfs.sh
new file mode 100755
index 000000000..29c4cc433
--- /dev/null
+++ b/src/spdk/test/blobfs/blobfs.sh
@@ -0,0 +1,141 @@
+#!/usr/bin/env bash
+
+SYSTEM=$(uname -s)
+if [ $SYSTEM = "FreeBSD" ]; then
+ echo "blobfs.sh cannot run on FreeBSD currently."
+ exit 0
+fi
+
+testdir=$(readlink -f $(dirname $0))
+rootdir=$(readlink -f $testdir/../..)
+source $rootdir/test/common/autotest_common.sh
+
+rpc_server=/var/tmp/spdk-blobfs.sock
+rpc_py="$rootdir/scripts/rpc.py -s $rpc_server"
+tmp_file=$SPDK_TEST_STORAGE/blobfs_file
+conf_file=/tmp/blobfs.conf
+bdevname=BlobfsBdev
+mount_dir=/tmp/spdk_tmp_mount
+test_cache_size=512
+
+function cleanup() {
+ if [[ -n $blobfs_pid && -e /proc/$blobfs_pid ]]; then
+ killprocess $blobfs_pid
+ fi
+
+ rm -rf $mount_dir
+ rm -f $tmp_file
+ rm -f $conf_file
+}
+
+function blobfs_start_app() {
+ $rootdir/test/app/bdev_svc/bdev_svc -r $rpc_server -c ${conf_file} &
+ blobfs_pid=$!
+
+ echo "Process blobfs pid: $blobfs_pid"
+ waitforlisten $blobfs_pid $rpc_server
+
+ result=$($rpc_py blobfs_set_cache_size ${test_cache_size})
+ if [ "${result}" != "True" ]; then
+ false
+ fi
+}
+
+function blobfs_detect_test() {
+ # Detect out there is no blobfs on test bdev
+ blobfs_start_app
+ result=$($rpc_py blobfs_detect ${bdevname})
+ if [ "${result}" != "False" ]; then
+ false
+ fi
+
+ killprocess $blobfs_pid
+
+ # Create blobfs on test bdev
+ $rootdir/test/blobfs/mkfs/mkfs ${conf_file} ${bdevname}
+
+ # Detect out there is a blobfs on test bdev
+ blobfs_start_app
+ result=$($rpc_py blobfs_detect ${bdevname})
+ if [ "${result}" != "True" ]; then
+ false
+ fi
+
+ killprocess $blobfs_pid
+}
+
+function blobfs_create_test() {
+ blobfs_start_app
+
+ # Create blobfs on test bdev
+ $rpc_py blobfs_create ${bdevname}
+
+ # Detect out there is a blobfs on test bdev
+ result=$($rpc_py blobfs_detect ${bdevname})
+ if [ "${result}" != "True" ]; then
+ false
+ fi
+
+ killprocess $blobfs_pid
+}
+
+function blobfs_fuse_test() {
+ if [ ! -d /usr/include/fuse3 ] && [ ! -d /usr/local/include/fuse3 ]; then
+ echo "libfuse3 is not installed which is required to this test."
+ return 0
+ fi
+
+ # mount blobfs on test dir
+ $rootdir/test/blobfs/fuse/fuse ${conf_file} ${bdevname} $mount_dir &
+ blobfs_pid=$!
+ echo "Process blobfs pid: $blobfs_pid"
+
+ # Currently blobfs fuse APP doesn't support specific path of RPC sock.
+ # So directly use default sock path.
+ waitforlisten $blobfs_pid /var/tmp/spdk.sock
+
+ # check mount status
+ mount | grep "$mount_dir"
+
+ # create a rand file in mount dir
+ dd if=/dev/urandom of=${mount_dir}/rand_file bs=4k count=32
+
+ umount ${mount_dir}
+ sleep 1
+ killprocess $blobfs_pid
+
+ # Verify there is no file in mount dir now
+ if [ -f ${mount_dir}/rand_file ]; then
+ false
+ fi
+
+ # use blobfs mount RPC
+ blobfs_start_app
+ $rpc_py blobfs_mount ${bdevname} $mount_dir
+
+ # read and delete the rand file
+ md5sum ${mount_dir}/rand_file
+ rm ${mount_dir}/rand_file
+
+ umount ${mount_dir}
+ sleep 1
+ killprocess $blobfs_pid
+}
+
+trap 'cleanup' EXIT
+
+# Create one temp file as test bdev
+dd if=/dev/zero of=${tmp_file} bs=4k count=1M
+echo "[AIO]" > ${conf_file}
+echo "AIO ${tmp_file} ${bdevname} 512" >> ${conf_file}
+
+blobfs_detect_test
+
+# Clear blobfs on temp file
+dd if=/dev/zero of=${tmp_file} bs=4k count=1M
+
+blobfs_create_test
+
+# Create dir for FUSE mount
+mkdir -p $mount_dir
+blobfs_fuse_test
diff --git a/src/spdk/test/blobfs/fuse/.gitignore b/src/spdk/test/blobfs/fuse/.gitignore
new file mode 100644
index 000000000..a517c488f
--- /dev/null
+++ b/src/spdk/test/blobfs/fuse/.gitignore
@@ -0,0 +1 @@
+fuse
diff --git a/src/spdk/test/blobfs/fuse/Makefile b/src/spdk/test/blobfs/fuse/Makefile
new file mode 100644
index 000000000..09d956e4f
--- /dev/null
+++ b/src/spdk/test/blobfs/fuse/Makefile
@@ -0,0 +1,50 @@
+#
+# BSD LICENSE
+#
+# Copyright (c) Intel Corporation.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Intel Corporation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../..)
+include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
+include $(SPDK_ROOT_DIR)/mk/spdk.modules.mk
+
+APP = fuse
+
+C_SRCS := fuse.c
+
+SPDK_LIB_LIST = $(ALL_MODULES_LIST)
+SPDK_LIB_LIST += $(EVENT_BDEV_SUBSYSTEM)
+SPDK_LIB_LIST += bdev accel event thread util conf trace \
+ log jsonrpc json rpc sock notify blobfs_bdev
+
+# libfuse3 is required internally by blobfs_bdev
+LIBS+= -L/usr/local/lib -lfuse3
+
+include $(SPDK_ROOT_DIR)/mk/spdk.app.mk
diff --git a/src/spdk/test/blobfs/fuse/fuse.c b/src/spdk/test/blobfs/fuse/fuse.c
new file mode 100644
index 000000000..e434fb505
--- /dev/null
+++ b/src/spdk/test/blobfs/fuse/fuse.c
@@ -0,0 +1,114 @@
+/*-
+ * BSD LICENSE
+ *
+ * Copyright (c) Intel Corporation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "spdk/stdinc.h"
+
+#define FUSE_USE_VERSION 30
+#include "fuse3/fuse.h"
+#include "fuse3/fuse_lowlevel.h"
+
+#include "spdk/blobfs.h"
+#include "spdk/bdev.h"
+#include "spdk/event.h"
+#include "spdk/thread.h"
+#include "spdk/blob_bdev.h"
+#include "spdk/blobfs_bdev.h"
+#include "spdk/log.h"
+#include "spdk/string.h"
+
+char *g_bdev_name;
+char *g_mountpoint;
+
+int g_fuse_argc = 0;
+char **g_fuse_argv = NULL;
+
+static void
+fuse_run_cb(void *cb_arg, int fserrno)
+{
+ if (fserrno) {
+ printf("Failed to mount filesystem on bdev %s to path %s: %s",
+ g_bdev_name, g_mountpoint, spdk_strerror(fserrno));
+
+ spdk_app_stop(0);
+ return;
+ }
+
+ printf("done.\n");
+}
+
+static void
+spdk_fuse_run(void *arg1)
+{
+ printf("Mounting filesystem on bdev %s to path %s...",
+ g_bdev_name, g_mountpoint);
+ fflush(stdout);
+
+ spdk_blobfs_bdev_mount(g_bdev_name, g_mountpoint, fuse_run_cb, NULL);
+}
+
+static void
+spdk_fuse_shutdown(void)
+{
+ spdk_app_stop(0);
+}
+
+int main(int argc, char **argv)
+{
+ struct spdk_app_opts opts = {};
+ int rc = 0;
+
+ if (argc < 4) {
+ fprintf(stderr, "usage: %s <conffile> <bdev name> <mountpoint>\n", argv[0]);
+ exit(1);
+ }
+
+ spdk_app_opts_init(&opts);
+ opts.name = "spdk_fuse";
+ opts.config_file = argv[1];
+ opts.reactor_mask = "0x3";
+ opts.shutdown_cb = spdk_fuse_shutdown;
+
+ g_bdev_name = argv[2];
+ g_mountpoint = argv[3];
+
+ /* TODO: mount blobfs with extra FUSE options. */
+ g_fuse_argc = argc - 2;
+ g_fuse_argv = &argv[2];
+
+ spdk_fs_set_cache_size(512);
+
+ rc = spdk_app_start(&opts, spdk_fuse_run, NULL);
+ spdk_app_fini();
+
+ return rc;
+}
diff --git a/src/spdk/test/blobfs/mkfs/.gitignore b/src/spdk/test/blobfs/mkfs/.gitignore
new file mode 100644
index 000000000..54e292c61
--- /dev/null
+++ b/src/spdk/test/blobfs/mkfs/.gitignore
@@ -0,0 +1 @@
+mkfs
diff --git a/src/spdk/test/blobfs/mkfs/Makefile b/src/spdk/test/blobfs/mkfs/Makefile
new file mode 100644
index 000000000..42eebd9f1
--- /dev/null
+++ b/src/spdk/test/blobfs/mkfs/Makefile
@@ -0,0 +1,52 @@
+#
+# BSD LICENSE
+#
+# Copyright (c) Intel Corporation.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Intel Corporation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../..)
+include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
+include $(SPDK_ROOT_DIR)/mk/spdk.modules.mk
+
+APP = mkfs
+
+C_SRCS := mkfs.c
+
+SPDK_LIB_LIST = $(ALL_MODULES_LIST)
+SPDK_LIB_LIST += $(EVENT_BDEV_SUBSYSTEM)
+SPDK_LIB_LIST += bdev accel event thread util conf trace \
+ log jsonrpc json rpc sock notify blobfs_bdev
+
+# libfuse3 is required internally by blobfs_bdev
+ifeq ($(CONFIG_FUSE),y)
+LIBS+= -L/usr/local/lib -lfuse3
+endif
+
+include $(SPDK_ROOT_DIR)/mk/spdk.app.mk
diff --git a/src/spdk/test/blobfs/mkfs/mkfs.c b/src/spdk/test/blobfs/mkfs/mkfs.c
new file mode 100644
index 000000000..4d70a5e16
--- /dev/null
+++ b/src/spdk/test/blobfs/mkfs/mkfs.c
@@ -0,0 +1,115 @@
+/*-
+ * BSD LICENSE
+ *
+ * Copyright (c) Intel Corporation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "spdk/stdinc.h"
+
+#include "spdk/event.h"
+#include "spdk/blobfs.h"
+#include "spdk/blobfs_bdev.h"
+#include "spdk/log.h"
+#include "spdk/string.h"
+
+const char *g_bdev_name;
+static uint64_t g_cluster_size;
+
+static void
+shutdown_cb(void *cb_arg, int fserrno)
+{
+ if (fserrno) {
+ printf("\nFailed to initialize filesystem on bdev %s...", g_bdev_name);
+ }
+
+ printf("done.\n");
+
+ spdk_app_stop(0);
+}
+
+static void
+spdk_mkfs_run(void *arg1)
+{
+ printf("Initializing filesystem on bdev %s...", g_bdev_name);
+ fflush(stdout);
+
+ spdk_blobfs_bdev_create(g_bdev_name, g_cluster_size, shutdown_cb, NULL);
+}
+
+static void
+mkfs_usage(void)
+{
+ printf(" -C <size> cluster size\n");
+}
+
+static int
+mkfs_parse_arg(int ch, char *arg)
+{
+ bool has_prefix;
+
+ switch (ch) {
+ case 'C':
+ spdk_parse_capacity(arg, &g_cluster_size, &has_prefix);
+ break;
+ default:
+ return -EINVAL;
+ }
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ struct spdk_app_opts opts = {};
+ int rc = 0;
+
+ if (argc < 3) {
+ SPDK_ERRLOG("usage: %s <conffile> <bdevname>\n", argv[0]);
+ exit(1);
+ }
+
+ spdk_app_opts_init(&opts);
+ opts.name = "spdk_mkfs";
+ opts.config_file = argv[1];
+ opts.reactor_mask = "0x3";
+ opts.shutdown_cb = NULL;
+
+ spdk_fs_set_cache_size(512);
+ g_bdev_name = argv[2];
+ if ((rc = spdk_app_parse_args(argc, argv, &opts, "C:", NULL,
+ mkfs_parse_arg, mkfs_usage)) !=
+ SPDK_APP_PARSE_ARGS_SUCCESS) {
+ exit(rc);
+ }
+
+ rc = spdk_app_start(&opts, spdk_mkfs_run, NULL);
+ spdk_app_fini();
+
+ return rc;
+}
diff --git a/src/spdk/test/blobfs/rocksdb/.gitignore b/src/spdk/test/blobfs/rocksdb/.gitignore
new file mode 100644
index 000000000..1a06816d8
--- /dev/null
+++ b/src/spdk/test/blobfs/rocksdb/.gitignore
@@ -0,0 +1 @@
+results
diff --git a/src/spdk/test/blobfs/rocksdb/common_flags.txt b/src/spdk/test/blobfs/rocksdb/common_flags.txt
new file mode 100644
index 000000000..6390c7a40
--- /dev/null
+++ b/src/spdk/test/blobfs/rocksdb/common_flags.txt
@@ -0,0 +1,27 @@
+--disable_seek_compaction=1
+--mmap_read=0
+--statistics=1
+--histogram=1
+--key_size=16
+--value_size=1000
+--block_size=4096
+--cache_size=0
+--bloom_bits=10
+--cache_numshardbits=4
+--open_files=500000
+--verify_checksum=1
+--db=/mnt/rocksdb
+--sync=0
+--compression_type=none
+--stats_interval=1000000
+--compression_ratio=1
+--disable_data_sync=0
+--target_file_size_base=67108864
+--max_write_buffer_number=3
+--max_bytes_for_level_multiplier=10
+--max_background_compactions=10
+--num_levels=10
+--delete_obsolete_files_period_micros=3000000
+--max_grandparent_overlap_factor=10
+--stats_per_interval=1
+--max_bytes_for_level_base=10485760
diff --git a/src/spdk/test/blobfs/rocksdb/postprocess.py b/src/spdk/test/blobfs/rocksdb/postprocess.py
new file mode 100755
index 000000000..1ba8a7302
--- /dev/null
+++ b/src/spdk/test/blobfs/rocksdb/postprocess.py
@@ -0,0 +1,70 @@
+#!/usr/bin/env python3
+from collections import namedtuple
+from itertools import islice
+import operator
+import sys
+
+total_samples = 0
+thread_module_samples = {}
+function_module_samples = {}
+module_samples = {}
+threads = set()
+
+ThreadModule = namedtuple('ThreadModule', ['thread', 'module'])
+FunctionModule = namedtuple('FunctionModule', ['function', 'module'])
+
+with open(sys.argv[1] + "/" + sys.argv[2] + ".perf.txt") as f:
+ for line in f:
+ fields = line.split()
+ total_samples += int(fields[1])
+ key = ThreadModule(fields[2], fields[3])
+ thread_module_samples.setdefault(key, 0)
+ thread_module_samples[key] += int(fields[1])
+ key = FunctionModule(fields[5], fields[3])
+ function_module_samples.setdefault(key, 0)
+ function_module_samples[key] += int(fields[1])
+ threads.add(fields[2])
+
+ key = fields[3]
+ module_samples.setdefault(key, 0)
+ module_samples[key] += int(fields[1])
+
+for thread in sorted(threads):
+ thread_pct = 0
+ print("")
+ print("Thread: {:s}".format(thread))
+ print(" Percent Module")
+ print("============================")
+ for key, value in sorted(list(thread_module_samples.items()), key=operator.itemgetter(1), reverse=True):
+ if key.thread == thread:
+ print("{:8.4f} {:20s}".format(float(value) * 100 / total_samples, key.module))
+ thread_pct += float(value) * 100 / total_samples
+ print("============================")
+ print("{:8.4f} Total".format(thread_pct))
+
+print("")
+print(" Percent Module Function")
+print("=================================================================")
+for key, value in islice(sorted(list(function_module_samples.items()), key=operator.itemgetter(1), reverse=True), 100):
+ print(("{:8.4f} {:20s} {:s}".format(float(value) * 100 / total_samples, key.module, key.function)))
+
+print("")
+print("")
+print(" Percent Module")
+print("=================================")
+for key, value in sorted(list(module_samples.items()), key=operator.itemgetter(1), reverse=True):
+ print("{:8.4f} {:s}".format(float(value) * 100 / total_samples, key))
+
+print("")
+with open(sys.argv[1] + "/" + sys.argv[2] + "_db_bench.txt") as f:
+ for line in f:
+ if "maxresident" in line:
+ fields = line.split()
+ print("Wall time elapsed: {:s}".format(fields[2].split("e")[0]))
+ print("CPU utilization: {:s}".format(fields[3].split('C')[0]))
+ user = float(fields[0].split('u')[0])
+ system = float(fields[1].split('s')[0])
+ print("User: {:8.2f} ({:5.2f}%)".format(user, user * 100 / (user + system)))
+ print("System: {:8.2f} ({:5.2f}%)".format(system, system * 100 / (user + system)))
+
+print("")
diff --git a/src/spdk/test/blobfs/rocksdb/rocksdb.sh b/src/spdk/test/blobfs/rocksdb/rocksdb.sh
new file mode 100755
index 000000000..406156905
--- /dev/null
+++ b/src/spdk/test/blobfs/rocksdb/rocksdb.sh
@@ -0,0 +1,155 @@
+#!/usr/bin/env bash
+
+testdir=$(readlink -f $(dirname $0))
+rootdir=$(readlink -f $testdir/../../..)
+source $rootdir/test/common/autotest_common.sh
+
+dump_db_bench_on_err() {
+ # Fetch std dump of the last run_step that might have failed
+ [[ -e $db_bench ]] || return 0
+
+ # Dump entire *.txt to stderr to clearly see what might have failed
+ xtrace_disable
+ mapfile -t step_map < "$db_bench"
+ printf '%s\n' "${step_map[@]/#/* $step (FAILED)}" >&2
+ xtrace_restore
+}
+
+run_step() {
+ if [ -z "$1" ]; then
+ echo run_step called with no parameter
+ exit 1
+ fi
+
+ cat <<- EOL >> "$1"_flags.txt
+ --spdk=$ROCKSDB_CONF
+ --spdk_bdev=Nvme0n1
+ --spdk_cache_size=$CACHE_SIZE
+ EOL
+
+ db_bench=$1_db_bench.txt
+ echo -n Start $1 test phase...
+ time taskset 0xFF $DB_BENCH --flagfile="$1"_flags.txt &> "$db_bench"
+ DB_BENCH_FILE=$(grep -o '/dev/shm/\(\w\|\.\|\d\|/\)*' "$db_bench")
+ gzip $DB_BENCH_FILE
+ mv $DB_BENCH_FILE.gz "$1"_trace.gz
+ chmod 644 "$1"_trace.gz
+ echo done.
+}
+
+run_bsdump() {
+ $SPDK_EXAMPLE_DIR/blobcli -c $ROCKSDB_CONF -b Nvme0n1 -D &> bsdump.txt
+}
+
+# In the autotest job, we copy the rocksdb source to just outside the spdk directory.
+DB_BENCH_DIR="$rootdir/../rocksdb"
+DB_BENCH=$DB_BENCH_DIR/db_bench
+ROCKSDB_CONF=$testdir/rocksdb.conf
+
+if [ ! -e $DB_BENCH_DIR ]; then
+ echo $DB_BENCH_DIR does not exist
+ false
+fi
+
+timing_enter db_bench_build
+
+pushd $DB_BENCH_DIR
+if [ -z "$SKIP_GIT_CLEAN" ]; then
+ git clean -x -f -d
+fi
+
+EXTRA_CXXFLAGS=""
+GCC_VERSION=$(cc -dumpversion | cut -d. -f1)
+if ((GCC_VERSION >= 9)); then
+ EXTRA_CXXFLAGS+="-Wno-deprecated-copy -Wno-pessimizing-move -Wno-error=stringop-truncation"
+fi
+
+$MAKE db_bench $MAKEFLAGS $MAKECONFIG DEBUG_LEVEL=0 SPDK_DIR=$rootdir EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS"
+popd
+
+timing_exit db_bench_build
+
+$rootdir/scripts/gen_nvme.sh > $ROCKSDB_CONF
+# 0x80 is the bit mask for BlobFS tracepoints
+echo "[Global]" >> $ROCKSDB_CONF
+echo "TpointGroupMask 0x80" >> $ROCKSDB_CONF
+
+trap 'dump_db_bench_on_err; run_bsdump || :; rm -f $ROCKSDB_CONF; exit 1' SIGINT SIGTERM EXIT
+
+if [ -z "$SKIP_MKFS" ]; then
+ run_test "blobfs_mkfs" $rootdir/test/blobfs/mkfs/mkfs $ROCKSDB_CONF Nvme0n1
+fi
+
+mkdir -p $output_dir/rocksdb
+RESULTS_DIR=$output_dir/rocksdb
+if [ $RUN_NIGHTLY -eq 1 ]; then
+ CACHE_SIZE=4096
+ DURATION=60
+ NUM_KEYS=100000000
+else
+ CACHE_SIZE=2048
+ DURATION=20
+ NUM_KEYS=20000000
+fi
+
+cd $RESULTS_DIR
+cp $testdir/common_flags.txt insert_flags.txt
+cat << EOL >> insert_flags.txt
+--benchmarks=fillseq
+--threads=1
+--disable_wal=1
+--use_existing_db=0
+--num=$NUM_KEYS
+EOL
+
+cp $testdir/common_flags.txt randread_flags.txt
+cat << EOL >> randread_flags.txt
+--benchmarks=readrandom
+--threads=16
+--duration=$DURATION
+--disable_wal=1
+--use_existing_db=1
+--num=$NUM_KEYS
+EOL
+
+cp $testdir/common_flags.txt overwrite_flags.txt
+cat << EOL >> overwrite_flags.txt
+--benchmarks=overwrite
+--threads=1
+--duration=$DURATION
+--disable_wal=1
+--use_existing_db=1
+--num=$NUM_KEYS
+EOL
+
+cp $testdir/common_flags.txt readwrite_flags.txt
+cat << EOL >> readwrite_flags.txt
+--benchmarks=readwhilewriting
+--threads=4
+--duration=$DURATION
+--disable_wal=1
+--use_existing_db=1
+--num=$NUM_KEYS
+EOL
+
+cp $testdir/common_flags.txt writesync_flags.txt
+cat << EOL >> writesync_flags.txt
+--benchmarks=overwrite
+--threads=1
+--duration=$DURATION
+--disable_wal=0
+--use_existing_db=1
+--sync=1
+--num=$NUM_KEYS
+EOL
+
+run_test "rocksdb_insert" run_step insert
+run_test "rocksdb_overwrite" run_step overwrite
+run_test "rocksdb_readwrite" run_step readwrite
+run_test "rocksdb_writesync" run_step writesync
+run_test "rocksdb_randread" run_step randread
+
+trap - SIGINT SIGTERM EXIT
+
+run_bsdump
+rm -f $ROCKSDB_CONF
diff --git a/src/spdk/test/blobfs/rocksdb/rocksdb_commit_id b/src/spdk/test/blobfs/rocksdb/rocksdb_commit_id
new file mode 100644
index 000000000..efac5a55d
--- /dev/null
+++ b/src/spdk/test/blobfs/rocksdb/rocksdb_commit_id
@@ -0,0 +1 @@
+526c73bd94150cc8fbd651f736e1ca95f50d8e13