blob: refactor parent_id and allocate_all checks

The blob's parent_id and allocate_all examined and/or modified in a
two places bs_inflate_blob_open_cpl(). This transforms the two if
statements scattered around the function into a switch statement to make
it easier to understand how these two values are related.

Signed-off-by: Mike Gerdts <mgerdts@nvidia.com>
Change-Id: I2cff2d07a0089b52678035b2ece60db6a5f67a8e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17178
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Mike Gerdts 2023-03-14 09:45:34 -05:00 committed by Jim Harris
parent ecee22738b
commit 9ea88fcb72

View File

@ -6815,20 +6815,16 @@ bs_inflate_blob_open_cpl(void *cb_arg, struct spdk_blob *_blob, int bserrno)
_blob->locked_operation_in_progress = true; _blob->locked_operation_in_progress = true;
if (!ctx->allocate_all && _blob->parent_id == SPDK_BLOBID_INVALID) { switch (_blob->parent_id) {
/* This blob have no parent, so we cannot decouple it. */ case SPDK_BLOBID_INVALID:
SPDK_ERRLOG("Cannot decouple parent of blob with no parent.\n"); if (!ctx->allocate_all) {
bs_clone_snapshot_origblob_cleanup(ctx, -EINVAL); /* This blob has no parent, so we cannot decouple it. */
return; SPDK_ERRLOG("Cannot decouple parent of blob with no parent.\n");
} bs_clone_snapshot_origblob_cleanup(ctx, -EINVAL);
return;
if (spdk_blob_is_thin_provisioned(_blob) == false) { }
/* This is not thin provisioned blob. No need to inflate. */ break;
bs_clone_snapshot_origblob_cleanup(ctx, 0); case SPDK_BLOBID_EXTERNAL_SNAPSHOT:
return;
}
if (_blob->parent_id == SPDK_BLOBID_EXTERNAL_SNAPSHOT) {
/* /*
* It would be better to rely on back_bs_dev->is_zeroes(), to determine which * It would be better to rely on back_bs_dev->is_zeroes(), to determine which
* clusters require allocation. Until there is a blobstore consumer that * clusters require allocation. Until there is a blobstore consumer that
@ -6836,6 +6832,15 @@ bs_inflate_blob_open_cpl(void *cb_arg, struct spdk_blob *_blob, int bserrno)
* worth the effort. * worth the effort.
*/ */
ctx->allocate_all = true; ctx->allocate_all = true;
break;
default:
break;
}
if (spdk_blob_is_thin_provisioned(_blob) == false) {
/* This is not thin provisioned blob. No need to inflate. */
bs_clone_snapshot_origblob_cleanup(ctx, 0);
return;
} }
/* Do two passes - one to verify that we can obtain enough clusters /* Do two passes - one to verify that we can obtain enough clusters