From 44ed167da74825bfb7950d45a4f83bce3e84921c Mon Sep 17 00:00:00 2001 From: Philipp Reisner Date: Tue, 19 Apr 2011 17:10:19 +0200 Subject: drbd: rcu_read_lock() and rcu_dereference() for tconn->net_conf Removing the get_net_conf()/put_net_conf() calls Signed-off-by: Philipp Reisner Signed-off-by: Lars Ellenberg --- drivers/block/drbd/drbd_state.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'drivers/block/drbd/drbd_state.c') diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c index 52ebd9a9b032..f20a4a3807eb 100644 --- a/drivers/block/drbd/drbd_state.c +++ b/drivers/block/drbd/drbd_state.c @@ -482,6 +482,7 @@ is_valid_state(struct drbd_conf *mdev, union drbd_state ns) enum drbd_fencing_p fp; enum drbd_state_rv rv = SS_SUCCESS; + struct net_conf *nc; fp = FP_DONT_CARE; if (get_ldev(mdev)) { @@ -489,14 +490,15 @@ is_valid_state(struct drbd_conf *mdev, union drbd_state ns) put_ldev(mdev); } - if (get_net_conf(mdev->tconn)) { - if (!mdev->tconn->net_conf->two_primaries && ns.role == R_PRIMARY) { + rcu_read_lock(); + nc = rcu_dereference(mdev->tconn->net_conf); + if (nc) { + if (!nc->two_primaries && ns.role == R_PRIMARY) { if (ns.peer == R_PRIMARY) rv = SS_TWO_PRIMARIES; else if (conn_highest_peer(mdev->tconn) == R_PRIMARY) rv = SS_O_VOL_PEER_PRI; - } - put_net_conf(mdev->tconn); + } } if (rv <= 0) @@ -531,7 +533,7 @@ is_valid_state(struct drbd_conf *mdev, union drbd_state ns) rv = SS_CONNECTED_OUTDATES; else if ((ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T) && - (mdev->tconn->net_conf->verify_alg[0] == 0)) + (nc->verify_alg[0] == 0)) rv = SS_NO_VERIFY_ALG; else if ((ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T) && @@ -541,6 +543,8 @@ is_valid_state(struct drbd_conf *mdev, union drbd_state ns) else if (ns.conn >= C_CONNECTED && ns.pdsk == D_UNKNOWN) rv = SS_CONNECTED_OUTDATES; + rcu_read_unlock(); + return rv; } -- cgit v1.2.3