diff --git a/.gitignore b/.gitignore index e71124b..b9b3150 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.o *.d *.so -func_test -zvfs_meta.txt \ No newline at end of file +zvfs/func_test +zvfs_meta.txt +zvfs/zvfs_meta.txt \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..601522f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "spdk"] + path = spdk + url = https://github.com/spdk/spdk.git + branch = v24.05 diff --git a/Makefile b/Makefile old mode 100755 new mode 100644 index c54e550..ed1a695 --- a/Makefile +++ b/Makefile @@ -1,37 +1,9 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright (C) 2017 Intel Corporation -# All rights reserved. -# +.PHONY: all clean zvfs -SPDK_ROOT_DIR := $(abspath $(CURDIR)/../spdk) -include $(SPDK_ROOT_DIR)/mk/spdk.common.mk -include $(SPDK_ROOT_DIR)/mk/spdk.modules.mk -include $(SPDK_ROOT_DIR)/mk/spdk.app_vars.mk +all: zvfs -LIBZVFS := libzvfs.so -APP := func_test - -C_SRCS := zvfs.c zvfs_hook.c - -SPDK_LIB_LIST = $(ALL_MODULES_LIST) event event_bdev - -LIBS += $(SPDK_LIB_LINKER_ARGS) -LDFLAGS += -shared -rdynamic -Wl,-z,nodelete -Wl,--disable-new-dtags \ - -Wl,-rpath,$(SPDK_ROOT_DIR)/build/lib \ - -Wl,-rpath,$(SPDK_ROOT_DIR)/dpdk/build/lib -SYS_LIBS += -ldl - -all: $(LIBZVFS) $(APP) - @: - rm -rf zvfs_meta.txt - -$(LIBZVFS): $(OBJS) $(SPDK_LIB_FILES) $(ENV_LIBS) - $(LINK_C) - -$(APP): func_test.c - $(CC) -o $@ $< +zvfs: + $(MAKE) -C zvfs clean: - $(CLEAN_C) $(LIBZVFS) $(APP) - -include $(SPDK_ROOT_DIR)/mk/spdk.deps.mk + $(MAKE) -C zvfs clean \ No newline at end of file diff --git a/README.md b/README.md index e7b00e0..36eed8c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ ## usage ```shell +git submodule update --init --recursive + cd /home/lian/share/10.1-spdk/spdk ./configure --with-shared make -j @@ -23,15 +25,15 @@ zvfs的测试结果: 1. iosize = 4K:95MiB/s 2. ioszie = 128K:1662MiB/s -相当于spdk读写的90%性能。 +相当于spdk测试工具读写的90%性能。 对比系统调用: 1. O_DIRECT - 1. 大块:43MiB/s - 2. 小块:724MiB/s + 1. 大块4K:43MiB/s + 2. 小块128K:724MiB/s 2. !O_DIRECT - 1. 大块:1460MiB/s - 2. 小块:1266MiB/s + 1. 大块4K:1460MiB/s + 2. 小块128K:1266MiB/s ### spdk_nvme_perf 性能基准测试 ```shell diff --git a/spdk b/spdk new file mode 160000 index 0000000..40a5c21 --- /dev/null +++ b/spdk @@ -0,0 +1 @@ +Subproject commit 40a5c2189767d8624461ce1066219124ea17471e diff --git a/zvfs/Makefile b/zvfs/Makefile new file mode 100755 index 0000000..5844fa3 --- /dev/null +++ b/zvfs/Makefile @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (C) 2017 Intel Corporation +# All rights reserved. +# + +SPDK_ROOT_DIR := $(abspath $(CURDIR)/../spdk) +include $(SPDK_ROOT_DIR)/mk/spdk.common.mk +include $(SPDK_ROOT_DIR)/mk/spdk.modules.mk +include $(SPDK_ROOT_DIR)/mk/spdk.app_vars.mk + +LIBZVFS := libzvfs.so +APP := func_test + +C_SRCS := zvfs.c zvfs_hook.c + +SPDK_LIB_LIST = $(ALL_MODULES_LIST) event event_bdev + +LIBS += $(SPDK_LIB_LINKER_ARGS) +LDFLAGS += -shared -rdynamic -Wl,-z,nodelete -Wl,--disable-new-dtags \ + -Wl,-rpath,$(SPDK_ROOT_DIR)/build/lib \ + -Wl,-rpath,$(SPDK_ROOT_DIR)/dpdk/build/lib +SYS_LIBS += -ldl + + +all: $(LIBZVFS) $(APP) + @: + +$(LIBZVFS): $(OBJS) $(SPDK_LIB_FILES) $(ENV_LIBS) + $(LINK_C) + +$(APP): func_test.c + $(CC) -o $@ $< + +clean: + $(CLEAN_C) $(LIBZVFS) $(APP) + +include $(SPDK_ROOT_DIR)/mk/spdk.deps.mk diff --git a/fio_script/bdev.fio b/zvfs/fio_script/bdev.fio similarity index 100% rename from fio_script/bdev.fio rename to zvfs/fio_script/bdev.fio diff --git a/fio_script/io_uring.fio b/zvfs/fio_script/io_uring.fio similarity index 100% rename from fio_script/io_uring.fio rename to zvfs/fio_script/io_uring.fio diff --git a/fio_script/kingfs b/zvfs/fio_script/kingfs similarity index 100% rename from fio_script/kingfs rename to zvfs/fio_script/kingfs diff --git a/fio_script/libaio.fio b/zvfs/fio_script/libaio.fio similarity index 100% rename from fio_script/libaio.fio rename to zvfs/fio_script/libaio.fio diff --git a/fio_script/nvme.fio b/zvfs/fio_script/nvme.fio similarity index 100% rename from fio_script/nvme.fio rename to zvfs/fio_script/nvme.fio diff --git a/fio_script/psync.fio b/zvfs/fio_script/psync.fio similarity index 100% rename from fio_script/psync.fio rename to zvfs/fio_script/psync.fio diff --git a/fio_script/zvfs.json b/zvfs/fio_script/zvfs.json similarity index 100% rename from fio_script/zvfs.json rename to zvfs/fio_script/zvfs.json diff --git a/func_test.c b/zvfs/func_test.c similarity index 99% rename from func_test.c rename to zvfs/func_test.c index c4f4443..fd27b30 100644 --- a/func_test.c +++ b/zvfs/func_test.c @@ -16,8 +16,8 @@ static double time_diff_sec(struct timespec a, struct timespec b) static int test_single_file_perf(const char *path) { - // size_t io_size = 128 * 1024; - size_t io_size = 4096; + size_t io_size = 128 * 1024; + // size_t io_size = 4096; size_t max_size = 2ULL * 1024 * 1024 * 1024; /* 最大 2GB,循环覆写 */ size_t max_count = max_size / io_size; int test_sec = 10; diff --git a/zvfs.c b/zvfs/zvfs.c similarity index 96% rename from zvfs.c rename to zvfs/zvfs.c index 6c67f59..b34c09b 100755 --- a/zvfs.c +++ b/zvfs/zvfs.c @@ -10,7 +10,7 @@ #endif struct spdk_thread *global_thread = NULL; -const char *json_file = "/home/lian/share/10.1-spdk/zvfs/zvfs.json"; +const char *json_file = "/home/lian/share/10.1-spdk/zvfs/zvfs/zvfs.json"; // mount void zvfs_do_mount(void *arg); @@ -599,7 +599,7 @@ int zvfs_env_setup(void) { return -1; } - spdk_log_set_print_level(SPDK_LOG_NOTICE); + spdk_log_set_print_level(SPDK_LOG_ERROR); spdk_log_set_level(SPDK_LOG_NOTICE); spdk_log_open(NULL); diff --git a/zvfs.h b/zvfs/zvfs.h similarity index 100% rename from zvfs.h rename to zvfs/zvfs.h diff --git a/zvfs.json b/zvfs/zvfs.json similarity index 100% rename from zvfs.json rename to zvfs/zvfs.json diff --git a/zvfs.old/Makefile b/zvfs/zvfs.old/Makefile similarity index 100% rename from zvfs.old/Makefile rename to zvfs/zvfs.old/Makefile diff --git a/zvfs.old/zvfs.c b/zvfs/zvfs.old/zvfs.c similarity index 100% rename from zvfs.old/zvfs.c rename to zvfs/zvfs.old/zvfs.c diff --git a/zvfs.old/zvfs.json b/zvfs/zvfs.old/zvfs.json similarity index 100% rename from zvfs.old/zvfs.json rename to zvfs/zvfs.old/zvfs.json diff --git a/zvfs.old/zvfs.old.c b/zvfs/zvfs.old/zvfs.old.c similarity index 100% rename from zvfs.old/zvfs.old.c rename to zvfs/zvfs.old/zvfs.old.c diff --git a/zvfs_hook.c b/zvfs/zvfs_hook.c similarity index 100% rename from zvfs_hook.c rename to zvfs/zvfs_hook.c