From 83a4b155caa3423c3dc34a63e9d8ce2bf74e43f1 Mon Sep 17 00:00:00 2001 From: Artur Paszkiewicz Date: Wed, 27 Apr 2022 11:18:05 +0200 Subject: [PATCH] module/raid: raid5: rename to raid5f Signed-off-by: Artur Paszkiewicz Change-Id: I4ccd54f995f0f413dadd700ba3f6ed82fe17e223 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12395 Reviewed-by: Shuhei Matsumoto Reviewed-by: Ben Walker Reviewed-by: Konrad Sztyber Tested-by: SPDK CI Jenkins Community-CI: Broadcom CI --- CHANGELOG.md | 6 ++ CONFIG | 4 +- configure | 12 +-- module/bdev/raid/Makefile | 4 +- module/bdev/raid/bdev_raid.c | 4 +- module/bdev/raid/bdev_raid.h | 2 +- module/bdev/raid/raid5.c | 86 ------------------- module/bdev/raid/raid5f.c | 86 +++++++++++++++++++ test/common/autotest_common.sh | 2 +- test/unit/lib/bdev/raid/Makefile | 2 +- .../bdev/raid/{raid5.c => raid5f.c}/Makefile | 2 +- .../raid5_ut.c => raid5f.c/raid5f_ut.c} | 50 +++++------ test/unit/unittest.sh | 4 +- 13 files changed, 135 insertions(+), 129 deletions(-) delete mode 100644 module/bdev/raid/raid5.c create mode 100644 module/bdev/raid/raid5f.c rename test/unit/lib/bdev/raid/{raid5.c => raid5f.c}/Makefile (89%) rename test/unit/lib/bdev/raid/{raid5.c/raid5_ut.c => raid5f.c/raid5f_ut.c} (77%) diff --git a/CHANGELOG.md b/CHANGELOG.md index f25c4ad02..73069b6a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,12 @@ New options `enable_ktls` and `tls_version` were added to the `sock_impl_set_opt Added warning message for `bdev_rbd_create`, if it is used without -c. `bdev_rbd_create()` API without specifying -c is deprecated and will be removed in future release. +### raid + +Renamed the `raid5` module to `raid5f` to reflect that it is not a traditional +RAID5 implementation - only full stripe writes are supported, partial stripe +writes (read-modify-write) are not. + ## v22.05 ### sock diff --git a/CONFIG b/CONFIG index 31bd87a91..a056f326b 100644 --- a/CONFIG +++ b/CONFIG @@ -166,8 +166,8 @@ CONFIG_OPENSSL_PATH= # Build with FUSE support CONFIG_FUSE=n -# Build with RAID5 support -CONFIG_RAID5=n +# Build with RAID5f support +CONFIG_RAID5F=n # Build with IDXD support # In this mode, SPDK fully controls the DSA device. diff --git a/configure b/configure index cf47baa87..6b7216f82 100755 --- a/configure +++ b/configure @@ -101,8 +101,8 @@ function usage() { echo " --without-fuse No path required." echo " --with-nvme-cuse Build NVMe driver with support for CUSE-based character devices." echo " --without-nvme-cuse No path required." - echo " --with-raid5 Build with bdev_raid module RAID5 support." - echo " --without-raid5 No path required." + echo " --with-raid5f Build with bdev_raid module RAID5f support." + echo " --without-raid5f No path required." echo " --with-wpdk=DIR Build using WPDK to provide support for Windows (experimental)." echo " --without-wpdk The argument must be a directory containing lib and include." echo " --with-usdt Build with userspace DTrace probes enabled." @@ -616,11 +616,11 @@ for i in "$@"; do --without-nvme-cuse) CONFIG[NVME_CUSE]=n ;; - --with-raid5) - CONFIG[RAID5]=y + --with-raid5f) + CONFIG[RAID5F]=y ;; - --without-raid5) - CONFIG[RAID5]=n + --without-raid5f) + CONFIG[RAID5F]=n ;; --with-idxd) CONFIG[IDXD]=y diff --git a/module/bdev/raid/Makefile b/module/bdev/raid/Makefile index 44dbf2259..e2c3941ca 100644 --- a/module/bdev/raid/Makefile +++ b/module/bdev/raid/Makefile @@ -12,8 +12,8 @@ SO_MINOR := 0 CFLAGS += -I$(SPDK_ROOT_DIR)/lib/bdev/ C_SRCS = bdev_raid.c bdev_raid_rpc.c raid0.c concat.c -ifeq ($(CONFIG_RAID5),y) -C_SRCS += raid5.c +ifeq ($(CONFIG_RAID5F),y) +C_SRCS += raid5f.c endif LIBNAME = bdev_raid diff --git a/module/bdev/raid/bdev_raid.c b/module/bdev/raid/bdev_raid.c index 0428001fa..e08ebfbd0 100644 --- a/module/bdev/raid/bdev_raid.c +++ b/module/bdev/raid/bdev_raid.c @@ -879,8 +879,8 @@ static struct { } g_raid_level_names[] = { { "raid0", RAID0 }, { "0", RAID0 }, - { "raid5", RAID5 }, - { "5", RAID5 }, + { "raid5f", RAID5F }, + { "5f", RAID5F }, { "concat", CONCAT }, { } }; diff --git a/module/bdev/raid/bdev_raid.h b/module/bdev/raid/bdev_raid.h index db1efdc51..5c253ab28 100644 --- a/module/bdev/raid/bdev_raid.h +++ b/module/bdev/raid/bdev_raid.h @@ -11,7 +11,7 @@ enum raid_level { INVALID_RAID_LEVEL = -1, RAID0 = 0, - RAID5 = 5, + RAID5F = 95, /* 0x5f */ CONCAT = 99, }; diff --git a/module/bdev/raid/raid5.c b/module/bdev/raid/raid5.c deleted file mode 100644 index ee105395c..000000000 --- a/module/bdev/raid/raid5.c +++ /dev/null @@ -1,86 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright (c) Intel Corporation. - * All rights reserved. - */ - -#include "bdev_raid.h" - -#include "spdk/env.h" -#include "spdk/thread.h" -#include "spdk/string.h" -#include "spdk/util.h" - -#include "spdk/log.h" - -struct raid5_info { - /* The parent raid bdev */ - struct raid_bdev *raid_bdev; - - /* Number of data blocks in a stripe (without parity) */ - uint64_t stripe_blocks; - - /* Number of stripes on this array */ - uint64_t total_stripes; -}; - -static inline uint8_t -raid5_stripe_data_chunks_num(const struct raid_bdev *raid_bdev) -{ - return raid_bdev->num_base_bdevs - raid_bdev->module->base_bdevs_max_degraded; -} - -static void -raid5_submit_rw_request(struct raid_bdev_io *raid_io) -{ - raid_bdev_io_complete(raid_io, SPDK_BDEV_IO_STATUS_FAILED); -} - -static int -raid5_start(struct raid_bdev *raid_bdev) -{ - uint64_t min_blockcnt = UINT64_MAX; - struct raid_base_bdev_info *base_info; - struct raid5_info *r5info; - - r5info = calloc(1, sizeof(*r5info)); - if (!r5info) { - SPDK_ERRLOG("Failed to allocate r5info\n"); - return -ENOMEM; - } - r5info->raid_bdev = raid_bdev; - - RAID_FOR_EACH_BASE_BDEV(raid_bdev, base_info) { - min_blockcnt = spdk_min(min_blockcnt, base_info->bdev->blockcnt); - } - - r5info->total_stripes = min_blockcnt / raid_bdev->strip_size; - r5info->stripe_blocks = raid_bdev->strip_size * raid5_stripe_data_chunks_num(raid_bdev); - - raid_bdev->bdev.blockcnt = r5info->stripe_blocks * r5info->total_stripes; - raid_bdev->bdev.optimal_io_boundary = r5info->stripe_blocks; - raid_bdev->bdev.split_on_optimal_io_boundary = true; - - raid_bdev->module_private = r5info; - - return 0; -} - -static void -raid5_stop(struct raid_bdev *raid_bdev) -{ - struct raid5_info *r5info = raid_bdev->module_private; - - free(r5info); -} - -static struct raid_bdev_module g_raid5_module = { - .level = RAID5, - .base_bdevs_min = 3, - .base_bdevs_max_degraded = 1, - .start = raid5_start, - .stop = raid5_stop, - .submit_rw_request = raid5_submit_rw_request, -}; -RAID_MODULE_REGISTER(&g_raid5_module) - -SPDK_LOG_REGISTER_COMPONENT(bdev_raid5) diff --git a/module/bdev/raid/raid5f.c b/module/bdev/raid/raid5f.c new file mode 100644 index 000000000..b94d40d25 --- /dev/null +++ b/module/bdev/raid/raid5f.c @@ -0,0 +1,86 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) Intel Corporation. + * All rights reserved. + */ + +#include "bdev_raid.h" + +#include "spdk/env.h" +#include "spdk/thread.h" +#include "spdk/string.h" +#include "spdk/util.h" + +#include "spdk/log.h" + +struct raid5f_info { + /* The parent raid bdev */ + struct raid_bdev *raid_bdev; + + /* Number of data blocks in a stripe (without parity) */ + uint64_t stripe_blocks; + + /* Number of stripes on this array */ + uint64_t total_stripes; +}; + +static inline uint8_t +raid5f_stripe_data_chunks_num(const struct raid_bdev *raid_bdev) +{ + return raid_bdev->num_base_bdevs - raid_bdev->module->base_bdevs_max_degraded; +} + +static void +raid5f_submit_rw_request(struct raid_bdev_io *raid_io) +{ + raid_bdev_io_complete(raid_io, SPDK_BDEV_IO_STATUS_FAILED); +} + +static int +raid5f_start(struct raid_bdev *raid_bdev) +{ + uint64_t min_blockcnt = UINT64_MAX; + struct raid_base_bdev_info *base_info; + struct raid5f_info *r5f_info; + + r5f_info = calloc(1, sizeof(*r5f_info)); + if (!r5f_info) { + SPDK_ERRLOG("Failed to allocate r5f_info\n"); + return -ENOMEM; + } + r5f_info->raid_bdev = raid_bdev; + + RAID_FOR_EACH_BASE_BDEV(raid_bdev, base_info) { + min_blockcnt = spdk_min(min_blockcnt, base_info->bdev->blockcnt); + } + + r5f_info->total_stripes = min_blockcnt / raid_bdev->strip_size; + r5f_info->stripe_blocks = raid_bdev->strip_size * raid5f_stripe_data_chunks_num(raid_bdev); + + raid_bdev->bdev.blockcnt = r5f_info->stripe_blocks * r5f_info->total_stripes; + raid_bdev->bdev.optimal_io_boundary = r5f_info->stripe_blocks; + raid_bdev->bdev.split_on_optimal_io_boundary = true; + + raid_bdev->module_private = r5f_info; + + return 0; +} + +static void +raid5f_stop(struct raid_bdev *raid_bdev) +{ + struct raid5f_info *r5f_info = raid_bdev->module_private; + + free(r5f_info); +} + +static struct raid_bdev_module g_raid5f_module = { + .level = RAID5F, + .base_bdevs_min = 3, + .base_bdevs_max_degraded = 1, + .start = raid5f_start, + .stop = raid5f_stop, + .submit_rw_request = raid5f_submit_rw_request, +}; +RAID_MODULE_REGISTER(&g_raid5f_module) + +SPDK_LOG_REGISTER_COMPONENT(bdev_raid5f) diff --git a/test/common/autotest_common.sh b/test/common/autotest_common.sh index 8c4c010c7..dc44249af 100755 --- a/test/common/autotest_common.sh +++ b/test/common/autotest_common.sh @@ -462,7 +462,7 @@ function get_config_params() { fi if [ $SPDK_TEST_RAID5 -eq 1 ]; then - config_params+=' --with-raid5' + config_params+=' --with-raid5f' fi if [ $SPDK_TEST_VFIOUSER -eq 1 ] || [ $SPDK_TEST_VFIOUSER_QEMU -eq 1 ]; then diff --git a/test/unit/lib/bdev/raid/Makefile b/test/unit/lib/bdev/raid/Makefile index ab4ed9864..8eb519607 100644 --- a/test/unit/lib/bdev/raid/Makefile +++ b/test/unit/lib/bdev/raid/Makefile @@ -8,7 +8,7 @@ include $(SPDK_ROOT_DIR)/mk/spdk.common.mk DIRS-y = bdev_raid.c concat.c -DIRS-$(CONFIG_RAID5) += raid5.c +DIRS-$(CONFIG_RAID5F) += raid5f.c .PHONY: all clean $(DIRS-y) diff --git a/test/unit/lib/bdev/raid/raid5.c/Makefile b/test/unit/lib/bdev/raid/raid5f.c/Makefile similarity index 89% rename from test/unit/lib/bdev/raid/raid5.c/Makefile rename to test/unit/lib/bdev/raid/raid5f.c/Makefile index f47c92afa..2d82c3176 100644 --- a/test/unit/lib/bdev/raid/raid5.c/Makefile +++ b/test/unit/lib/bdev/raid/raid5f.c/Makefile @@ -5,6 +5,6 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../../../../..) -TEST_FILE = raid5_ut.c +TEST_FILE = raid5f_ut.c include $(SPDK_ROOT_DIR)/mk/spdk.unittest.mk diff --git a/test/unit/lib/bdev/raid/raid5.c/raid5_ut.c b/test/unit/lib/bdev/raid/raid5f.c/raid5f_ut.c similarity index 77% rename from test/unit/lib/bdev/raid/raid5.c/raid5_ut.c rename to test/unit/lib/bdev/raid/raid5f.c/raid5f_ut.c index 0cb71174e..a0f736ff9 100644 --- a/test/unit/lib/bdev/raid/raid5.c/raid5_ut.c +++ b/test/unit/lib/bdev/raid/raid5f.c/raid5f_ut.c @@ -8,26 +8,26 @@ #include "spdk/env.h" #include "spdk_internal/mock.h" -#include "bdev/raid/raid5.c" +#include "bdev/raid/raid5f.c" DEFINE_STUB_V(raid_bdev_module_list_add, (struct raid_bdev_module *raid_module)); DEFINE_STUB_V(raid_bdev_io_complete, (struct raid_bdev_io *raid_io, enum spdk_bdev_io_status status)); -struct raid5_params { +struct raid5f_params { uint8_t num_base_bdevs; uint64_t base_bdev_blockcnt; uint32_t base_bdev_blocklen; uint32_t strip_size; }; -static struct raid5_params *g_params; +static struct raid5f_params *g_params; static size_t g_params_count; #define ARRAY_FOR_EACH(a, e) \ for (e = a; e < a + SPDK_COUNTOF(a); e++) -#define RAID5_PARAMS_FOR_EACH(p) \ +#define RAID5F_PARAMS_FOR_EACH(p) \ for (p = g_params; p < g_params + g_params_count; p++) static int @@ -41,7 +41,7 @@ test_setup(void) uint64_t *base_bdev_blockcnt; uint32_t *base_bdev_blocklen; uint32_t *strip_size_kb; - struct raid5_params *params; + struct raid5f_params *params; g_params_count = SPDK_COUNTOF(num_base_bdevs_values) * SPDK_COUNTOF(base_bdev_blockcnt_values) * @@ -84,7 +84,7 @@ test_cleanup(void) } static struct raid_bdev * -create_raid_bdev(struct raid5_params *params) +create_raid_bdev(struct raid5f_params *params) { struct raid_bdev *raid_bdev; struct raid_base_bdev_info *base_info; @@ -92,7 +92,7 @@ create_raid_bdev(struct raid5_params *params) raid_bdev = calloc(1, sizeof(*raid_bdev)); SPDK_CU_ASSERT_FATAL(raid_bdev != NULL); - raid_bdev->module = &g_raid5_module; + raid_bdev->module = &g_raid5f_module; raid_bdev->num_base_bdevs = params->num_base_bdevs; raid_bdev->base_bdev_info = calloc(raid_bdev->num_base_bdevs, sizeof(struct raid_base_bdev_info)); @@ -125,44 +125,44 @@ delete_raid_bdev(struct raid_bdev *raid_bdev) free(raid_bdev); } -static struct raid5_info * -create_raid5(struct raid5_params *params) +static struct raid5f_info * +create_raid5f(struct raid5f_params *params) { struct raid_bdev *raid_bdev = create_raid_bdev(params); - SPDK_CU_ASSERT_FATAL(raid5_start(raid_bdev) == 0); + SPDK_CU_ASSERT_FATAL(raid5f_start(raid_bdev) == 0); return raid_bdev->module_private; } static void -delete_raid5(struct raid5_info *r5info) +delete_raid5f(struct raid5f_info *r5f_info) { - struct raid_bdev *raid_bdev = r5info->raid_bdev; + struct raid_bdev *raid_bdev = r5f_info->raid_bdev; - raid5_stop(raid_bdev); + raid5f_stop(raid_bdev); delete_raid_bdev(raid_bdev); } static void -test_raid5_start(void) +test_raid5f_start(void) { - struct raid5_params *params; + struct raid5f_params *params; - RAID5_PARAMS_FOR_EACH(params) { - struct raid5_info *r5info; + RAID5F_PARAMS_FOR_EACH(params) { + struct raid5f_info *r5f_info; - r5info = create_raid5(params); + r5f_info = create_raid5f(params); - CU_ASSERT_EQUAL(r5info->stripe_blocks, params->strip_size * (params->num_base_bdevs - 1)); - CU_ASSERT_EQUAL(r5info->total_stripes, params->base_bdev_blockcnt / params->strip_size); - CU_ASSERT_EQUAL(r5info->raid_bdev->bdev.blockcnt, + CU_ASSERT_EQUAL(r5f_info->stripe_blocks, params->strip_size * (params->num_base_bdevs - 1)); + CU_ASSERT_EQUAL(r5f_info->total_stripes, params->base_bdev_blockcnt / params->strip_size); + CU_ASSERT_EQUAL(r5f_info->raid_bdev->bdev.blockcnt, (params->base_bdev_blockcnt - params->base_bdev_blockcnt % params->strip_size) * (params->num_base_bdevs - 1)); - CU_ASSERT_EQUAL(r5info->raid_bdev->bdev.optimal_io_boundary, r5info->stripe_blocks); + CU_ASSERT_EQUAL(r5f_info->raid_bdev->bdev.optimal_io_boundary, r5f_info->stripe_blocks); - delete_raid5(r5info); + delete_raid5f(r5f_info); } } @@ -175,8 +175,8 @@ main(int argc, char **argv) CU_set_error_action(CUEA_ABORT); CU_initialize_registry(); - suite = CU_add_suite("raid5", test_setup, test_cleanup); - CU_ADD_TEST(suite, test_raid5_start); + suite = CU_add_suite("raid5f", test_setup, test_cleanup); + CU_ADD_TEST(suite, test_raid5f_start); CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); diff --git a/test/unit/unittest.sh b/test/unit/unittest.sh index 5a928fbe7..3cc8214f9 100755 --- a/test/unit/unittest.sh +++ b/test/unit/unittest.sh @@ -204,8 +204,8 @@ if grep -q '#define SPDK_CONFIG_PMDK 1' $rootdir/include/spdk/config.h; then run_test "unittest_bdev_pmem" $valgrind $testdir/lib/bdev/pmem/bdev_pmem_ut fi -if grep -q '#define SPDK_CONFIG_RAID5 1' $rootdir/include/spdk/config.h; then - run_test "unittest_bdev_raid5" $valgrind $testdir/lib/bdev/raid/raid5.c/raid5_ut +if grep -q '#define SPDK_CONFIG_RAID5F 1' $rootdir/include/spdk/config.h; then + run_test "unittest_bdev_raid5f" $valgrind $testdir/lib/bdev/raid/raid5f.c/raid5f_ut fi run_test "unittest_blob_blobfs" unittest_blob