lib/blob: read clear_method from per blob metadata

On blob load, read in the saved clear_method option. If
BLOB_CLEAR_WITH_DEFAULT was passed in, use the setting stored
in metadata previously.  If something other than the default was
specified, ignore stored value and used what was passed in. If
ignoring a stored value, print a warning.

Signed-off-by: paul luse <paul.e.luse@intel.com>
Change-Id: Ia0c81fa0adc175dfaeb74c06e1ac91dc6b27e9ab
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/472209
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
paul luse 2019-10-23 18:41:41 +00:00 committed by Tomasz Zawadzki
parent ea69d6d6cc
commit ca667d064f

View File

@ -953,6 +953,8 @@ _spdk_blob_load_snapshot_cpl(void *cb_arg, struct spdk_blob *snapshot, int bserr
_spdk_blob_load_final(ctx, bserrno);
}
static void _spdk_blob_update_clear_method(struct spdk_blob *blob);
static void
_spdk_blob_load_backing_dev(void *cb_arg)
{
@ -1034,6 +1036,12 @@ _spdk_blob_load_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
_spdk_blob_load_final(ctx, rc);
return;
}
ctx->seq = seq;
/* Check the clear_method stored in metadata vs what may have been passed
* via spdk_bs_open_blob_ext() and update accordingly.
*/
_spdk_blob_update_clear_method(blob);
_spdk_blob_load_backing_dev(ctx);
}
@ -6328,6 +6336,27 @@ spdk_blob_is_thin_provisioned(struct spdk_blob *blob)
return !!(blob->invalid_flags & SPDK_BLOB_THIN_PROV);
}
static void
_spdk_blob_update_clear_method(struct spdk_blob *blob)
{
enum blob_clear_method stored_cm;
assert(blob != NULL);
/* If BLOB_CLEAR_WITH_DEFAULT was passed in, use the setting stored
* in metadata previously. If something other than the default was
* specified, ignore stored value and used what was passed in.
*/
stored_cm = ((blob->md_ro_flags & SPDK_BLOB_CLEAR_METHOD) >> SPDK_BLOB_CLEAR_METHOD_SHIFT);
if (blob->clear_method == BLOB_CLEAR_WITH_DEFAULT) {
blob->clear_method = stored_cm;
} else if (blob->clear_method != stored_cm) {
SPDK_WARNLOG("Using passed in clear method 0x%x instead of stored value of 0x%x\n",
blob->clear_method, stored_cm);
}
}
spdk_blob_id
spdk_blob_get_parent_snapshot(struct spdk_blob_store *bs, spdk_blob_id blob_id)
{