ut/blobfs: fix blobfs_sync_ut hang issue when testing file_length
we use this statement: while (g_file->length_flushed != buf_length) {} in file_length function. It means that in this test case, length_flushed are accessed by two different threads, so better to use another new variable length_flused with volatile before the variable definition. Then our ut will not hang. Change-Id: I6152a4ba3f27f0fad1c8c2baa71324a36a2fb9e8 Signed-off-by: Ziye Yang <ziye.yang@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456580 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
3bf82af866
commit
9c48768aa0
@ -237,6 +237,7 @@ file_length(void)
|
||||
int rc;
|
||||
char *buf;
|
||||
uint64_t buf_length;
|
||||
volatile uint64_t *length_flushed;
|
||||
struct spdk_fs_thread_ctx *channel;
|
||||
struct spdk_file_stat stat = {0};
|
||||
|
||||
@ -259,8 +260,13 @@ file_length(void)
|
||||
|
||||
/* Spin until all of the data has been flushed to the SSD. There's been no
|
||||
* sync operation yet, so the xattr on the file is still 0.
|
||||
*
|
||||
* length_flushed: This variable is modified by a different thread in this unit
|
||||
* test. So we need to dereference it as a volatile to ensure the value is always
|
||||
* re-read.
|
||||
*/
|
||||
while (g_file->length_flushed != buf_length) {}
|
||||
length_flushed = &g_file->length_flushed;
|
||||
while (*length_flushed != buf_length) {}
|
||||
|
||||
/* Close the file. This causes an implicit sync which should write the
|
||||
* length_flushed value as the "length" xattr on the file.
|
||||
|
Loading…
Reference in New Issue
Block a user