From 1b667cf3c4447c40b44c00aa7e622869115b7800 Mon Sep 17 00:00:00 2001 From: Xiaodong Liu Date: Thu, 28 Feb 2019 20:16:30 +0800 Subject: [PATCH] bdev/raid: check whether supports FLUSH/RESET io_types like FLUSH and RESET are not always supported by base bdev modules. For example: virtio_blk bdev doesn't support FLUSH; ocf or ftl vbdev doesn't support RESET. Change-Id: I569ea75f8242c8bf082d7d89996ad1c7b1791570 Signed-off-by: Xiaodong Liu Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446493 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Jim Harris Reviewed-by: Changpeng Liu --- lib/bdev/raid/bdev_raid.c | 21 ++++++++++--------- test/unit/lib/bdev/bdev_raid.c/bdev_raid_ut.c | 5 +++-- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/bdev/raid/bdev_raid.c b/lib/bdev/raid/bdev_raid.c index 995ee73db..dadd48d4a 100644 --- a/lib/bdev/raid/bdev_raid.c +++ b/lib/bdev/raid/bdev_raid.c @@ -861,18 +861,19 @@ raid_bdev_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_i /* * brief: - * raid_bdev_io_type_unmap_supported is check whether unmap is supported in - * raid bdev module. If anyone among the base_bdevs doesn't support, the - * raid device doesn't supports. For the base_bdev which is not discovered, by default - * it is thought supported. + * _raid_bdev_io_type_supported checks whether io_type is supported in + * all base bdev modules of raid bdev module. If anyone among the base_bdevs + * doesn't support, the raid device doesn't supports. + * * params: * raid_bdev - pointer to raid bdev context + * io_type - io type * returns: * true - io_type is supported * false - io_type is not supported */ -static bool -raid_bdev_io_type_unmap_supported(struct raid_bdev *raid_bdev) +inline static bool +_raid_bdev_io_type_supported(struct raid_bdev *raid_bdev, enum spdk_bdev_io_type io_type) { uint16_t i; @@ -883,7 +884,7 @@ raid_bdev_io_type_unmap_supported(struct raid_bdev *raid_bdev) } if (spdk_bdev_io_type_supported(raid_bdev->base_bdev_info[i].bdev, - SPDK_BDEV_IO_TYPE_UNMAP) == false) { + io_type) == false) { return false; } } @@ -909,12 +910,12 @@ raid_bdev_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type) switch (io_type) { case SPDK_BDEV_IO_TYPE_READ: case SPDK_BDEV_IO_TYPE_WRITE: - case SPDK_BDEV_IO_TYPE_FLUSH: - case SPDK_BDEV_IO_TYPE_RESET: return true; + case SPDK_BDEV_IO_TYPE_FLUSH: + case SPDK_BDEV_IO_TYPE_RESET: case SPDK_BDEV_IO_TYPE_UNMAP: - return raid_bdev_io_type_unmap_supported(ctx); + return _raid_bdev_io_type_supported(ctx, io_type); default: return false; diff --git a/test/unit/lib/bdev/bdev_raid.c/bdev_raid_ut.c b/test/unit/lib/bdev/bdev_raid.c/bdev_raid_ut.c index f84394a23..2a6b1cb41 100644 --- a/test/unit/lib/bdev/bdev_raid.c/bdev_raid_ut.c +++ b/test/unit/lib/bdev/bdev_raid.c/bdev_raid_ut.c @@ -1849,6 +1849,7 @@ test_unmap_io(void) } CU_ASSERT(raid_bdev_io_type_supported(pbdev, SPDK_BDEV_IO_TYPE_UNMAP) == true); + CU_ASSERT(raid_bdev_io_type_supported(pbdev, SPDK_BDEV_IO_TYPE_FLUSH) == true); raid_bdev_io_generate(); for (count = 0; count < g_io_range_idx; count++) { @@ -2027,6 +2028,8 @@ test_reset_io(void) g_bdev_io_submit_status = 0; g_child_io_status_flag = true; + CU_ASSERT(raid_bdev_io_type_supported(pbdev, SPDK_BDEV_IO_TYPE_RESET) == true); + bdev_io = calloc(1, sizeof(struct spdk_bdev_io) + sizeof(struct raid_bdev_io)); SPDK_CU_ASSERT_FATAL(bdev_io != NULL); bdev_io_initialize(bdev_io, &pbdev->bdev, 0, 1, SPDK_BDEV_IO_TYPE_RESET); @@ -2404,8 +2407,6 @@ test_io_type_supported(void) { CU_ASSERT(raid_bdev_io_type_supported(NULL, SPDK_BDEV_IO_TYPE_READ) == true); CU_ASSERT(raid_bdev_io_type_supported(NULL, SPDK_BDEV_IO_TYPE_WRITE) == true); - CU_ASSERT(raid_bdev_io_type_supported(NULL, SPDK_BDEV_IO_TYPE_FLUSH) == true); - CU_ASSERT(raid_bdev_io_type_supported(NULL, SPDK_BDEV_IO_TYPE_RESET) == true); CU_ASSERT(raid_bdev_io_type_supported(NULL, SPDK_BDEV_IO_TYPE_INVALID) == false); }