From a324e6d0013d2202b027eaf07c4413725286b34a Mon Sep 17 00:00:00 2001 From: Tomasz Zawadzki Date: Tue, 11 Feb 2020 08:05:07 -0500 Subject: [PATCH] ut/blob: issue to consecutive md syncs Expands blob_simultaneous_operations to cover case when second md sync is perfomed without waiting for the first one to complete. The blob state is forced in UT, but in normal usage could be changed by modifying xattr, allocating thin clusters or other. Related to #1170 Signed-off-by: Tomasz Zawadzki Change-Id: I880d289cdf957d4513c080efdcb7a5d8c6b3b447 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/775 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto --- test/unit/lib/blob/blob.c/blob_ut.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/unit/lib/blob/blob.c/blob_ut.c b/test/unit/lib/blob/blob.c/blob_ut.c index 1a55f093e..6dfcc07a0 100644 --- a/test/unit/lib/blob/blob.c/blob_ut.c +++ b/test/unit/lib/blob/blob.c/blob_ut.c @@ -7630,6 +7630,32 @@ blob_simultaneous_operations(void) /* Blob resized successfully */ CU_ASSERT(g_bserrno == 0); + /* Issue two consecutive blob syncs, neither should fail. + * Force sync to actually occur by marking blob dirty each time. + * Execution of sync should not be enough to complete the operation, + * since disk I/O is required to complete it. */ + g_bserrno = -1; + + blob->state = SPDK_BLOB_STATE_DIRTY; + spdk_blob_sync_md(blob, blob_op_complete, NULL); + SPDK_CU_ASSERT_FATAL(g_bserrno == -1); + + blob->state = SPDK_BLOB_STATE_DIRTY; + spdk_blob_sync_md(blob, blob_op_complete, NULL); + SPDK_CU_ASSERT_FATAL(g_bserrno == -1); + + uint32_t completions = 0; + while (completions < 2) { + SPDK_CU_ASSERT_FATAL(poll_thread_times(0, 1)); + if (g_bserrno == 0) { + g_bserrno = -1; + completions++; + } + /* Never should the g_bserrno be other than -1. + * It would mean that either of syncs failed. */ + SPDK_CU_ASSERT_FATAL(g_bserrno == -1); + } + spdk_blob_close(blob, blob_op_complete, NULL); poll_threads(); CU_ASSERT(g_bserrno == 0);