From 0d1c3aefc319da8658890e14848175b03dc3a217 Mon Sep 17 00:00:00 2001 From: Tomasz Kulasek Date: Thu, 22 Mar 2018 16:10:29 +0100 Subject: [PATCH] blobstore: clone-snapshot classification This patch introduces API to get some blobs capabilites: bool spdk_blob_is_read_only(struct spdk_blob *blob); bool spdk_blob_is_thin_provisioned(struct spdk_blob *blob); to be used in upper level in the unified way. Change-Id: I4411bb3f4dd0c64826ae16a66141b2911cbaab79 Signed-off-by: Tomasz Kulasek Reviewed-on: https://review.gerrithub.io/405022 Reviewed-by: Daniel Verkamp Tested-by: SPDK Automated Test System Reviewed-by: Ben Walker Reviewed-by: Tomasz Zawadzki --- include/spdk/blob.h | 18 ++++++++++++++++++ lib/blob/blobstore.c | 14 ++++++++++++++ lib/blob/blobstore.h | 2 -- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/include/spdk/blob.h b/include/spdk/blob.h index eb394a5e91..77dae7f4a6 100644 --- a/include/spdk/blob.h +++ b/include/spdk/blob.h @@ -390,6 +390,24 @@ void spdk_bs_create_clone(struct spdk_blob_store *bs, spdk_blob_id blobid, const struct spdk_blob_xattr_opts *clone_xattrs, spdk_blob_op_with_id_complete cb_fn, void *cb_arg); +/** + * Check if blob is read only. + * + * \param blob Blob. + * + * \return true if blob is read only. + */ +bool spdk_blob_is_read_only(struct spdk_blob *blob); + +/** + * Check if blob is thin-provisioned. + * + * \param blob Blob. + * + * \return true if blob is thin-provisioned. + */ +bool spdk_blob_is_thin_provisioned(struct spdk_blob *blob); + /** * Delete an existing blob from the given blobstore. * diff --git a/lib/blob/blobstore.c b/lib/blob/blobstore.c index e736da9bec..ad6a919588 100644 --- a/lib/blob/blobstore.c +++ b/lib/blob/blobstore.c @@ -4679,4 +4679,18 @@ spdk_bs_set_bstype(struct spdk_blob_store *bs, struct spdk_bs_type bstype) memcpy(&bs->bstype, &bstype, sizeof(bstype)); } +bool +spdk_blob_is_read_only(struct spdk_blob *blob) +{ + assert(blob != NULL); + return (blob->data_ro || blob->md_ro); +} + +bool +spdk_blob_is_thin_provisioned(struct spdk_blob *blob) +{ + assert(blob != NULL); + return !!(blob->invalid_flags & SPDK_BLOB_THIN_PROV); +} + SPDK_LOG_REGISTER_COMPONENT("blob", SPDK_LOG_BLOB) diff --git a/lib/blob/blobstore.h b/lib/blob/blobstore.h index 4b509a9303..ce8a11b087 100644 --- a/lib/blob/blobstore.h +++ b/lib/blob/blobstore.h @@ -259,8 +259,6 @@ struct spdk_blob_md_descriptor_extent { #define SPDK_BLOB_DATA_RO_FLAGS_MASK SPDK_BLOB_READ_ONLY #define SPDK_BLOB_MD_RO_FLAGS_MASK 0 -#define spdk_blob_is_thin_provisioned(blob) (blob->invalid_flags & SPDK_BLOB_THIN_PROV) - struct spdk_blob_md_descriptor_flags { uint8_t type; uint32_t length;