blob: add asserts for md operations on md thread
The md (metadata) thread is always the thread that initialize/loaded the blobstore. Metadata operations may only be performed from this thread. This patch adds some more asserts in metadata functions that were previously missed. While here, also update some of the blobstore documentation related to this. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: I5cafdb3ba402ceb6c3ccb6fdd9d36e7768f59f39 Reviewed-on: https://review.gerrithub.io/400885 Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Maciej Szwed <maciej.szwed@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
05db56d7d8
commit
0928d63d20
@ -42,17 +42,15 @@
|
||||
*
|
||||
* The blobstore is designed to be very high performance, and thus has
|
||||
* a few general rules regarding thread safety to avoid taking locks
|
||||
* in the I/O path. Functions starting with the prefix "spdk_bs_md" must only
|
||||
* be called from the metadata thread, of which there is only one at a time.
|
||||
* The metadata thread is the thread which called spdk_bs_init() or
|
||||
* spdk_bs_load().
|
||||
* in the I/O path. This is primarily done by only allowing most
|
||||
* functions to be called on the metadata thread. The metadata thread is
|
||||
* the thread which called spdk_bs_init() or spdk_bs_load().
|
||||
*
|
||||
* Functions starting with the prefix "spdk_blob_io" are passed a channel
|
||||
* as an argument, and channels may only be used from the thread they were
|
||||
* created on. See \ref spdk_bs_alloc_io_channel.
|
||||
*
|
||||
* Functions not starting with one of those two prefixes are thread safe
|
||||
* and may be called from any thread at any time.
|
||||
* created on. See \ref spdk_bs_alloc_io_channel. These are the only
|
||||
* functions that may be called from a thread other than the metadata
|
||||
* thread.
|
||||
*
|
||||
* The blob store returns errors using negated POSIX errno values, either
|
||||
* returned in the callback or as a return value. An errno value of 0 means
|
||||
|
@ -3229,6 +3229,8 @@ void spdk_bs_create_blob_ext(struct spdk_blob_store *bs, const struct spdk_blob_
|
||||
spdk_blob_id id;
|
||||
int rc;
|
||||
|
||||
assert(spdk_get_thread() == bs->md_thread);
|
||||
|
||||
page_idx = spdk_bit_array_find_first_clear(bs->used_md_pages, 0);
|
||||
if (page_idx >= spdk_bit_array_capacity(bs->used_md_pages)) {
|
||||
cb_fn(cb_arg, 0, -ENOMEM);
|
||||
@ -3401,6 +3403,8 @@ spdk_bs_delete_blob(struct spdk_blob_store *bs, spdk_blob_id blobid,
|
||||
|
||||
SPDK_DEBUGLOG(SPDK_LOG_BLOB, "Deleting blob %lu\n", blobid);
|
||||
|
||||
assert(spdk_get_thread() == bs->md_thread);
|
||||
|
||||
cpl.type = SPDK_BS_CPL_TYPE_BLOB_BASIC;
|
||||
cpl.u.blob_basic.cb_fn = cb_fn;
|
||||
cpl.u.blob_basic.cb_arg = cb_arg;
|
||||
@ -3446,6 +3450,7 @@ void spdk_bs_open_blob(struct spdk_blob_store *bs, spdk_blob_id blobid,
|
||||
uint32_t page_num;
|
||||
|
||||
SPDK_DEBUGLOG(SPDK_LOG_BLOB, "Opening blob %lu\n", blobid);
|
||||
assert(spdk_get_thread() == bs->md_thread);
|
||||
|
||||
page_num = _spdk_bs_blobid_to_page(blobid);
|
||||
if (spdk_bit_array_get(bs->used_blobids, page_num) == false) {
|
||||
@ -3873,6 +3878,7 @@ _spdk_blob_set_xattr(struct spdk_blob *blob, const char *name, const void *value
|
||||
struct spdk_xattr *xattr;
|
||||
|
||||
assert(blob != NULL);
|
||||
assert(spdk_get_thread() == blob->bs->md_thread);
|
||||
|
||||
assert(blob->state != SPDK_BLOB_STATE_LOADING &&
|
||||
blob->state != SPDK_BLOB_STATE_SYNCING);
|
||||
@ -3930,6 +3936,7 @@ _spdk_blob_remove_xattr(struct spdk_blob *blob, const char *name, bool internal)
|
||||
struct spdk_xattr *xattr;
|
||||
|
||||
assert(blob != NULL);
|
||||
assert(spdk_get_thread() == blob->bs->md_thread);
|
||||
|
||||
assert(blob->state != SPDK_BLOB_STATE_LOADING &&
|
||||
blob->state != SPDK_BLOB_STATE_SYNCING);
|
||||
@ -3971,6 +3978,8 @@ _spdk_blob_get_xattr_value(struct spdk_blob *blob, const char *name,
|
||||
struct spdk_xattr *xattr;
|
||||
struct spdk_xattr_tailq *xattrs;
|
||||
|
||||
assert(spdk_get_thread() == blob->bs->md_thread);
|
||||
|
||||
xattrs = internal ? &blob->xattrs_internal : &blob->xattrs;
|
||||
|
||||
TAILQ_FOREACH(xattr, xattrs, link) {
|
||||
@ -4020,6 +4029,8 @@ _spdk_blob_get_xattr_names(struct spdk_xattr_tailq *xattrs, struct spdk_xattr_na
|
||||
int
|
||||
spdk_blob_get_xattr_names(struct spdk_blob *blob, struct spdk_xattr_names **names)
|
||||
{
|
||||
assert(spdk_get_thread() == blob->bs->md_thread);
|
||||
|
||||
return _spdk_blob_get_xattr_names(&blob->xattrs, names);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user