scst_user: Protect the shared debug freeze flag with its mutex

DEBUG_TM_IGNORE_ALL workers share a freeze flag without synchronization.
Manual review of the volatile warning confirmed that volatile does not
protect these concurrent accesses. Store and snapshot the flag under the
existing per-device mutex, then unlock before the intentional infinite
sleep. The mutex is initialized before worker creation and destroyed
after joins.

Checkpatch reports VOLATILE:

  Use of volatile is usually wrong: see
  Documentation/process/volatile-considered-harmful.rst
This commit is contained in:
Gleb Chesnokov
2026-10-21 22:12:25 +03:00
parent a8d3b8f021
commit 2f1ca0223f
2 changed files with 7 additions and 2 deletions
+6 -1
View File
@@ -812,11 +812,16 @@ void *main_loop(void *arg)
while(1) {
#ifdef DEBUG_TM_IGNORE_ALL
int ignore_all;
pthread_mutex_lock(&dev->dev_mutex);
if (dev->debug_tm_ignore && (random() % 50000) == 55) {
TRACE_MGMT_DBG("%s", "Ignore ALL");
dev->debug_tm_ignore_all = 1;
}
if (dev->debug_tm_ignore_all) {
ignore_all = dev->debug_tm_ignore_all;
pthread_mutex_unlock(&dev->dev_mutex);
if (ignore_all) {
/* Go Astral */
while(1) {
sleep(60);
+1 -1
View File
@@ -87,7 +87,7 @@ struct vdisk_dev {
#if defined(DEBUG_TM_IGNORE) || defined(DEBUG_TM_IGNORE_ALL)
unsigned int debug_tm_ignore:1;
#if defined(DEBUG_TM_IGNORE_ALL)
volatile int debug_tm_ignore_all;
int debug_tm_ignore_all;
#endif
#endif