drivers: target: target_core_device: Pass lockdep expression to RCU lists
Subsystems (2)
PATCH v3 1/3 drivers: target: target_core_device: Pass lockdep expression to RCU lists
nacl->lun_entry_hlist is traversed with hlist_for_each_entry_rcu outside an RCU read-side critical section but under the protection of nacl->lun_entry_mutex.
Hence, add the corresponding lockdep expression to the list traversal primitive to silence false-positive lockdep warnings, and harden RCU lists.
---
v3:
- Remove rcu_read_lock_held() from lockdep expression since it is implicitly checked for.
- Remove unintended macro usage.
v2:
- Fix sparse error
CHECK: Alignment should match open parenthesis
drivers/target/target_core_device.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/target/target_core_device.c +6 -3
@@ -247,7 +247,8 @@ void core_free_device_list_for_node(struct se_dev_entry *deve;mutex_lock (&nacl->lun_entry_mutex); -hlist_for_each_entry_rcu (deve, &nacl->lun_entry_hlist, link) { +hlist_for_each_entry_rcu (deve, &nacl->lun_entry_hlist, link, +lockdep_is_held (&nacl->lun_entry_mutex)) {struct se_lun *lun =rcu_dereference_check (deve->se_lun,lockdep_is_held (&nacl->lun_entry_mutex));core_disable_device_list_for_node (lun, deve, nacl, tpg);
@@ -276,7 +277,8 @@ struct se_dev_entry *target_nacl_find_deve(struct se_node_acl *nacl, u64 mapped_ {struct se_dev_entry *deve; -hlist_for_each_entry_rcu (deve, &nacl->lun_entry_hlist, link) +hlist_for_each_entry_rcu (deve, &nacl->lun_entry_hlist, link, +lockdep_is_held (&nacl->lun_entry_mutex))if (deve->mapped_lun == mapped_lun)return deve;
@@ -460,7 +462,8 @@ void core_clear_lun_from_tpg(struct se_lun *lun, struct se_portal_group *tpg)list_for_each_entry (nacl, &tpg->acl_node_list, acl_list) {mutex_lock (&nacl->lun_entry_mutex); -hlist_for_each_entry_rcu (deve, &nacl->lun_entry_hlist, link) { +hlist_for_each_entry_rcu (deve, &nacl->lun_entry_hlist, link, +lockdep_is_held (&nacl->lun_entry_mutex)) {struct se_lun *tmp_lun =rcu_dereference_check (deve->se_lun,lockdep_is_held (&nacl->lun_entry_mutex));
Signature · 1 line
2.24.1
PATCH v3 2/3 drivers: target: target_core_tpg: Pass lockdep expression to RCU lists
tpg->tpg_lun_hlist is traversed with hlist_for_each_entry_rcu outside an RCU read-side critical section but under the protection of tpg->tpg_lun_mutex.
Hence, add the corresponding lockdep expression to the list traversal primitive to silence false-positive lockdep warnings, and harden RCU lists.
--- drivers/target/target_core_tpg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/target/target_core_tpg.c +2 -1
@@ -110,7 +110,8 @@ void core_tpg_add_node_to_devs(struct se_device *dev;mutex_lock (&tpg->tpg_lun_mutex); -hlist_for_each_entry_rcu (lun, &tpg->tpg_lun_hlist, link) { +hlist_for_each_entry_rcu (lun, &tpg->tpg_lun_hlist, link, +lockdep_is_held (&tpg->tpg_lun_mutex)) {if (lun_orig && lun != lun_orig)continue ;
Signature · 1 line
2.24.1
PATCH v3 3/3 drivers: target: tcm_fc: tfc_sess: Pass lockdep expression to RCU lists
In reply to Amol Groverhead is traversed with hlist_for_each_entry_rcu outside an RCU read-side critical section but under the protection of ft_lport_lock.
Hence, add the corresponding lockdep expression to the list traversal primitive to silence false-positive lockdep warnings, and harden RCU lists.
--- drivers/target/tcm_fc/tfc_sess.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/target/tcm_fc/tfc_sess.c +8 -4
@@ -170,7 +170,8 @@ static struct ft_sess *ft_sess_get(struct fc_lport *lport, u32 port_id) } head = &tport->hash[ft_sess_hash (port_id)]; -hlist_for_each_entry_rcu (sess, head, hash) { +hlist_for_each_entry_rcu (sess, head, hash, +lockdep_is_held (&ft_lport_lock)) {if (sess->port_id == port_id) {kref_get (&sess->kref);rcu_read_unlock ();
@@ -215,7 +216,8 @@ static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id,ft_format_wwn (&initiatorname[0 ],TRANSPORT_IQN_LEN , rdata->ids.port_name); head = &tport->hash[ft_sess_hash (port_id)]; -hlist_for_each_entry_rcu (sess, head, hash) +hlist_for_each_entry_rcu (sess, head, hash, +lockdep_is_held (&ft_lport_lock))if (sess->port_id == port_id)return sess;
@@ -264,7 +266,8 @@ static struct ft_sess *ft_sess_delete(struct ft_tport *tport, u32 port_id)struct ft_sess *sess; head = &tport->hash[ft_sess_hash (port_id)]; -hlist_for_each_entry_rcu (sess, head, hash) { +hlist_for_each_entry_rcu (sess, head, hash, +lockdep_is_held (&ft_lport_lock)) {if (sess->port_id == port_id) {ft_sess_unhash (sess);return sess;
@@ -291,7 +294,8 @@ static void ft_sess_delete_all(struct ft_tport *tport)for (head = tport->hash; head < &tport->hash[FT_SESS_HASH_SIZE ]; head++) { -hlist_for_each_entry_rcu (sess, head, hash) { +hlist_for_each_entry_rcu (sess, head, hash, +lockdep_is_held (&ft_lport_lock)) {ft_sess_unhash (sess);ft_close_sess (sess);/* release from table */ }
Signature · 1 line
2.24.1