blob: change spdk_blob_set_read_only to return int

This is needed for an upcoming change which will
prevent metadata functions from being called on
threads other than the metadata thread.  Without
this change, there was no way for this function
to return an error if it was called from the wrong
thread.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I67e591140194ff6ad250878168f6b166a1ff2282

Reviewed-on: https://review.gerrithub.io/400883
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
Jim Harris 2018-02-21 14:24:02 -07:00
parent c8efd8a8b2
commit e14cdc7d3a
3 changed files with 6 additions and 3 deletions

View File

@ -263,7 +263,7 @@ int spdk_blob_resize(struct spdk_blob *blob, size_t sz);
* These changes do not take effect until
* spdk_blob_sync_md() is called. */
void spdk_blob_set_read_only(struct spdk_blob *blob);
int spdk_blob_set_read_only(struct spdk_blob *blob);
/* Sync a blob */
/* Make a blob persistent. This applies to resize, set xattr,

View File

@ -3484,13 +3484,14 @@ void spdk_bs_open_blob(struct spdk_blob_store *bs, spdk_blob_id blobid,
/* END spdk_bs_open_blob */
/* START spdk_blob_set_read_only */
void spdk_blob_set_read_only(struct spdk_blob *blob)
int spdk_blob_set_read_only(struct spdk_blob *blob)
{
assert(spdk_get_thread() == blob->bs->md_thread);
blob->data_ro_flags |= SPDK_BLOB_READ_ONLY;
blob->state = SPDK_BLOB_STATE_DIRTY;
return 0;
}
/* END spdk_blob_set_read_only */

View File

@ -534,6 +534,7 @@ blob_read_only(void)
struct spdk_blob *blob;
struct spdk_bs_opts opts;
spdk_blob_id blobid;
int rc;
dev = init_dev();
spdk_bs_opts_init(&opts);
@ -554,7 +555,8 @@ blob_read_only(void)
SPDK_CU_ASSERT_FATAL(g_blob != NULL);
blob = g_blob;
spdk_blob_set_read_only(blob);
rc = spdk_blob_set_read_only(blob);
CU_ASSERT(rc == 0);
CU_ASSERT(blob->data_ro == false);
CU_ASSERT(blob->md_ro == false);