Commit 0413071f authored by Yalong Wang's avatar Yalong Wang Committed by Tomasz Zawadzki
Browse files

lib/blob: Use dedicated buf for cluster release



The buffer new_cluster_page was meant for cluster allocation and
its reuse is guarded by need_cluster_alloc.
Commit 41fd1f6b also used it for unmap, risking concurrent reuse and corruption.

Fix by introducing a separate buffer for cluster release to avoid
interference with allocation.

Change-Id: I42566ea6441ffe2dbbfb059578a25dd959fa8d84
Signed-off-by: default avatarYalong Wang <yalong9@staff.sina.com.cn>
Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/26196


Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz@tzawadzki.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
parent c9ae71ff
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -3267,7 +3267,7 @@ blob_request_submit_op_single(struct spdk_io_channel *_ch, struct spdk_blob *blo
			ctx->blob = blob;
			ctx->page = cluster_start_page;
			ctx->cluster_num = cluster_number;
			ctx->md_page = bs_channel->new_cluster_page;
			ctx->md_page = bs_channel->release_cluster_page;
			ctx->seq = bs_sequence_start_bs(_ch, &cpl);
			if (!ctx->seq) {
				free(ctx);
@@ -3655,6 +3655,16 @@ bs_channel_create(void *io_device, void *ctx_buf)
		return -1;
	}

	channel->release_cluster_page = spdk_zmalloc(bs->md_page_size, 0, NULL, SPDK_ENV_NUMA_ID_ANY,
					SPDK_MALLOC_DMA);
	if (!channel->release_cluster_page) {
		SPDK_ERRLOG("Failed to allocate release cluster page\n");
		spdk_free(channel->new_cluster_page);
		free(channel->req_mem);
		channel->dev->destroy_channel(channel->dev, channel->dev_channel);
		return -1;
	}

	TAILQ_INIT(&channel->need_cluster_alloc);
	TAILQ_INIT(&channel->queued_io);
	RB_INIT(&channel->esnap_channels);
@@ -3684,6 +3694,7 @@ bs_channel_destroy(void *io_device, void *ctx_buf)

	free(channel->req_mem);
	spdk_free(channel->new_cluster_page);
	spdk_free(channel->release_cluster_page);
	channel->dev->destroy_channel(channel->dev, channel->dev_channel);
}

+3 −0
Original line number Diff line number Diff line
@@ -220,6 +220,9 @@ struct spdk_bs_channel {
	TAILQ_HEAD(, spdk_bs_request_set) need_cluster_alloc;
	TAILQ_HEAD(, spdk_bs_request_set) queued_io;

	/* This page is only used during release of an existing cluster. */
	struct spdk_blob_md_page        *release_cluster_page;

	RB_HEAD(blob_esnap_channel_tree, blob_esnap_channel) esnap_channels;
};