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 <xiaodong.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446493
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
Xiaodong Liu 2019-02-28 20:16:30 +08:00 committed by Changpeng Liu
parent d77608212b
commit 1b667cf3c4
2 changed files with 14 additions and 12 deletions

View File

@ -861,18 +861,19 @@ raid_bdev_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_i
/* /*
* brief: * brief:
* raid_bdev_io_type_unmap_supported is check whether unmap is supported in * _raid_bdev_io_type_supported checks whether io_type is supported in
* raid bdev module. If anyone among the base_bdevs doesn't support, the * all base bdev modules of raid bdev module. If anyone among the base_bdevs
* raid device doesn't supports. For the base_bdev which is not discovered, by default * doesn't support, the raid device doesn't supports.
* it is thought supported. *
* params: * params:
* raid_bdev - pointer to raid bdev context * raid_bdev - pointer to raid bdev context
* io_type - io type
* returns: * returns:
* true - io_type is supported * true - io_type is supported
* false - io_type is not supported * false - io_type is not supported
*/ */
static bool inline static bool
raid_bdev_io_type_unmap_supported(struct raid_bdev *raid_bdev) _raid_bdev_io_type_supported(struct raid_bdev *raid_bdev, enum spdk_bdev_io_type io_type)
{ {
uint16_t i; 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, if (spdk_bdev_io_type_supported(raid_bdev->base_bdev_info[i].bdev,
SPDK_BDEV_IO_TYPE_UNMAP) == false) { io_type) == false) {
return false; return false;
} }
} }
@ -909,12 +910,12 @@ raid_bdev_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
switch (io_type) { switch (io_type) {
case SPDK_BDEV_IO_TYPE_READ: case SPDK_BDEV_IO_TYPE_READ:
case SPDK_BDEV_IO_TYPE_WRITE: case SPDK_BDEV_IO_TYPE_WRITE:
case SPDK_BDEV_IO_TYPE_FLUSH:
case SPDK_BDEV_IO_TYPE_RESET:
return true; return true;
case SPDK_BDEV_IO_TYPE_FLUSH:
case SPDK_BDEV_IO_TYPE_RESET:
case SPDK_BDEV_IO_TYPE_UNMAP: case SPDK_BDEV_IO_TYPE_UNMAP:
return raid_bdev_io_type_unmap_supported(ctx); return _raid_bdev_io_type_supported(ctx, io_type);
default: default:
return false; return false;

View File

@ -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_UNMAP) == true);
CU_ASSERT(raid_bdev_io_type_supported(pbdev, SPDK_BDEV_IO_TYPE_FLUSH) == true);
raid_bdev_io_generate(); raid_bdev_io_generate();
for (count = 0; count < g_io_range_idx; count++) { for (count = 0; count < g_io_range_idx; count++) {
@ -2027,6 +2028,8 @@ test_reset_io(void)
g_bdev_io_submit_status = 0; g_bdev_io_submit_status = 0;
g_child_io_status_flag = true; 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)); bdev_io = calloc(1, sizeof(struct spdk_bdev_io) + sizeof(struct raid_bdev_io));
SPDK_CU_ASSERT_FATAL(bdev_io != NULL); SPDK_CU_ASSERT_FATAL(bdev_io != NULL);
bdev_io_initialize(bdev_io, &pbdev->bdev, 0, 1, SPDK_BDEV_IO_TYPE_RESET); 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_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_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); CU_ASSERT(raid_bdev_io_type_supported(NULL, SPDK_BDEV_IO_TYPE_INVALID) == false);
} }