blob: simplify free cluster counting in inflate path

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I5716290476d4abdf8646a36206f07acb5b2dd4ec
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3967
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Jim Harris 2020-08-27 15:14:06 -07:00 committed by Tomasz Zawadzki
parent 2d87587fe5
commit f5b949d5fd

View File

@ -5922,7 +5922,7 @@ static void
bs_inflate_blob_open_cpl(void *cb_arg, struct spdk_blob *_blob, int bserrno)
{
struct spdk_clone_snapshot_ctx *ctx = (struct spdk_clone_snapshot_ctx *)cb_arg;
uint64_t lfc; /* lowest free cluster */
uint64_t clusters_needed;
uint64_t i;
if (bserrno != 0) {
@ -5957,18 +5957,18 @@ bs_inflate_blob_open_cpl(void *cb_arg, struct spdk_blob *_blob, int bserrno)
/* Do two passes - one to verify that we can obtain enough clusters
* and another to actually claim them.
*/
lfc = 0;
clusters_needed = 0;
for (i = 0; i < _blob->active.num_clusters; i++) {
if (bs_cluster_needs_allocation(_blob, i, ctx->allocate_all)) {
lfc = spdk_bit_array_find_first_clear(_blob->bs->used_clusters, lfc);
if (lfc == UINT32_MAX) {
/* No more free clusters. Cannot satisfy the request */
clusters_needed++;
}
}
if (clusters_needed > _blob->bs->num_free_clusters) {
/* Not enough free clusters. Cannot satisfy the request. */
bs_clone_snapshot_origblob_cleanup(ctx, -ENOSPC);
return;
}
lfc++;
}
}
ctx->cluster = 0;
bs_inflate_blob_touch_next(ctx, 0);