From fde382d1ee1d5ef9cf5e9ab28875013f00196a02 Mon Sep 17 00:00:00 2001 From: Tomasz Zawadzki Date: Tue, 30 Apr 2019 08:50:05 -0400 Subject: [PATCH] blobstore: release same cluster as claimed during initial insert When new writes come from different threads, cluster allocations can happen many times at once. The corresponding cluster number for the map is determined via _spdk_bs_allocate_cluster() and kept in ctx->new_cluster. The cluster itself is inserted into the map only on md_thread. When there is conflict of two threads allocating same cluster, message is returned to the losting thread to release the cluster. Before this patch, on such failure the cluster to release was calcualted from the page. This resulted in releasing the cluster claim for thread that actually won it. This patch makes it so that cluster allocated and save in ctx is used instead. Change-Id: Id10811b887f673f9b89e41e0637d4422f1d7270d Signed-off-by: Tomasz Zawadzki Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452625 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/blob/blobstore.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/blob/blobstore.c b/lib/blob/blobstore.c index 5655ba053..2e3037ac1 100644 --- a/lib/blob/blobstore.c +++ b/lib/blob/blobstore.c @@ -1589,17 +1589,13 @@ _spdk_blob_insert_cluster_cpl(void *cb_arg, int bserrno) struct spdk_blob_copy_cluster_ctx *ctx = cb_arg; if (bserrno) { - uint32_t cluster_number; - if (bserrno == -EEXIST) { /* The metadata insert failed because another thread * allocated the cluster first. Free our cluster * but continue without error. */ bserrno = 0; } - - cluster_number = _spdk_bs_page_to_cluster(ctx->blob->bs, ctx->page); - _spdk_bs_release_cluster(ctx->blob->bs, cluster_number); + _spdk_bs_release_cluster(ctx->blob->bs, ctx->new_cluster); } spdk_bs_sequence_finish(ctx->seq, bserrno);