Commit 1b667cf3 authored by Xiaodong Liu's avatar Xiaodong Liu Committed by Changpeng Liu
Browse files

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: default avatarXiaodong Liu <xiaodong.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446493


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent d7760821
Loading
Loading
Loading
Loading
+11 −10
Original line number Diff line number Diff line
@@ -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;
+3 −2
Original line number Diff line number Diff line
@@ -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);
}