blob: simplify check for available cluster count

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I56a9ca114b84ded4ac23a9eaacadaa6df8f031cc
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3968
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:24:05 -07:00 committed by Tomasz Zawadzki
parent f5b949d5fd
commit 8ba7450e8c

View File

@ -1873,19 +1873,10 @@ blob_resize(struct spdk_blob *blob, uint64_t sz)
current_num_ep = spdk_divide_round_up(num_clusters, SPDK_EXTENTS_PER_EP);
}
/* Do two passes - one to verify that we can obtain enough clusters
* and md pages, another to actually claim them.
*/
if (spdk_blob_is_thin_provisioned(blob) == false) {
lfc = 0;
for (i = num_clusters; i < sz; i++) {
lfc = spdk_bit_array_find_first_clear(bs->used_clusters, lfc);
if (lfc == UINT32_MAX) {
/* No more free clusters. Cannot satisfy the request */
return -ENOSPC;
}
lfc++;
/* Check first that we have enough clusters and md pages before we start claiming them. */
if (sz > num_clusters && spdk_blob_is_thin_provisioned(blob) == false) {
if ((sz - num_clusters) > bs->num_free_clusters) {
return -ENOSPC;
}
lfmd = 0;
for (i = current_num_ep; i < new_num_ep ; i++) {