diff options
author | Darrick J. Wong <djwong@kernel.org> | 2023-12-20 08:53:46 -0800 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2023-12-21 18:29:14 -0800 |
commit | 817d1b67b6da0a1e2ac94c73ac12fcdb10be1d1e (patch) | |
tree | 9f0798b860e85f9506841366fec3b1cd62d8d117 | |
parent | 9de9b74046527423dfd4a5140e86d74af69ee895 (diff) | |
download | xfsprogs-dev-817d1b67b6da0a1e2ac94c73ac12fcdb10be1d1e.tar.gz |
xfs_scrub: handle spurious wakeups in scan_fs_tree
Coverity reminded me that the pthread_cond_wait can wake up and return
without the predicate variable (sft.nr_dirs > 0) actually changing.
Therefore, one has to retest the condition after each wakeup.
Coverity-id: 1554280
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
-rw-r--r-- | scrub/vfs.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/scrub/vfs.c b/scrub/vfs.c index 577eb6dc3e..3c1825a75e 100644 --- a/scrub/vfs.c +++ b/scrub/vfs.c @@ -263,7 +263,7 @@ scan_fs_tree( * about to tear everything down. */ pthread_mutex_lock(&sft.lock); - if (sft.nr_dirs) + while (sft.nr_dirs > 0) pthread_cond_wait(&sft.wakeup, &sft.lock); assert(sft.nr_dirs == 0); pthread_mutex_unlock(&sft.lock); |