|
From: <bva...@us...> - 2019-08-05 01:43:43
|
Revision: 8496
http://sourceforge.net/p/scst/svn/8496
Author: bvassche
Date: 2019-08-05 01:43:41 +0000 (Mon, 05 Aug 2019)
Log Message:
-----------
scst: Fix a race condition between LUN translation and LUN removal
Modified Paths:
--------------
trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c 2019-08-05 01:43:03 UTC (rev 8495)
+++ trunk/scst/src/scst_targ.c 2019-08-05 01:43:41 UTC (rev 8496)
@@ -4996,6 +4996,9 @@
rcu_read_lock();
tgt_dev = scst_lookup_tgt_dev(cmd->sess, cmd->lun);
+ if (tgt_dev &&
+ !atomic_inc_not_zero(&tgt_dev->tgt_dev_cmd_count))
+ tgt_dev = NULL;
rcu_read_unlock();
if (tgt_dev) {
@@ -5014,6 +5017,7 @@
"the device will not be visible remotely",
(unsigned long long)cmd->lun);
nul_dev = true;
+ scst_tgt_dev_dec_cmd_count(tgt_dev);
}
}
if (unlikely(res != 0)) {
@@ -5142,7 +5146,7 @@
scst_set_cmd_state(cmd, SCST_CMD_STATE_PARSE);
- cnt = atomic_inc_return(&tgt_dev->tgt_dev_cmd_count) - 1;
+ cnt = atomic_read(&tgt_dev->tgt_dev_cmd_count) - 1;
if (unlikely(cnt > dev->max_tgt_dev_commands)) {
TRACE(TRACE_FLOW_CONTROL,
"Too many pending commands (%d) in "
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|