blob: add _spdk_blob_verify_md_op
These are common functions that can be called from any function that reads or modifies a blob's metadata to perform necessary asserts. This will also fix several places where blob metadata functions were asserting the calling thread context, but not the current state of the blob. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: I9e16c082a27c439311f8ff214335adadfa715497 Reviewed-on: https://review.gerrithub.io/401053 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: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
7d4705a257
commit
4f6096fa10
@ -59,6 +59,14 @@ static int _spdk_blob_get_xattr_value(struct spdk_blob *blob, const char *name,
|
|||||||
const void **value, size_t *value_len, bool internal);
|
const void **value, size_t *value_len, bool internal);
|
||||||
static int _spdk_blob_remove_xattr(struct spdk_blob *blob, const char *name, bool internal);
|
static int _spdk_blob_remove_xattr(struct spdk_blob *blob, const char *name, bool internal);
|
||||||
|
|
||||||
|
static void
|
||||||
|
_spdk_blob_verify_md_op(struct spdk_blob *blob)
|
||||||
|
{
|
||||||
|
assert(blob != NULL);
|
||||||
|
assert(spdk_get_thread() == blob->bs->md_thread);
|
||||||
|
assert(blob->state != SPDK_BLOB_STATE_LOADING);
|
||||||
|
}
|
||||||
|
|
||||||
static inline size_t
|
static inline size_t
|
||||||
divide_round_up(size_t num, size_t divisor)
|
divide_round_up(size_t num, size_t divisor)
|
||||||
{
|
{
|
||||||
@ -83,7 +91,7 @@ _spdk_blob_insert_cluster(struct spdk_blob *blob, uint32_t cluster_num, uint64_t
|
|||||||
{
|
{
|
||||||
uint64_t *cluster_lba = &blob->active.clusters[cluster_num];
|
uint64_t *cluster_lba = &blob->active.clusters[cluster_num];
|
||||||
|
|
||||||
assert(spdk_get_thread() == blob->bs->md_thread);
|
_spdk_blob_verify_md_op(blob);
|
||||||
|
|
||||||
if (*cluster_lba != 0) {
|
if (*cluster_lba != 0) {
|
||||||
return -EEXIST;
|
return -EEXIST;
|
||||||
@ -3215,6 +3223,7 @@ _spdk_blob_set_xattrs(struct spdk_blob *blob, const struct spdk_blob_xattr_opts
|
|||||||
static void
|
static void
|
||||||
_spdk_blob_set_thin_provision(struct spdk_blob *blob)
|
_spdk_blob_set_thin_provision(struct spdk_blob *blob)
|
||||||
{
|
{
|
||||||
|
_spdk_blob_verify_md_op(blob);
|
||||||
blob->invalid_flags |= SPDK_BLOB_THIN_PROV;
|
blob->invalid_flags |= SPDK_BLOB_THIN_PROV;
|
||||||
blob->state = SPDK_BLOB_STATE_DIRTY;
|
blob->state = SPDK_BLOB_STATE_DIRTY;
|
||||||
}
|
}
|
||||||
@ -3300,8 +3309,7 @@ spdk_blob_resize(struct spdk_blob *blob, uint64_t sz)
|
|||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
assert(blob != NULL);
|
_spdk_blob_verify_md_op(blob);
|
||||||
assert(spdk_get_thread() == blob->bs->md_thread);
|
|
||||||
|
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_BLOB, "Resizing blob %lu to %lu clusters\n", blob->id, sz);
|
SPDK_DEBUGLOG(SPDK_LOG_BLOB, "Resizing blob %lu to %lu clusters\n", blob->id, sz);
|
||||||
|
|
||||||
@ -3371,6 +3379,8 @@ _spdk_bs_delete_open_cpl(void *cb_arg, struct spdk_blob *blob, int bserrno)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_spdk_blob_verify_md_op(blob);
|
||||||
|
|
||||||
if (blob->open_ref > 1) {
|
if (blob->open_ref > 1) {
|
||||||
/*
|
/*
|
||||||
* Someone has this blob open (besides this delete context).
|
* Someone has this blob open (besides this delete context).
|
||||||
@ -3492,7 +3502,7 @@ void spdk_bs_open_blob(struct spdk_blob_store *bs, spdk_blob_id blobid,
|
|||||||
/* START spdk_blob_set_read_only */
|
/* START spdk_blob_set_read_only */
|
||||||
int 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);
|
_spdk_blob_verify_md_op(blob);
|
||||||
|
|
||||||
blob->data_ro_flags |= SPDK_BLOB_READ_ONLY;
|
blob->data_ro_flags |= SPDK_BLOB_READ_ONLY;
|
||||||
|
|
||||||
@ -3538,13 +3548,10 @@ _spdk_blob_sync_md(struct spdk_blob *blob, spdk_blob_op_complete cb_fn, void *cb
|
|||||||
void
|
void
|
||||||
spdk_blob_sync_md(struct spdk_blob *blob, spdk_blob_op_complete cb_fn, void *cb_arg)
|
spdk_blob_sync_md(struct spdk_blob *blob, spdk_blob_op_complete cb_fn, void *cb_arg)
|
||||||
{
|
{
|
||||||
assert(blob != NULL);
|
_spdk_blob_verify_md_op(blob);
|
||||||
assert(spdk_get_thread() == blob->bs->md_thread);
|
|
||||||
|
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_BLOB, "Syncing blob %lu\n", blob->id);
|
SPDK_DEBUGLOG(SPDK_LOG_BLOB, "Syncing blob %lu\n", blob->id);
|
||||||
|
|
||||||
assert(blob->state != SPDK_BLOB_STATE_LOADING);
|
|
||||||
|
|
||||||
if (blob->md_ro) {
|
if (blob->md_ro) {
|
||||||
assert(blob->state == SPDK_BLOB_STATE_CLEAN);
|
assert(blob->state == SPDK_BLOB_STATE_CLEAN);
|
||||||
cb_fn(cb_arg, 0);
|
cb_fn(cb_arg, 0);
|
||||||
@ -3657,13 +3664,10 @@ void spdk_blob_close(struct spdk_blob *blob, spdk_blob_op_complete cb_fn, void *
|
|||||||
struct spdk_bs_cpl cpl;
|
struct spdk_bs_cpl cpl;
|
||||||
spdk_bs_sequence_t *seq;
|
spdk_bs_sequence_t *seq;
|
||||||
|
|
||||||
assert(blob != NULL);
|
_spdk_blob_verify_md_op(blob);
|
||||||
assert(spdk_get_thread() == blob->bs->md_thread);
|
|
||||||
|
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_BLOB, "Closing blob %lu\n", blob->id);
|
SPDK_DEBUGLOG(SPDK_LOG_BLOB, "Closing blob %lu\n", blob->id);
|
||||||
|
|
||||||
assert(blob->state != SPDK_BLOB_STATE_LOADING);
|
|
||||||
|
|
||||||
if (blob->open_ref == 0) {
|
if (blob->open_ref == 0) {
|
||||||
cb_fn(cb_arg, -EBADF);
|
cb_fn(cb_arg, -EBADF);
|
||||||
return;
|
return;
|
||||||
@ -3876,10 +3880,7 @@ _spdk_blob_set_xattr(struct spdk_blob *blob, const char *name, const void *value
|
|||||||
struct spdk_xattr_tailq *xattrs;
|
struct spdk_xattr_tailq *xattrs;
|
||||||
struct spdk_xattr *xattr;
|
struct spdk_xattr *xattr;
|
||||||
|
|
||||||
assert(blob != NULL);
|
_spdk_blob_verify_md_op(blob);
|
||||||
assert(spdk_get_thread() == blob->bs->md_thread);
|
|
||||||
|
|
||||||
assert(blob->state != SPDK_BLOB_STATE_LOADING);
|
|
||||||
|
|
||||||
if (blob->md_ro) {
|
if (blob->md_ro) {
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
@ -3933,10 +3934,7 @@ _spdk_blob_remove_xattr(struct spdk_blob *blob, const char *name, bool internal)
|
|||||||
struct spdk_xattr_tailq *xattrs;
|
struct spdk_xattr_tailq *xattrs;
|
||||||
struct spdk_xattr *xattr;
|
struct spdk_xattr *xattr;
|
||||||
|
|
||||||
assert(blob != NULL);
|
_spdk_blob_verify_md_op(blob);
|
||||||
assert(spdk_get_thread() == blob->bs->md_thread);
|
|
||||||
|
|
||||||
assert(blob->state != SPDK_BLOB_STATE_LOADING);
|
|
||||||
|
|
||||||
if (blob->md_ro) {
|
if (blob->md_ro) {
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
@ -3975,7 +3973,7 @@ _spdk_blob_get_xattr_value(struct spdk_blob *blob, const char *name,
|
|||||||
struct spdk_xattr *xattr;
|
struct spdk_xattr *xattr;
|
||||||
struct spdk_xattr_tailq *xattrs;
|
struct spdk_xattr_tailq *xattrs;
|
||||||
|
|
||||||
assert(spdk_get_thread() == blob->bs->md_thread);
|
_spdk_blob_verify_md_op(blob);
|
||||||
|
|
||||||
xattrs = internal ? &blob->xattrs_internal : &blob->xattrs;
|
xattrs = internal ? &blob->xattrs_internal : &blob->xattrs;
|
||||||
|
|
||||||
@ -4026,7 +4024,7 @@ _spdk_blob_get_xattr_names(struct spdk_xattr_tailq *xattrs, struct spdk_xattr_na
|
|||||||
int
|
int
|
||||||
spdk_blob_get_xattr_names(struct spdk_blob *blob, struct spdk_xattr_names **names)
|
spdk_blob_get_xattr_names(struct spdk_blob *blob, struct spdk_xattr_names **names)
|
||||||
{
|
{
|
||||||
assert(spdk_get_thread() == blob->bs->md_thread);
|
_spdk_blob_verify_md_op(blob);
|
||||||
|
|
||||||
return _spdk_blob_get_xattr_names(&blob->xattrs, names);
|
return _spdk_blob_get_xattr_names(&blob->xattrs, names);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user