drbd: Use RCU for the drbd_tconns list
Preparing removal of drbd_cfg_rwsem
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index 5747bc6..a0cf000 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -2674,7 +2674,7 @@
/* synchronize with conn_create()/conn_destroy() */
down_read(&drbd_cfg_rwsem);
/* revalidate iterator position */
- list_for_each_entry(tmp, &drbd_tconns, all_tconn) {
+ list_for_each_entry_rcu(tmp, &drbd_tconns, all_tconn) {
if (pos == NULL) {
/* first iteration */
pos = tmp;
@@ -2692,8 +2692,8 @@
if (!mdev) {
/* No more volumes to dump on this tconn.
* Advance tconn iterator. */
- pos = list_entry(tconn->all_tconn.next,
- struct drbd_tconn, all_tconn);
+ pos = list_entry_rcu(tconn->all_tconn.next,
+ struct drbd_tconn, all_tconn);
/* Did we dump any volume on this tconn yet? */
if (volume != 0) {
/* If we reached the end of the list,
@@ -3130,7 +3130,8 @@
/* delete connection */
if (conn_lowest_minor(adm_ctx.tconn) < 0) {
- list_del(&adm_ctx.tconn->all_tconn);
+ list_del_rcu(&adm_ctx.tconn->all_tconn);
+ synchronize_rcu();
kref_put(&adm_ctx.tconn->kref, &conn_destroy);
retcode = NO_ERROR;
@@ -3160,7 +3161,8 @@
down_write(&drbd_cfg_rwsem);
if (conn_lowest_minor(adm_ctx.tconn) < 0) {
- list_del(&adm_ctx.tconn->all_tconn);
+ list_del_rcu(&adm_ctx.tconn->all_tconn);
+ synchronize_rcu();
kref_put(&adm_ctx.tconn->kref, &conn_destroy);
retcode = NO_ERROR;