Commit 8ba7450e authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

blob: simplify check for available cluster count



Signed-off-by: default avatarJim 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: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent f5b949d5
Loading
Loading
Loading
Loading
+4 −13
Original line number Diff line number Diff line
@@ -1873,20 +1873,11 @@ 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 */
	/* 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;
		}
			lfc++;
		}
		lfmd = 0;
		for (i = current_num_ep; i < new_num_ep ; i++) {
			lfmd = spdk_bit_array_find_first_clear(blob->bs->used_md_pages, lfmd);