lkml.org 
[lkml]   [2011]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 030/118] drbd: moved net_cont and net_cnt_wait from mdev to tconn
Date
Patch partly generated by:

sed -i -e 's/get_net_conf(mdev)/get_net_conf(mdev->tconn)/g' \
-e 's/put_net_conf(mdev)/put_net_conf(mdev->tconn)/g' \
-e 's/get_net_conf(odev)/get_net_conf(odev->tconn)/g' \
-e 's/put_net_conf(odev)/put_net_conf(odev->tconn)/g' \
*.[ch]

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
---
drivers/block/drbd/drbd_int.h | 23 ++++++++++++-----------
drivers/block/drbd/drbd_main.c | 9 +++++----
drivers/block/drbd/drbd_nl.c | 20 ++++++++++----------
drivers/block/drbd/drbd_receiver.c | 14 +++++++-------
drivers/block/drbd/drbd_req.c | 10 +++++-----
5 files changed, 39 insertions(+), 37 deletions(-)
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index 9b41d6f..a464642 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -967,6 +967,8 @@ struct drbd_tconn { /* is a resource from the config file */
struct drbd_conf *volume0; /* TODO: Remove me again */

struct net_conf *net_conf; /* protected by get_net_conf() and put_net_conf() */
+ atomic_t net_cnt; /* Users of net_conf */
+ wait_queue_head_t net_cnt_wait;
};

