mirror of
https://github.com/SCST-project/scst.git
synced 2026-08-17 12:46:27 +00:00
scst_lib: Avoid holding scst_mutex during sess_tgt_dev_list access
In the previous commit, we introduced the use of RCU protection when accessing sess_tgt_dev_list in scst_get_max_lun_commands(). As a result, we can now drop the use of scst_mutex when accessing the list.
This commit is contained in:
+9
-7
@@ -14084,11 +14084,11 @@ int scst_get_max_lun_commands(struct scst_session *sess, uint64_t lun)
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
mutex_lock(&scst_mutex);
|
||||
|
||||
if (sess == NULL) {
|
||||
struct scst_device *dev;
|
||||
|
||||
mutex_lock(&scst_mutex);
|
||||
|
||||
list_for_each_entry(dev, &scst_dev_list, dev_list_entry) {
|
||||
if (dev->handler == &scst_null_devtype)
|
||||
continue;
|
||||
@@ -14097,7 +14097,10 @@ int scst_get_max_lun_commands(struct scst_session *sess, uint64_t lun)
|
||||
if (res > dev->max_tgt_dev_commands)
|
||||
res = dev->max_tgt_dev_commands;
|
||||
}
|
||||
goto out_unlock;
|
||||
|
||||
mutex_unlock(&scst_mutex);
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (lun != NO_SUCH_LUN) {
|
||||
@@ -14118,7 +14121,7 @@ int scst_get_max_lun_commands(struct scst_session *sess, uint64_t lun)
|
||||
}
|
||||
rcu_read_unlock();
|
||||
|
||||
goto out_unlock;
|
||||
goto out;
|
||||
}
|
||||
|
||||
rcu_read_lock();
|
||||
@@ -14133,10 +14136,9 @@ int scst_get_max_lun_commands(struct scst_session *sess, uint64_t lun)
|
||||
}
|
||||
rcu_read_unlock();
|
||||
|
||||
out_unlock:
|
||||
mutex_unlock(&scst_mutex);
|
||||
|
||||
out:
|
||||
TRACE_EXIT_RES(res);
|
||||
|
||||
return res;
|
||||
}
|
||||
EXPORT_SYMBOL(scst_get_max_lun_commands);
|
||||
|
||||
Reference in New Issue
Block a user