Commit e7912a28 authored by Artur Paszkiewicz's avatar Artur Paszkiewicz Committed by Tomasz Zawadzki
Browse files

bdev: fix callback not working if unquiesce called inside quiesce cb



A callback for unquiescing a range inside the quiesce callback of the
same range would not be execued. The quiesce_ctx for a range is shared
between quiesce and unquiesce operations and the unquiesce callback, set
by the quiesce cb, was cleared immediately after quiesce cb finished.

Change-Id: I8cc34cb6394e533c536c0f4efb831d8bed8f7bce
Signed-off-by: default avatarArtur Paszkiewicz <artur.paszkiewicz@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/20699


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent efa09fda
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -9894,9 +9894,13 @@ bdev_quiesce_range_locked(struct lba_range *range, void *ctx, int status)
	spdk_spin_unlock(&module->internal.spinlock);

	if (quiesce_ctx->cb_fn != NULL) {
		quiesce_ctx->cb_fn(quiesce_ctx->cb_arg, status);
		/* copy the context in case the range is unlocked by the callback */
		struct bdev_quiesce_ctx tmp = *quiesce_ctx;

		quiesce_ctx->cb_fn = NULL;
		quiesce_ctx->cb_arg = NULL;

		tmp.cb_fn(tmp.cb_arg, status);
	}
	/* quiesce_ctx will be freed on unquiesce */
}
+22 −0
Original line number Diff line number Diff line
@@ -5181,6 +5181,18 @@ bdev_unquiesce_done(void *ctx, int status)
	g_unlock_lba_range_done = true;
}

static void
bdev_quiesce_done_unquiesce(void *ctx, int status)
{
	struct spdk_bdev *bdev = ctx;
	int rc;

	g_lock_lba_range_done = true;

	rc = spdk_bdev_unquiesce(bdev, &bdev_ut_if, bdev_unquiesce_done, NULL);
	CU_ASSERT(rc == 0);
}

static void
bdev_quiesce(void)
{
@@ -5262,6 +5274,16 @@ bdev_quiesce(void)
	CU_ASSERT(TAILQ_EMPTY(&channel->locked_ranges));
	CU_ASSERT(TAILQ_EMPTY(&bdev_ut_if.internal.quiesced_ranges));

	/* Test unquiesce from quiesce cb */
	g_lock_lba_range_done = false;
	g_unlock_lba_range_done = false;
	rc = spdk_bdev_quiesce(bdev, &bdev_ut_if, bdev_quiesce_done_unquiesce, bdev);
	CU_ASSERT(rc == 0);
	poll_threads();

	CU_ASSERT(g_lock_lba_range_done == true);
	CU_ASSERT(g_unlock_lba_range_done == true);

	spdk_put_io_channel(io_ch);
	spdk_bdev_close(desc);
	free_bdev(bdev);