extern struct idr minors;
extern struct list_head drbd_tconns;
extern struct rw_semaphore drbd_cfg_rwsem;
-/* drbd_cfg_rwsem protects: drbd_tconns list,
+/* drbd_cfg_rwsem protects: drbd_tconns list, minors idr, tconn->volumes idr
note: non sleeping iterations over the idrs are protoected by RCU */
/* on the wire */
drbd_genl_unregister();
+ down_write(&drbd_cfg_rwsem);
idr_for_each_entry(&minors, mdev, i)
drbd_delete_device(mdev);
+ up_write(&drbd_cfg_rwsem);
drbd_destroy_mempools();
unregister_blkdev(DRBD_MAJOR, "drbd");
struct drbd_conf *mdev;
int vnr;
+ down_read(&drbd_cfg_rwsem);
idr_for_each_entry(&tconn->volumes, mdev, vnr)
drbd_md_sync(mdev);
+ up_read(&drbd_cfg_rwsem);
}
int conn_khelper(struct drbd_tconn *tconn, char *cmd)
goto out;
}
+ down_write(&drbd_cfg_rwsem);
retcode = conn_new_minor(adm_ctx.tconn, dh->minor, adm_ctx.volume);
+ up_write(&drbd_cfg_rwsem);
out:
drbd_adm_finish(info, retcode);
return 0;
oos .. known out-of-sync kB
*/
+ down_read(&drbd_cfg_rwsem);
idr_for_each_entry(&minors, mdev, i) {
if (prev_i != i - 1)
seq_printf(seq, "\n");
}
}
}
+ up_read(&drbd_cfg_rwsem);
return 0;
}
if (drbd_send_protocol(tconn) == -EOPNOTSUPP)
return -1;
- return !idr_for_each(&tconn->volumes, drbd_connected, tconn);
+ down_read(&drbd_cfg_rwsem);
+ h = !idr_for_each(&tconn->volumes, drbd_connected, tconn);
+ up_read(&drbd_cfg_rwsem);
+ return h;
out_release_sockets:
if (tconn->data.socket) {
drbd_thread_stop(&tconn->asender);
drbd_free_sock(tconn);
+ down_read(&drbd_cfg_rwsem);
idr_for_each(&tconn->volumes, drbd_disconnected, tconn);
+ up_read(&drbd_cfg_rwsem);
conn_info(tconn, "Connection closed\n");
if (conn_highest_role(tconn) == R_PRIMARY && conn_highest_pdsk(tconn) >= D_UNKNOWN)
do {
clear_bit(SIGNAL_ASENDER, &tconn->flags);
flush_signals(current);
+ down_read(&drbd_cfg_rwsem);
idr_for_each_entry(&tconn->volumes, mdev, i) {
- if (drbd_finish_peer_reqs(mdev))
+ if (drbd_finish_peer_reqs(mdev)) {
+ up_read(&drbd_cfg_rwsem);
return 1; /* error */
+ }
}
+ up_read(&drbd_cfg_rwsem);
set_bit(SIGNAL_ASENDER, &tconn->flags);
spin_lock_irq(&tconn->req_lock);
spin_unlock_irq(&tconn->data.work.q_lock);
drbd_thread_stop(&tconn->receiver);
+ down_read(&drbd_cfg_rwsem);
idr_for_each_entry(&tconn->volumes, mdev, vnr) {
D_ASSERT(mdev->state.disk == D_DISKLESS && mdev->state.conn == C_STANDALONE);
/* _drbd_set_state only uses stop_nowait.
* wait here for the exiting receiver. */
drbd_mdev_cleanup(mdev);
}
+ up_read(&drbd_cfg_rwsem);
clear_bit(OBJECT_DYING, &tconn->flags);
clear_bit(CONFIG_PENDING, &tconn->flags);
wake_up(&tconn->ping_wait);