lvol: raport not supported io types on ro lvol

Change-Id: I07dac4bbf06a85659ae5d31e3f8d037d87825694
Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
Reviewed-on: https://review.gerrithub.io/408483
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Tomasz Kulasek 2018-04-20 14:24:00 +02:00 committed by Daniel Verkamp
parent 887ecc2d82
commit 7fb0f7467c
2 changed files with 42 additions and 3 deletions

View File

@ -687,12 +687,13 @@ vbdev_lvol_get_io_channel(void *ctx)
static bool
vbdev_lvol_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
{
struct spdk_lvol *lvol = ctx;
switch (io_type) {
case SPDK_BDEV_IO_TYPE_WRITE:
case SPDK_BDEV_IO_TYPE_UNMAP:
case SPDK_BDEV_IO_TYPE_WRITE_ZEROES:
/* TODO: Report false if snapshot */
return true;
return !spdk_blob_is_read_only(lvol->blob);
case SPDK_BDEV_IO_TYPE_RESET:
case SPDK_BDEV_IO_TYPE_READ:
return true;

View File

@ -177,6 +177,14 @@ spdk_blob_get_parent_snapshot(struct spdk_blob_store *bs, spdk_blob_id blobid)
return 0;
}
bool g_blob_is_read_only = false;
bool
spdk_blob_is_read_only(struct spdk_blob *blob)
{
return g_blob_is_read_only;
}
bool
spdk_blob_is_snapshot(struct spdk_blob *blob)
{
@ -1275,8 +1283,14 @@ ut_vbdev_lvol_get_io_channel(void)
static void
ut_vbdev_lvol_io_type_supported(void)
{
struct spdk_lvol *lvol = g_lvol;
struct spdk_lvol *lvol;
bool ret;
lvol = calloc(1, sizeof(struct spdk_lvol));
SPDK_CU_ASSERT_FATAL(lvol != NULL);
g_blob_is_read_only = false;
/* Supported types */
ret = vbdev_lvol_io_type_supported(lvol, SPDK_BDEV_IO_TYPE_READ);
CU_ASSERT(ret == true);
@ -1296,6 +1310,30 @@ ut_vbdev_lvol_io_type_supported(void)
CU_ASSERT(ret == false);
ret = vbdev_lvol_io_type_supported(lvol, SPDK_BDEV_IO_TYPE_NVME_IO);
CU_ASSERT(ret == false);
g_blob_is_read_only = true;
/* Supported types */
ret = vbdev_lvol_io_type_supported(lvol, SPDK_BDEV_IO_TYPE_READ);
CU_ASSERT(ret == true);
ret = vbdev_lvol_io_type_supported(lvol, SPDK_BDEV_IO_TYPE_RESET);
CU_ASSERT(ret == true);
/* Unsupported types */
ret = vbdev_lvol_io_type_supported(lvol, SPDK_BDEV_IO_TYPE_WRITE);
CU_ASSERT(ret == false);
ret = vbdev_lvol_io_type_supported(lvol, SPDK_BDEV_IO_TYPE_UNMAP);
CU_ASSERT(ret == false);
ret = vbdev_lvol_io_type_supported(lvol, SPDK_BDEV_IO_TYPE_WRITE_ZEROES);
CU_ASSERT(ret == false);
ret = vbdev_lvol_io_type_supported(lvol, SPDK_BDEV_IO_TYPE_FLUSH);
CU_ASSERT(ret == false);
ret = vbdev_lvol_io_type_supported(lvol, SPDK_BDEV_IO_TYPE_NVME_ADMIN);
CU_ASSERT(ret == false);
ret = vbdev_lvol_io_type_supported(lvol, SPDK_BDEV_IO_TYPE_NVME_IO);
CU_ASSERT(ret == false);
free(lvol);
}
static void