struct drbd_conf {
@@ -1012,7 +1014,6 @@ struct drbd_conf {
union drbd_state state;
wait_queue_head_t misc_wait;
wait_queue_head_t state_wait; /* upon each state change. */
- wait_queue_head_t net_cnt_wait;
unsigned int send_cnt;
unsigned int recv_cnt;
unsigned int read_cnt;
@@ -1024,7 +1025,7 @@ struct drbd_conf {
atomic_t rs_pending_cnt; /* RS request/data packets on the wire */
atomic_t unacked_cnt; /* Need to send replys for */
atomic_t local_cnt; /* Waiting for local completion */
- atomic_t net_cnt; /* Users of net_conf */
+
spinlock_t req_lock;
struct drbd_tl_epoch *unused_spare_tle; /* for pre-allocation */
struct drbd_tl_epoch *newest_tle;
@@ -2126,10 +2127,10 @@ static inline void inc_unacked(struct drbd_conf *mdev)
ERR_IF_CNT_IS_NEGATIVE(unacked_cnt); } while (0)


-static inline void put_net_conf(struct drbd_conf *mdev)
+static inline void put_net_conf(struct drbd_tconn *tconn)
{
- if (atomic_dec_and_test(&mdev->net_cnt))
- wake_up(&mdev->net_cnt_wait);
+ if (atomic_dec_and_test(&tconn->net_cnt))
+ wake_up(&tconn->net_cnt_wait);
}

/**
@@ -2138,14 +2139,14 @@ static inline void put_net_conf(struct drbd_conf *mdev)
*
* You have to call put_net_conf() when finished working with mdev->tconn->net_conf.
*/
-static inline int get_net_conf(struct drbd_conf *mdev)
+static inline int get_net_conf(struct drbd_tconn *tconn)
{
int have_net_conf;

- atomic_inc(&mdev->net_cnt);
- have_net_conf = mdev->state.conn >= C_UNCONNECTED;
+ atomic_inc(&tconn->net_cnt);
+ have_net_conf = tconn->volume0->state.conn >= C_UNCONNECTED;
if (!have_net_conf)
- put_net_conf(mdev);
+ put_net_conf(tconn);
return have_net_conf;
}

@@ -2251,9 +2252,9 @@ static inline void drbd_get_syncer_progress(struct drbd_conf *mdev,
static inline int drbd_get_max_buffers(struct drbd_conf *mdev)
{
int mxb = 1000000; /* arbitrary limit on open requests */
- if (get_net_conf(mdev)) {
+ if (get_net_conf(mdev->tconn)) {
mxb = mdev->tconn->net_conf->max_buffers;
- put_net_conf(mdev);
+ put_net_conf(mdev->tconn);
}
return mxb;
}
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index 7e88a49..9a77a9b 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -692,11 +692,11 @@ is_valid_state(struct drbd_conf *mdev, union drbd_state ns)
put_ldev(mdev);
}

- if (get_net_conf(mdev)) {
+ if (get_net_conf(mdev->tconn)) {
if (!mdev->tconn->net_conf->two_primaries &&
ns.role == R_PRIMARY && ns.peer == R_PRIMARY)
rv = SS_TWO_PRIMARIES;
- put_net_conf(mdev);
+ put_net_conf(mdev->tconn);
}

if (rv <= 0)
@@ -2972,7 +2972,6 @@ void drbd_init_set_defaults(struct drbd_conf *mdev)
atomic_set(&mdev->rs_pending_cnt, 0);
atomic_set(&mdev->unacked_cnt, 0);
atomic_set(&mdev->local_cnt, 0);
- atomic_set(&mdev->net_cnt, 0);
atomic_set(&mdev->packet_seq, 0);
atomic_set(&mdev->pp_in_use, 0);
atomic_set(&mdev->pp_in_use_by_net, 0);
@@ -3031,7 +3030,6 @@ void drbd_init_set_defaults(struct drbd_conf *mdev)

init_waitqueue_head(&mdev->misc_wait);
init_waitqueue_head(&mdev->state_wait);
- init_waitqueue_head(&mdev->net_cnt_wait);
init_waitqueue_head(&mdev->ee_wait);
init_waitqueue_head(&mdev->al_wait);
init_waitqueue_head(&mdev->seq_wait);
@@ -3372,6 +3370,9 @@ struct drbd_tconn *drbd_new_tconn(char *name)
if (!tconn->name)
goto fail;

+ atomic_set(&tconn->net_cnt, 0);
+ init_waitqueue_head(&tconn->net_cnt_wait);
+
write_lock_irq(&global_state_lock);
list_add(&tconn->all_tconn, &drbd_tconns);
write_unlock_irq(&global_state_lock);
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index d816c61..a936d61 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -149,7 +149,7 @@ int drbd_khelper(struct drbd_conf *mdev, char *cmd)

snprintf(mb, 12, "minor-%d", mdev_to_minor(mdev));

- if (get_net_conf(mdev)) {
+ if (get_net_conf(mdev->tconn)) {
switch (((struct sockaddr *)mdev->tconn->net_conf->peer_addr)->sa_family) {
case AF_INET6:
afs = "ipv6";
@@ -169,7 +169,7 @@ int drbd_khelper(struct drbd_conf *mdev, char *cmd)
snprintf(af, 20, "DRBD_PEER_AF=%s", afs);
envp[3]=af;
envp[4]=ad;
- put_net_conf(mdev);
+ put_net_conf(mdev->tconn);
}

/* The helper may take some time.
@@ -409,9 +409,9 @@ drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force)
put_ldev(mdev);
}
} else {
- if (get_net_conf(mdev)) {
+ if (get_net_conf(mdev->tconn)) {
mdev->tconn->net_conf->want_lose = 0;
- put_net_conf(mdev);
+ put_net_conf(mdev->tconn);
}
set_disk_ro(mdev->vdisk, false);
if (get_ldev(mdev)) {
@@ -971,9 +971,9 @@ static int drbd_nl_disk_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp
goto fail;
}

- if (get_net_conf(mdev)) {
+ if (get_net_conf(mdev->tconn)) {
int prot = mdev->tconn->net_conf->wire_protocol;
- put_net_conf(mdev);
+ put_net_conf(mdev->tconn);
if (nbc->dc.fencing == FP_STONITH && prot == DRBD_PROT_A) {
retcode = ERR_STONITH_AND_PROT_A;
goto fail;
@@ -1438,7 +1438,7 @@ static int drbd_nl_net_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp,
odev = minor_to_mdev(i);
if (!odev || odev == mdev)
continue;
- if (get_net_conf(odev)) {
+ if (get_net_conf(odev->tconn)) {
taken_addr = (struct sockaddr *)&odev->tconn->net_conf->my_addr;
if (new_conf->my_addr_len == odev->tconn->net_conf->my_addr_len &&
!memcmp(new_my_addr, taken_addr, new_conf->my_addr_len))
@@ -1449,7 +1449,7 @@ static int drbd_nl_net_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp,
!memcmp(new_peer_addr, taken_addr, new_conf->peer_addr_len))
retcode = ERR_PEER_ADDR;

- put_net_conf(odev);
+ put_net_conf(odev->tconn);
if (retcode != NO_ERROR)
goto fail;
}
@@ -2050,9 +2050,9 @@ static int drbd_nl_get_config(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nl
put_ldev(mdev);
}

- if (get_net_conf(mdev)) {
+ if (get_net_conf(mdev->tconn)) {
tl = net_conf_to_tags(mdev, mdev->tconn->net_conf, tl);
- put_net_conf(mdev);
+ put_net_conf(mdev->tconn);
}
tl = syncer_conf_to_tags(mdev, &mdev->sync_conf, tl);

diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index e5e7dd1..8a01f27 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -578,7 +578,7 @@ static struct socket *drbd_try_connect(struct drbd_conf *mdev)
int err;
int disconnect_on_error = 1;

- if (!get_net_conf(mdev))
+ if (!get_net_conf(mdev->tconn))
return NULL;

what = "sock_create_kern";
@@ -644,7 +644,7 @@ out:
if (disconnect_on_error)
drbd_force_state(mdev, NS(conn, C_DISCONNECTING));
}
- put_net_conf(mdev);
+ put_net_conf(mdev->tconn);
return sock;
}

@@ -654,7 +654,7 @@ static struct socket *drbd_wait_for_connect(struct drbd_conf *mdev)
struct socket *s_estab = NULL, *s_listen;
const char *what;

- if (!get_net_conf(mdev))
+ if (!get_net_conf(mdev->tconn))
return NULL;

what = "sock_create_kern";
@@ -692,7 +692,7 @@ out:
drbd_force_state(mdev, NS(conn, C_DISCONNECTING));
}
}
- put_net_conf(mdev);
+ put_net_conf(mdev->tconn);

return s_estab;
}
@@ -3839,7 +3839,7 @@ static void drbd_disconnect(struct drbd_conf *mdev)
spin_unlock_irq(&mdev->req_lock);

if (os.conn == C_DISCONNECTING) {
- wait_event(mdev->net_cnt_wait, atomic_read(&mdev->net_cnt) == 0);
+ wait_event(mdev->tconn->net_cnt_wait, atomic_read(&mdev->tconn->net_cnt) == 0);

crypto_free_hash(mdev->cram_hmac_tfm);
mdev->cram_hmac_tfm = NULL;
@@ -4166,9 +4166,9 @@ int drbdd_init(struct drbd_thread *thi)
} while (h == 0);

if (h > 0) {
- if (get_net_conf(mdev)) {
+ if (get_net_conf(mdev->tconn)) {
drbdd(mdev);
- put_net_conf(mdev);
+ put_net_conf(mdev->tconn);
}
}

diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c
index 2b2662d..8f1e7db 100644
--- a/drivers/block/drbd/drbd_req.c
+++ b/drivers/block/drbd/drbd_req.c
@@ -323,7 +323,7 @@ static int _req_conflicts(struct drbd_request *req)

D_ASSERT(drbd_interval_empty(&req->i));

- if (!get_net_conf(mdev))
+ if (!get_net_conf(mdev->tconn))
return 0;

i = drbd_find_overlap(&mdev->write_requests, sector, size);
@@ -359,11 +359,11 @@ static int _req_conflicts(struct drbd_request *req)

/* this is like it should be, and what we expected.
* our users do behave after all... */
- put_net_conf(mdev);
+ put_net_conf(mdev->tconn);
return 0;

out_conflict:
- put_net_conf(mdev);
+ put_net_conf(mdev->tconn);
return 1;
}

@@ -1181,9 +1181,9 @@ void request_timer_fn(unsigned long data)
struct list_head *le;
unsigned long et = 0; /* effective timeout = ko_count * timeout */

- if (get_net_conf(mdev)) {
+ if (get_net_conf(mdev->tconn)) {
et = mdev->tconn->net_conf->timeout*HZ/10 * mdev->tconn->net_conf->ko_count;
- put_net_conf(mdev);
+ put_net_conf(mdev->tconn);
}
if (!et || mdev->state.conn < C_WF_REPORT_PARAMS)
return; /* Recurring timer stopped */
--
1.7.4.1


\
 
 \ /
  Last update: 2011-08-25 17:33    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site