Commit e14cdc7d authored by Jim Harris's avatar Jim Harris
Browse files

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: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I67e591140194ff6ad250878168f6b166a1ff2282

Reviewed-on: https://review.gerrithub.io/400883


Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
parent c8efd8a8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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,
+2 −1
Original line number Diff line number Diff line
@@ -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 */

+3 −1
Original line number Diff line number Diff line
@@ -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);