Commit 89e58e75 authored by Philipp Reisner's avatar Philipp Reisner

drbd: moved net_conf from mdev to tconn

Besides moving the struct member, everything else is generated by:

sed -i -e 's/mdev->net_conf/mdev->tconn->net_conf/g' \
       -e 's/odev->net_conf/odev->tconn->net_conf/g' \
       *.[ch]
Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent 2111438b
......@@ -977,7 +977,6 @@ struct drbd_conf {
unsigned long flags;
/* configured by drbdsetup */
struct net_conf *net_conf; /* protected by get_net_conf() and put_net_conf() */
struct syncer_conf sync_conf;
struct drbd_backing_dev *ldev __protected_by(local);
......@@ -2134,10 +2133,10 @@ static inline void put_net_conf(struct drbd_conf *mdev)
}
/**
* get_net_conf() - Increase ref count on mdev->net_conf; Returns 0 if nothing there
* get_net_conf() - Increase ref count on mdev->tconn->net_conf; Returns 0 if nothing there
* @mdev: DRBD device.
*
* You have to call put_net_conf() when finished working with mdev->net_conf.
* 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)
{
......@@ -2253,7 +2252,7 @@ static inline int drbd_get_max_buffers(struct drbd_conf *mdev)
{
int mxb = 1000000; /* arbitrary limit on open requests */
if (get_net_conf(mdev)) {
mxb = mdev->net_conf->max_buffers;
mxb = mdev->tconn->net_conf->max_buffers;
put_net_conf(mdev);
}
return mxb;
......
......@@ -693,7 +693,7 @@ is_valid_state(struct drbd_conf *mdev, union drbd_state ns)
}
if (get_net_conf(mdev)) {
if (!mdev->net_conf->two_primaries &&
if (!mdev->tconn->net_conf->two_primaries &&
ns.role == R_PRIMARY && ns.peer == R_PRIMARY)
rv = SS_TWO_PRIMARIES;
put_net_conf(mdev);
......@@ -1952,7 +1952,7 @@ int drbd_send_protocol(struct drbd_conf *mdev)
size = sizeof(struct p_protocol);
if (mdev->agreed_pro_version >= 87)
size += strlen(mdev->net_conf->integrity_alg) + 1;
size += strlen(mdev->tconn->net_conf->integrity_alg) + 1;
/* we must not recurse into our own queue,
* as that is blocked during handshake */
......@@ -1960,16 +1960,16 @@ int drbd_send_protocol(struct drbd_conf *mdev)
if (p == NULL)
return 0;
p->protocol = cpu_to_be32(mdev->net_conf->wire_protocol);
p->after_sb_0p = cpu_to_be32(mdev->net_conf->after_sb_0p);
p->after_sb_1p = cpu_to_be32(mdev->net_conf->after_sb_1p);
p->after_sb_2p = cpu_to_be32(mdev->net_conf->after_sb_2p);
p->two_primaries = cpu_to_be32(mdev->net_conf->two_primaries);
p->protocol = cpu_to_be32(mdev->tconn->net_conf->wire_protocol);
p->after_sb_0p = cpu_to_be32(mdev->tconn->net_conf->after_sb_0p);
p->after_sb_1p = cpu_to_be32(mdev->tconn->net_conf->after_sb_1p);
p->after_sb_2p = cpu_to_be32(mdev->tconn->net_conf->after_sb_2p);
p->two_primaries = cpu_to_be32(mdev->tconn->net_conf->two_primaries);
cf = 0;
if (mdev->net_conf->want_lose)
if (mdev->tconn->net_conf->want_lose)
cf |= CF_WANT_LOSE;
if (mdev->net_conf->dry_run) {
if (mdev->tconn->net_conf->dry_run) {
if (mdev->agreed_pro_version >= 92)
cf |= CF_DRY_RUN;
else {
......@@ -1981,7 +1981,7 @@ int drbd_send_protocol(struct drbd_conf *mdev)
p->conn_flags = cpu_to_be32(cf);
if (mdev->agreed_pro_version >= 87)
strcpy(p->integrity_alg, mdev->net_conf->integrity_alg);
strcpy(p->integrity_alg, mdev->tconn->net_conf->integrity_alg);
rv = drbd_send_cmd(mdev, USE_DATA_SOCKET, P_PROTOCOL,
(struct p_header80 *)p, size);
......@@ -2002,7 +2002,7 @@ int _drbd_send_uuids(struct drbd_conf *mdev, u64 uuid_flags)
mdev->comm_bm_set = drbd_bm_total_weight(mdev);
p.uuid[UI_SIZE] = cpu_to_be64(mdev->comm_bm_set);
uuid_flags |= mdev->net_conf->want_lose ? 1 : 0;
uuid_flags |= mdev->tconn->net_conf->want_lose ? 1 : 0;
uuid_flags |= test_bit(CRASHED_PRIMARY, &mdev->flags) ? 2 : 0;
uuid_flags |= mdev->new_state_tmp.disk == D_INCONSISTENT ? 4 : 0;
p.uuid[UI_FLAGS] = cpu_to_be64(uuid_flags);
......@@ -2717,7 +2717,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
* out ok after sending on this side, but does not fit on the
* receiving side, we sure have detected corruption elsewhere.
*/
if (mdev->net_conf->wire_protocol == DRBD_PROT_A || dgs)
if (mdev->tconn->net_conf->wire_protocol == DRBD_PROT_A || dgs)
ok = _drbd_send_bio(mdev, req->master_bio);
else
ok = _drbd_send_zc_bio(mdev, req->master_bio);
......@@ -2843,7 +2843,7 @@ int drbd_send(struct drbd_conf *mdev, struct socket *sock,
msg.msg_flags = msg_flags | MSG_NOSIGNAL;
if (sock == mdev->data.socket) {
mdev->ko_count = mdev->net_conf->ko_count;
mdev->ko_count = mdev->tconn->net_conf->ko_count;
drbd_update_congested(mdev);
}
do {
......@@ -3073,7 +3073,7 @@ void drbd_mdev_cleanup(struct drbd_conf *mdev)
mdev->rs_mark_left[i] = 0;
mdev->rs_mark_time[i] = 0;
}
D_ASSERT(mdev->net_conf == NULL);
D_ASSERT(mdev->tconn->net_conf == NULL);
drbd_set_my_capacity(mdev, 0);
if (mdev->bitmap) {
......
......@@ -150,21 +150,21 @@ int drbd_khelper(struct drbd_conf *mdev, char *cmd)
snprintf(mb, 12, "minor-%d", mdev_to_minor(mdev));
if (get_net_conf(mdev)) {
switch (((struct sockaddr *)mdev->net_conf->peer_addr)->sa_family) {
switch (((struct sockaddr *)mdev->tconn->net_conf->peer_addr)->sa_family) {
case AF_INET6:
afs = "ipv6";
snprintf(ad, 60, "DRBD_PEER_ADDRESS=%pI6",
&((struct sockaddr_in6 *)mdev->net_conf->peer_addr)->sin6_addr);
&((struct sockaddr_in6 *)mdev->tconn->net_conf->peer_addr)->sin6_addr);
break;
case AF_INET:
afs = "ipv4";
snprintf(ad, 60, "DRBD_PEER_ADDRESS=%pI4",
&((struct sockaddr_in *)mdev->net_conf->peer_addr)->sin_addr);
&((struct sockaddr_in *)mdev->tconn->net_conf->peer_addr)->sin_addr);
break;
default:
afs = "ssocks";
snprintf(ad, 60, "DRBD_PEER_ADDRESS=%pI4",
&((struct sockaddr_in *)mdev->net_conf->peer_addr)->sin_addr);
&((struct sockaddr_in *)mdev->tconn->net_conf->peer_addr)->sin_addr);
}
snprintf(af, 20, "DRBD_PEER_AF=%s", afs);
envp[3]=af;
......@@ -379,7 +379,7 @@ drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force)
if (rv == SS_TWO_PRIMARIES) {
/* Maybe the peer is detected as dead very soon...
retry at most once more in this case. */
schedule_timeout_interruptible((mdev->net_conf->ping_timeo+1)*HZ/10);
schedule_timeout_interruptible((mdev->tconn->net_conf->ping_timeo+1)*HZ/10);
if (try < max_tries)
try = max_tries - 1;
continue;
......@@ -410,7 +410,7 @@ drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force)
}
} else {
if (get_net_conf(mdev)) {
mdev->net_conf->want_lose = 0;
mdev->tconn->net_conf->want_lose = 0;
put_net_conf(mdev);
}
set_disk_ro(mdev->vdisk, false);
......@@ -972,7 +972,7 @@ static int drbd_nl_disk_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp
}
if (get_net_conf(mdev)) {
int prot = mdev->net_conf->wire_protocol;
int prot = mdev->tconn->net_conf->wire_protocol;
put_net_conf(mdev);
if (nbc->dc.fencing == FP_STONITH && prot == DRBD_PROT_A) {
retcode = ERR_STONITH_AND_PROT_A;
......@@ -1439,13 +1439,13 @@ static int drbd_nl_net_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp,
if (!odev || odev == mdev)
continue;
if (get_net_conf(odev)) {
taken_addr = (struct sockaddr *)&odev->net_conf->my_addr;
if (new_conf->my_addr_len == odev->net_conf->my_addr_len &&
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))
retcode = ERR_LOCAL_ADDR;
taken_addr = (struct sockaddr *)&odev->net_conf->peer_addr;
if (new_conf->peer_addr_len == odev->net_conf->peer_addr_len &&
taken_addr = (struct sockaddr *)&odev->tconn->net_conf->peer_addr;
if (new_conf->peer_addr_len == odev->tconn->net_conf->peer_addr_len &&
!memcmp(new_peer_addr, taken_addr, new_conf->peer_addr_len))
retcode = ERR_PEER_ADDR;
......@@ -1522,12 +1522,12 @@ static int drbd_nl_net_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp,
drbd_flush_workqueue(mdev);
spin_lock_irq(&mdev->req_lock);
if (mdev->net_conf != NULL) {
if (mdev->tconn->net_conf != NULL) {
retcode = ERR_NET_CONFIGURED;
spin_unlock_irq(&mdev->req_lock);
goto fail;
}
mdev->net_conf = new_conf;
mdev->tconn->net_conf = new_conf;
mdev->send_cnt = 0;
mdev->recv_cnt = 0;
......@@ -2051,7 +2051,7 @@ static int drbd_nl_get_config(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nl
}
if (get_net_conf(mdev)) {
tl = net_conf_to_tags(mdev, mdev->net_conf, tl);
tl = net_conf_to_tags(mdev, mdev->tconn->net_conf, tl);
put_net_conf(mdev);
}
tl = syncer_conf_to_tags(mdev, &mdev->sync_conf, tl);
......
......@@ -254,8 +254,8 @@ static int drbd_seq_show(struct seq_file *seq, void *v)
drbd_role_str(mdev->state.peer),
drbd_disk_str(mdev->state.disk),
drbd_disk_str(mdev->state.pdsk),
(mdev->net_conf == NULL ? ' ' :
(mdev->net_conf->wire_protocol - DRBD_PROT_A+'A')),
(mdev->tconn->net_conf == NULL ? ' ' :
(mdev->tconn->net_conf->wire_protocol - DRBD_PROT_A+'A')),
is_susp(mdev->state) ? 's' : 'r',
mdev->state.aftr_isp ? 'a' : '-',
mdev->state.peer_isp ? 'p' : '-',
......
This diff is collapsed.
......@@ -528,7 +528,7 @@ int __req_mod(struct drbd_request *req, enum drbd_req_event what,
drbd_queue_work(&mdev->data.work, &req->w);
/* close the epoch, in case it outgrew the limit */
if (mdev->newest_tle->n_writes >= mdev->net_conf->max_epoch_size)
if (mdev->newest_tle->n_writes >= mdev->tconn->net_conf->max_epoch_size)
queue_barrier(mdev);
break;
......@@ -558,7 +558,7 @@ int __req_mod(struct drbd_request *req, enum drbd_req_event what,
atomic_add(req->i.size >> 9, &mdev->ap_in_flight);
if (bio_data_dir(req->master_bio) == WRITE &&
mdev->net_conf->wire_protocol == DRBD_PROT_A) {
mdev->tconn->net_conf->wire_protocol == DRBD_PROT_A) {
/* this is what is dangerous about protocol A:
* pretend it was successfully written on the peer. */
if (req->rq_state & RQ_NET_PENDING) {
......@@ -697,8 +697,8 @@ int __req_mod(struct drbd_request *req, enum drbd_req_event what,
}
if ((req->rq_state & RQ_NET_MASK) != 0) {
req->rq_state |= RQ_NET_DONE;
if (mdev->net_conf->wire_protocol == DRBD_PROT_A)
atomic_sub(req->i.size >> 9, &mdev->ap_in_flight);
if (mdev->tconn->net_conf->wire_protocol == DRBD_PROT_A)
atomic_sub(req->i.size>>9, &mdev->ap_in_flight);
}
_req_may_be_done(req, m); /* Allowed while state.susp */
break;
......@@ -951,16 +951,16 @@ static int drbd_make_request_common(struct drbd_conf *mdev, struct bio *bio, uns
_req_mod(req, QUEUE_FOR_SEND_OOS);
if (remote &&
mdev->net_conf->on_congestion != OC_BLOCK && mdev->agreed_pro_version >= 96) {
mdev->tconn->net_conf->on_congestion != OC_BLOCK && mdev->agreed_pro_version >= 96) {
int congested = 0;
if (mdev->net_conf->cong_fill &&
atomic_read(&mdev->ap_in_flight) >= mdev->net_conf->cong_fill) {
if (mdev->tconn->net_conf->cong_fill &&
atomic_read(&mdev->ap_in_flight) >= mdev->tconn->net_conf->cong_fill) {
dev_info(DEV, "Congestion-fill threshold reached\n");
congested = 1;
}
if (mdev->act_log->used >= mdev->net_conf->cong_extents) {
if (mdev->act_log->used >= mdev->tconn->net_conf->cong_extents) {
dev_info(DEV, "Congestion-extents threshold reached\n");
congested = 1;
}
......@@ -968,9 +968,9 @@ static int drbd_make_request_common(struct drbd_conf *mdev, struct bio *bio, uns
if (congested) {
queue_barrier(mdev); /* last barrier, after mirrored writes */
if (mdev->net_conf->on_congestion == OC_PULL_AHEAD)
if (mdev->tconn->net_conf->on_congestion == OC_PULL_AHEAD)
_drbd_set_state(_NS(mdev, conn, C_AHEAD), 0, NULL);
else /*mdev->net_conf->on_congestion == OC_DISCONNECT */
else /*mdev->tconn->net_conf->on_congestion == OC_DISCONNECT */
_drbd_set_state(_NS(mdev, conn, C_DISCONNECTING), 0, NULL);
}
}
......@@ -1182,7 +1182,7 @@ void request_timer_fn(unsigned long data)
unsigned long et = 0; /* effective timeout = ko_count * timeout */
if (get_net_conf(mdev)) {
et = mdev->net_conf->timeout*HZ/10 * mdev->net_conf->ko_count;
et = mdev->tconn->net_conf->timeout*HZ/10 * mdev->tconn->net_conf->ko_count;
put_net_conf(mdev);
}
if (!et || mdev->state.conn < C_WF_REPORT_PARAMS)
......
......@@ -1590,8 +1590,8 @@ void drbd_start_resync(struct drbd_conf *mdev, enum drbd_conns side)
* the race considerably, but does not solve it. */
if (side == C_SYNC_SOURCE)
schedule_timeout_interruptible(
mdev->net_conf->ping_int * HZ +
mdev->net_conf->ping_timeo*HZ/9);
mdev->tconn->net_conf->ping_int * HZ +
mdev->tconn->net_conf->ping_timeo*HZ/9);
drbd_resync_finished(mdev);
}
......@@ -1623,14 +1623,14 @@ int drbd_worker(struct drbd_thread *thi)
if (down_trylock(&mdev->data.work.s)) {
mutex_lock(&mdev->data.mutex);
if (mdev->data.socket && !mdev->net_conf->no_cork)
if (mdev->data.socket && !mdev->tconn->net_conf->no_cork)
drbd_tcp_uncork(mdev->data.socket);
mutex_unlock(&mdev->data.mutex);
intr = down_interruptible(&mdev->data.work.s);
mutex_lock(&mdev->data.mutex);
if (mdev->data.socket && !mdev->net_conf->no_cork)
if (mdev->data.socket && !mdev->tconn->net_conf->no_cork)
drbd_tcp_cork(mdev->data.socket);
mutex_unlock(&mdev->data.mutex);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment