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 {
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;
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;
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);
}
/**
*
* 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;
}
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;
}
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)
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);
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);
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);
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";
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.
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)) {
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;
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))
!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;
}
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);
int err;
int disconnect_on_error = 1;
- if (!get_net_conf(mdev))
+ if (!get_net_conf(mdev->tconn))
return NULL;
what = "sock_create_kern";
if (disconnect_on_error)
drbd_force_state(mdev, NS(conn, C_DISCONNECTING));
}
- put_net_conf(mdev);
+ put_net_conf(mdev->tconn);
return sock;
}
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";
drbd_force_state(mdev, NS(conn, C_DISCONNECTING));
}
}
- put_net_conf(mdev);
+ put_net_conf(mdev->tconn);
return s_estab;
}
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;
} 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);
}
}
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);
/* 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;
}
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 */