al_work.enr = enr;
al_work.old_enr = al_ext->lc_number;
al_work.w.cb = w_al_write_transaction;
- drbd_queue_work_front(&mdev->data.work, &al_work.w);
+ drbd_queue_work_front(&mdev->tconn->data.work, &al_work.w);
wait_for_completion(&al_work.event);
mdev->al_writ_cnt++;
if (udw) {
udw->enr = ext->lce.lc_number;
udw->w.cb = w_update_odbm;
- drbd_queue_work_front(&mdev->data.work, &udw->w);
+ drbd_queue_work_front(&mdev->tconn->data.work, &udw->w);
} else {
dev_warn(DEV, "Could not kmalloc an udw\n");
}
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_socket data; /* data/barrier/cstate/parameter packets */
+ struct drbd_socket meta; /* ping/ack (metadata) packets */
};
struct drbd_conf {
struct block_device *this_bdev;
struct gendisk *vdisk;
- struct drbd_socket data; /* data/barrier/cstate/parameter packets */
- struct drbd_socket meta; /* ping/ack (metadata) packets */
int agreed_pro_version; /* actually used protocol version */
unsigned long last_received; /* in jiffies, either socket */
unsigned int ko_count;
*/
static inline int drbd_get_data_sock(struct drbd_conf *mdev)
{
- mutex_lock(&mdev->data.mutex);
+ mutex_lock(&mdev->tconn->data.mutex);
/* drbd_disconnect() could have called drbd_free_sock()
* while we were waiting in down()... */
- if (unlikely(mdev->data.socket == NULL)) {
- mutex_unlock(&mdev->data.mutex);
+ if (unlikely(mdev->tconn->data.socket == NULL)) {
+ mutex_unlock(&mdev->tconn->data.mutex);
return 0;
}
return 1;
static inline void drbd_put_data_sock(struct drbd_conf *mdev)
{
- mutex_unlock(&mdev->data.mutex);
+ mutex_unlock(&mdev->tconn->data.mutex);
}
/*
wake_up(&mdev->misc_wait);
if (ap_bio == 0 && test_bit(BITMAP_IO, &mdev->flags)) {
if (!test_and_set_bit(BITMAP_IO_QUEUED, &mdev->flags))
- drbd_queue_work(&mdev->data.work, &mdev->bm_io_work.w);
+ drbd_queue_work(&mdev->tconn->data.work, &mdev->bm_io_work.w);
}
}
static inline void drbd_update_congested(struct drbd_conf *mdev)
{
- struct sock *sk = mdev->data.socket->sk;
+ struct sock *sk = mdev->tconn->data.socket->sk;
if (sk->sk_wmem_queued > sk->sk_sndbuf * 4 / 5)
set_bit(NET_CONGESTED, &mdev->flags);
}
set_bit(CREATE_BARRIER, &mdev->flags);
}
- drbd_queue_work(&mdev->data.work, &b->w);
+ drbd_queue_work(&mdev->tconn->data.work, &b->w);
}
pn = &b->next;
} else {
ascw->flags = flags;
ascw->w.cb = w_after_state_ch;
ascw->done = done;
- drbd_queue_work(&mdev->data.work, &ascw->w);
+ drbd_queue_work(&mdev->tconn->data.work, &ascw->w);
} else {
dev_warn(DEV, "Could not kmalloc an ascw\n");
}
struct socket *sock;
if (use_data_socket) {
- mutex_lock(&mdev->data.mutex);
- sock = mdev->data.socket;
+ mutex_lock(&mdev->tconn->data.mutex);
+ sock = mdev->tconn->data.socket;
} else {
- mutex_lock(&mdev->meta.mutex);
- sock = mdev->meta.socket;
+ mutex_lock(&mdev->tconn->meta.mutex);
+ sock = mdev->tconn->meta.socket;
}
/* drbd_disconnect() could have called drbd_free_sock()
ok = _drbd_send_cmd(mdev, sock, cmd, h, size, 0);
if (use_data_socket)
- mutex_unlock(&mdev->data.mutex);
+ mutex_unlock(&mdev->tconn->data.mutex);
else
- mutex_unlock(&mdev->meta.mutex);
+ mutex_unlock(&mdev->tconn->meta.mutex);
return ok;
}
return 0;
ok = (sizeof(h) ==
- drbd_send(mdev, mdev->data.socket, &h, sizeof(h), 0));
+ drbd_send(mdev, mdev->tconn->data.socket, &h, sizeof(h), 0));
ok = ok && (size ==
- drbd_send(mdev, mdev->data.socket, data, size, 0));
+ drbd_send(mdev, mdev->tconn->data.socket, data, size, 0));
drbd_put_data_sock(mdev);
/* used from admin command context and receiver/worker context.
* to avoid kmalloc, grab the socket right here,
* then use the pre-allocated sbuf there */
- mutex_lock(&mdev->data.mutex);
- sock = mdev->data.socket;
+ mutex_lock(&mdev->tconn->data.mutex);
+ sock = mdev->tconn->data.socket;
if (likely(sock != NULL)) {
enum drbd_packets cmd = apv >= 89 ? P_SYNC_PARAM89 : P_SYNC_PARAM;
- p = &mdev->data.sbuf.rs_param_95;
+ p = &mdev->tconn->data.sbuf.rs_param_95;
/* initialize verify_alg and csums_alg */
memset(p->verify_alg, 0, 2 * SHARED_SECRET_MAX);
} else
rv = 0; /* not ok */
- mutex_unlock(&mdev->data.mutex);
+ mutex_unlock(&mdev->tconn->data.mutex);
return rv;
}
* of a cluster wide state change on another thread */
drbd_state_lock(mdev);
- mutex_lock(&mdev->data.mutex);
+ mutex_lock(&mdev->tconn->data.mutex);
p.state = cpu_to_be32(mdev->state.i); /* Within the send mutex */
- sock = mdev->data.socket;
+ sock = mdev->tconn->data.socket;
if (likely(sock != NULL)) {
ok = _drbd_send_cmd(mdev, sock, P_STATE,
(struct p_header80 *)&p, sizeof(p), 0);
}
- mutex_unlock(&mdev->data.mutex);
+ mutex_unlock(&mdev->tconn->data.mutex);
drbd_state_unlock(mdev);
return ok;
if (len) {
DCBP_set_code(p, RLE_VLI_Bits);
- ok = _drbd_send_cmd(mdev, mdev->data.socket, P_COMPRESSED_BITMAP, h,
+ ok = _drbd_send_cmd(mdev, mdev->tconn->data.socket, P_COMPRESSED_BITMAP, h,
sizeof(*p) + len, 0);
c->packets[0]++;
len = num_words * sizeof(long);
if (len)
drbd_bm_get_lel(mdev, c->word_offset, num_words, (unsigned long*)h->payload);
- ok = _drbd_send_cmd(mdev, mdev->data.socket, P_BITMAP,
+ ok = _drbd_send_cmd(mdev, mdev->tconn->data.socket, P_BITMAP,
h, sizeof(struct p_header80) + len, 0);
c->word_offset += num_words;
c->bit_offset = c->word_offset * BITS_PER_LONG;
p.blksize = blksize;
p.seq_num = cpu_to_be32(atomic_add_return(1, &mdev->packet_seq));
- if (!mdev->meta.socket || mdev->state.conn < C_CONNECTED)
+ if (!mdev->tconn->meta.socket || mdev->state.conn < C_CONNECTED)
return false;
ok = drbd_send_cmd(mdev, USE_META_SOCKET, cmd,
(struct p_header80 *)&p, sizeof(p));
p.head.command = cpu_to_be16(cmd);
p.head.length = cpu_to_be16(sizeof(p) - sizeof(struct p_header80) + digest_size);
- mutex_lock(&mdev->data.mutex);
+ mutex_lock(&mdev->tconn->data.mutex);
- ok = (sizeof(p) == drbd_send(mdev, mdev->data.socket, &p, sizeof(p), 0));
- ok = ok && (digest_size == drbd_send(mdev, mdev->data.socket, digest, digest_size, 0));
+ ok = (sizeof(p) == drbd_send(mdev, mdev->tconn->data.socket, &p, sizeof(p), 0));
+ ok = ok && (digest_size == drbd_send(mdev, mdev->tconn->data.socket, digest, digest_size, 0));
- mutex_unlock(&mdev->data.mutex);
+ mutex_unlock(&mdev->tconn->data.mutex);
return ok;
}
int drop_it;
/* long elapsed = (long)(jiffies - mdev->last_received); */
- drop_it = mdev->meta.socket == sock
+ drop_it = mdev->tconn->meta.socket == sock
|| !mdev->asender.task
|| get_t_state(&mdev->asender) != RUNNING
|| mdev->state.conn < C_CONNECTED;
static int _drbd_no_send_page(struct drbd_conf *mdev, struct page *page,
int offset, size_t size, unsigned msg_flags)
{
- int sent = drbd_send(mdev, mdev->data.socket, kmap(page) + offset, size, msg_flags);
+ int sent = drbd_send(mdev, mdev->tconn->data.socket, kmap(page) + offset, size, msg_flags);
kunmap(page);
if (sent == size)
mdev->send_cnt += size>>9;
drbd_update_congested(mdev);
set_fs(KERNEL_DS);
do {
- sent = mdev->data.socket->ops->sendpage(mdev->data.socket, page,
+ sent = mdev->tconn->data.socket->ops->sendpage(mdev->tconn->data.socket, page,
offset, len,
msg_flags);
if (sent == -EAGAIN) {
if (we_should_drop_the_connection(mdev,
- mdev->data.socket))
+ mdev->tconn->data.socket))
break;
else
continue;
p.dp_flags = cpu_to_be32(dp_flags);
set_bit(UNPLUG_REMOTE, &mdev->flags);
ok = (sizeof(p) ==
- drbd_send(mdev, mdev->data.socket, &p, sizeof(p), dgs ? MSG_MORE : 0));
+ drbd_send(mdev, mdev->tconn->data.socket, &p, sizeof(p), dgs ? MSG_MORE : 0));
if (ok && dgs) {
dgb = mdev->int_dig_out;
drbd_csum_bio(mdev, mdev->integrity_w_tfm, req->master_bio, dgb);
- ok = dgs == drbd_send(mdev, mdev->data.socket, dgb, dgs, 0);
+ ok = dgs == drbd_send(mdev, mdev->tconn->data.socket, dgb, dgs, 0);
}
if (ok) {
/* For protocol A, we have to memcpy the payload into
if (!drbd_get_data_sock(mdev))
return 0;
- ok = sizeof(p) == drbd_send(mdev, mdev->data.socket, &p, sizeof(p), dgs ? MSG_MORE : 0);
+ ok = sizeof(p) == drbd_send(mdev, mdev->tconn->data.socket, &p, sizeof(p), dgs ? MSG_MORE : 0);
if (ok && dgs) {
dgb = mdev->int_dig_out;
drbd_csum_ee(mdev, mdev->integrity_w_tfm, e, dgb);
- ok = dgs == drbd_send(mdev, mdev->data.socket, dgb, dgs, 0);
+ ok = dgs == drbd_send(mdev, mdev->tconn->data.socket, dgb, dgs, 0);
}
if (ok)
ok = _drbd_send_zc_ee(mdev, e);
msg.msg_controllen = 0;
msg.msg_flags = msg_flags | MSG_NOSIGNAL;
- if (sock == mdev->data.socket) {
+ if (sock == mdev->tconn->data.socket) {
mdev->ko_count = mdev->tconn->net_conf->ko_count;
drbd_update_congested(mdev);
}
iov.iov_len -= rv;
} while (sent < size);
- if (sock == mdev->data.socket)
+ if (sock == mdev->tconn->data.socket)
clear_bit(NET_CONGESTED, &mdev->flags);
if (rv <= 0) {
if (rv != -EAGAIN) {
dev_err(DEV, "%s_sendmsg returned %d\n",
- sock == mdev->meta.socket ? "msock" : "sock",
+ sock == mdev->tconn->meta.socket ? "msock" : "sock",
rv);
drbd_force_state(mdev, NS(conn, C_BROKEN_PIPE));
} else
atomic_set(&mdev->ap_in_flight, 0);
mutex_init(&mdev->md_io_mutex);
- mutex_init(&mdev->data.mutex);
- mutex_init(&mdev->meta.mutex);
- sema_init(&mdev->data.work.s, 0);
- sema_init(&mdev->meta.work.s, 0);
+ mutex_init(&mdev->tconn->data.mutex);
+ mutex_init(&mdev->tconn->meta.mutex);
+ sema_init(&mdev->tconn->data.work.s, 0);
+ sema_init(&mdev->tconn->meta.work.s, 0);
mutex_init(&mdev->state_mutex);
- spin_lock_init(&mdev->data.work.q_lock);
- spin_lock_init(&mdev->meta.work.q_lock);
+ spin_lock_init(&mdev->tconn->data.work.q_lock);
+ spin_lock_init(&mdev->tconn->meta.work.q_lock);
spin_lock_init(&mdev->al_lock);
spin_lock_init(&mdev->req_lock);
INIT_LIST_HEAD(&mdev->read_ee);
INIT_LIST_HEAD(&mdev->net_ee);
INIT_LIST_HEAD(&mdev->resync_reads);
- INIT_LIST_HEAD(&mdev->data.work.q);
- INIT_LIST_HEAD(&mdev->meta.work.q);
+ INIT_LIST_HEAD(&mdev->tconn->data.work.q);
+ INIT_LIST_HEAD(&mdev->tconn->meta.work.q);
INIT_LIST_HEAD(&mdev->resync_work.list);
INIT_LIST_HEAD(&mdev->unplug_work.list);
INIT_LIST_HEAD(&mdev->go_diskless.list);
D_ASSERT(list_empty(&mdev->read_ee));
D_ASSERT(list_empty(&mdev->net_ee));
D_ASSERT(list_empty(&mdev->resync_reads));
- D_ASSERT(list_empty(&mdev->data.work.q));
- D_ASSERT(list_empty(&mdev->meta.work.q));
+ D_ASSERT(list_empty(&mdev->tconn->data.work.q));
+ D_ASSERT(list_empty(&mdev->tconn->meta.work.q));
D_ASSERT(list_empty(&mdev->resync_work.list));
D_ASSERT(list_empty(&mdev->unplug_work.list));
D_ASSERT(list_empty(&mdev->go_diskless.list));
/* paranoia asserts */
D_ASSERT(mdev->open_cnt == 0);
- D_ASSERT(list_empty(&mdev->data.work.q));
+ D_ASSERT(list_empty(&mdev->tconn->data.work.q));
/* end paranoia asserts */
del_gendisk(mdev->vdisk);
void drbd_free_sock(struct drbd_conf *mdev)
{
- if (mdev->data.socket) {
- mutex_lock(&mdev->data.mutex);
- kernel_sock_shutdown(mdev->data.socket, SHUT_RDWR);
- sock_release(mdev->data.socket);
- mdev->data.socket = NULL;
- mutex_unlock(&mdev->data.mutex);
+ if (mdev->tconn->data.socket) {
+ mutex_lock(&mdev->tconn->data.mutex);
+ kernel_sock_shutdown(mdev->tconn->data.socket, SHUT_RDWR);
+ sock_release(mdev->tconn->data.socket);
+ mdev->tconn->data.socket = NULL;
+ mutex_unlock(&mdev->tconn->data.mutex);
}
- if (mdev->meta.socket) {
- mutex_lock(&mdev->meta.mutex);
- kernel_sock_shutdown(mdev->meta.socket, SHUT_RDWR);
- sock_release(mdev->meta.socket);
- mdev->meta.socket = NULL;
- mutex_unlock(&mdev->meta.mutex);
+ if (mdev->tconn->meta.socket) {
+ mutex_lock(&mdev->tconn->meta.mutex);
+ kernel_sock_shutdown(mdev->tconn->meta.socket, SHUT_RDWR);
+ sock_release(mdev->tconn->meta.socket);
+ mdev->tconn->meta.socket = NULL;
+ mutex_unlock(&mdev->tconn->meta.mutex);
}
}
{
D_ASSERT(mdev->state.disk == D_FAILED);
if (!test_and_set_bit(GO_DISKLESS, &mdev->flags))
- drbd_queue_work(&mdev->data.work, &mdev->go_diskless);
+ drbd_queue_work(&mdev->tconn->data.work, &mdev->go_diskless);
}
/**
set_bit(BITMAP_IO, &mdev->flags);
if (atomic_read(&mdev->ap_bio_cnt) == 0) {
if (!test_and_set_bit(BITMAP_IO_QUEUED, &mdev->flags))
- drbd_queue_work(&mdev->data.work, &mdev->bm_io_work.w);
+ drbd_queue_work(&mdev->tconn->data.work, &mdev->bm_io_work.w);
}
spin_unlock_irq(&mdev->req_lock);
}
{
struct drbd_conf *mdev = (struct drbd_conf *) data;
- drbd_queue_work_front(&mdev->data.work, &mdev->md_sync_work);
+ drbd_queue_work_front(&mdev->tconn->data.work, &mdev->md_sync_work);
}
static int w_md_sync(struct drbd_conf *mdev, struct drbd_work *w, int unused)
set_fs(KERNEL_DS);
for (;;) {
- rv = sock_recvmsg(mdev->data.socket, &msg, size, msg.msg_flags);
+ rv = sock_recvmsg(mdev->tconn->data.socket, &msg, size, msg.msg_flags);
if (rv == size)
break;
static int drbd_send_fp(struct drbd_conf *mdev,
struct socket *sock, enum drbd_packets cmd)
{
- struct p_header80 *h = &mdev->data.sbuf.header.h80;
+ struct p_header80 *h = &mdev->tconn->data.sbuf.header.h80;
return _drbd_send_cmd(mdev, sock, cmd, h, sizeof(*h), 0);
}
static enum drbd_packets drbd_recv_fp(struct drbd_conf *mdev, struct socket *sock)
{
- struct p_header80 *h = &mdev->data.rbuf.header.h80;
+ struct p_header80 *h = &mdev->tconn->data.rbuf.header.h80;
int rr;
rr = drbd_recv_short(mdev, sock, h, sizeof(*h), 0);
struct socket *s, *sock, *msock;
int try, h, ok;
- D_ASSERT(!mdev->data.socket);
+ D_ASSERT(!mdev->tconn->data.socket);
if (drbd_request_state(mdev, NS(conn, C_WF_CONNECTION)) < SS_SUCCESS)
return -2;
drbd_tcp_nodelay(sock);
drbd_tcp_nodelay(msock);
- mdev->data.socket = sock;
- mdev->meta.socket = msock;
+ mdev->tconn->data.socket = sock;
+ mdev->tconn->meta.socket = msock;
mdev->last_received = jiffies;
D_ASSERT(mdev->asender.task == NULL);
static int drbd_recv_header(struct drbd_conf *mdev, enum drbd_packets *cmd, unsigned int *packet_size)
{
- union p_header *h = &mdev->data.rbuf.header;
+ union p_header *h = &mdev->tconn->data.rbuf.header;
int r;
r = drbd_recv(mdev, h, sizeof(*h));
static int receive_Barrier(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size)
{
int rv;
- struct p_barrier *p = &mdev->data.rbuf.barrier;
+ struct p_barrier *p = &mdev->tconn->data.rbuf.barrier;
struct drbd_epoch *epoch;
inc_unacked(mdev);
struct drbd_request *req;
sector_t sector;
int ok;
- struct p_data *p = &mdev->data.rbuf.data;
+ struct p_data *p = &mdev->tconn->data.rbuf.data;
sector = be64_to_cpu(p->sector);
{
sector_t sector;
int ok;
- struct p_data *p = &mdev->data.rbuf.data;
+ struct p_data *p = &mdev->tconn->data.rbuf.data;
sector = be64_to_cpu(p->sector);
D_ASSERT(p->block_id == ID_SYNCER);
{
sector_t sector;
struct drbd_epoch_entry *e;
- struct p_data *p = &mdev->data.rbuf.data;
+ struct p_data *p = &mdev->tconn->data.rbuf.data;
int rw = WRITE;
u32 dp_flags;
struct digest_info *di = NULL;
int size, verb;
unsigned int fault_type;
- struct p_block_req *p = &mdev->data.rbuf.block_req;
+ struct p_block_req *p = &mdev->tconn->data.rbuf.block_req;
sector = be64_to_cpu(p->sector);
size = be32_to_cpu(p->blksize);
static int receive_protocol(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size)
{
- struct p_protocol *p = &mdev->data.rbuf.protocol;
+ struct p_protocol *p = &mdev->tconn->data.rbuf.protocol;
int p_proto, p_after_sb_0p, p_after_sb_1p, p_after_sb_2p;
int p_want_lose, p_two_primaries, cf;
char p_integrity_alg[SHARED_SECRET_MAX] = "";
static int receive_SyncParam(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int packet_size)
{
int ok = true;
- struct p_rs_param_95 *p = &mdev->data.rbuf.rs_param_95;
+ struct p_rs_param_95 *p = &mdev->tconn->data.rbuf.rs_param_95;
unsigned int header_size, data_size, exp_max_sz;
struct crypto_hash *verify_tfm = NULL;
struct crypto_hash *csums_tfm = NULL;
static int receive_sizes(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size)
{
- struct p_sizes *p = &mdev->data.rbuf.sizes;
+ struct p_sizes *p = &mdev->tconn->data.rbuf.sizes;
enum determine_dev_size dd = unchanged;
sector_t p_size, p_usize, my_usize;
int ldsc = 0; /* local disk size changed */
static int receive_uuids(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size)
{
- struct p_uuids *p = &mdev->data.rbuf.uuids;
+ struct p_uuids *p = &mdev->tconn->data.rbuf.uuids;
u64 *p_uuid;
int i, updated_uuids = 0;
static int receive_req_state(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size)
{
- struct p_req_state *p = &mdev->data.rbuf.req_state;
+ struct p_req_state *p = &mdev->tconn->data.rbuf.req_state;
union drbd_state mask, val;
enum drbd_state_rv rv;
static int receive_state(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size)
{
- struct p_state *p = &mdev->data.rbuf.state;
+ struct p_state *p = &mdev->tconn->data.rbuf.state;
union drbd_state os, ns, peer_state;
enum drbd_disk_state real_peer_disk;
enum chg_state_flags cs_flags;
static int receive_sync_uuid(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size)
{
- struct p_rs_uuid *p = &mdev->data.rbuf.rs_uuid;
+ struct p_rs_uuid *p = &mdev->tconn->data.rbuf.rs_uuid;
wait_event(mdev->misc_wait,
mdev->state.conn == C_WF_SYNC_UUID ||
void *buffer;
int err;
int ok = false;
- struct p_header80 *h = &mdev->data.rbuf.header.h80;
+ struct p_header80 *h = &mdev->tconn->data.rbuf.header.h80;
drbd_bm_lock(mdev, "receive bitmap", BM_LOCKED_SET_ALLOWED);
/* you are supposed to send additional out-of-sync information
{
/* Make sure we've acked all the TCP data associated
* with the data requests being unplugged */
- drbd_tcp_quickack(mdev->data.socket);
+ drbd_tcp_quickack(mdev->tconn->data.socket);
return true;
}
static int receive_out_of_sync(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size)
{
- struct p_block_desc *p = &mdev->data.rbuf.block_desc;
+ struct p_block_desc *p = &mdev->tconn->data.rbuf.block_desc;
switch (mdev->state.conn) {
case C_WF_SYNC_UUID:
};
/* All handler functions that expect a sub-header get that sub-heder in
- mdev->data.rbuf.header.head.payload.
+ mdev->tconn->data.rbuf.header.head.payload.
- Usually in mdev->data.rbuf.header.head the callback can find the usual
+ Usually in mdev->tconn->data.rbuf.header.head the callback can find the usual
p_header, but they may not rely on that. Since there is also p_header95 !
*/
static void drbdd(struct drbd_conf *mdev)
{
- union p_header *header = &mdev->data.rbuf.header;
+ union p_header *header = &mdev->tconn->data.rbuf.header;
unsigned int packet_size;
enum drbd_packets cmd;
size_t shs; /* sub header size */
barr.w.cb = w_prev_work_done;
init_completion(&barr.done);
- drbd_queue_work(&mdev->data.work, &barr.w);
+ drbd_queue_work(&mdev->tconn->data.work, &barr.w);
wait_for_completion(&barr.done);
}
static int drbd_send_handshake(struct drbd_conf *mdev)
{
/* ASSERT current == mdev->receiver ... */
- struct p_handshake *p = &mdev->data.sbuf.handshake;
+ struct p_handshake *p = &mdev->tconn->data.sbuf.handshake;
int ok;
- if (mutex_lock_interruptible(&mdev->data.mutex)) {
+ if (mutex_lock_interruptible(&mdev->tconn->data.mutex)) {
dev_err(DEV, "interrupted during initial handshake\n");
return 0; /* interrupted. not ok. */
}
- if (mdev->data.socket == NULL) {
- mutex_unlock(&mdev->data.mutex);
+ if (mdev->tconn->data.socket == NULL) {
+ mutex_unlock(&mdev->tconn->data.mutex);
return 0;
}
memset(p, 0, sizeof(*p));
p->protocol_min = cpu_to_be32(PRO_VERSION_MIN);
p->protocol_max = cpu_to_be32(PRO_VERSION_MAX);
- ok = _drbd_send_cmd( mdev, mdev->data.socket, P_HAND_SHAKE,
+ ok = _drbd_send_cmd( mdev, mdev->tconn->data.socket, P_HAND_SHAKE,
(struct p_header80 *)p, sizeof(*p), 0 );
- mutex_unlock(&mdev->data.mutex);
+ mutex_unlock(&mdev->tconn->data.mutex);
return ok;
}
static int drbd_do_handshake(struct drbd_conf *mdev)
{
/* ASSERT current == mdev->receiver ... */
- struct p_handshake *p = &mdev->data.rbuf.handshake;
+ struct p_handshake *p = &mdev->tconn->data.rbuf.handshake;
const int expect = sizeof(struct p_handshake) - sizeof(struct p_header80);
unsigned int length;
enum drbd_packets cmd;
static int got_PingAck(struct drbd_conf *mdev, struct p_header80 *h)
{
/* restore idle timeout */
- mdev->meta.socket->sk->sk_rcvtimeo = mdev->tconn->net_conf->ping_int*HZ;
+ mdev->tconn->meta.socket->sk->sk_rcvtimeo = mdev->tconn->net_conf->ping_int*HZ;
if (!test_and_set_bit(GOT_PING_ACK, &mdev->flags))
wake_up(&mdev->misc_wait);
w = kmalloc(sizeof(*w), GFP_NOIO);
if (w) {
w->cb = w_ov_finished;
- drbd_queue_work_front(&mdev->data.work, w);
+ drbd_queue_work_front(&mdev->tconn->data.work, w);
} else {
dev_err(DEV, "kmalloc(w) failed.");
ov_oos_print(mdev);
int drbd_asender(struct drbd_thread *thi)
{
struct drbd_conf *mdev = thi->mdev;
- struct p_header80 *h = &mdev->meta.rbuf.header.h80;
+ struct p_header80 *h = &mdev->tconn->meta.rbuf.header.h80;
struct asender_cmd *cmd = NULL;
int rv, len;
dev_err(DEV, "drbd_send_ping has failed\n");
goto reconnect;
}
- mdev->meta.socket->sk->sk_rcvtimeo =
+ mdev->tconn->meta.socket->sk->sk_rcvtimeo =
mdev->tconn->net_conf->ping_timeo*HZ/10;
ping_timeout_active = 1;
}
* it may hurt latency if we cork without much to send */
if (!mdev->tconn->net_conf->no_cork &&
3 < atomic_read(&mdev->unacked_cnt))
- drbd_tcp_cork(mdev->meta.socket);
+ drbd_tcp_cork(mdev->tconn->meta.socket);
while (1) {
clear_bit(SIGNAL_ASENDER, &mdev->flags);
flush_signals(current);
}
/* but unconditionally uncork unless disabled */
if (!mdev->tconn->net_conf->no_cork)
- drbd_tcp_uncork(mdev->meta.socket);
+ drbd_tcp_uncork(mdev->tconn->meta.socket);
/* short circuit, recv_msg would return EINTR anyways. */
if (signal_pending(current))
continue;
- rv = drbd_recv_short(mdev, mdev->meta.socket,
+ rv = drbd_recv_short(mdev, mdev->tconn->meta.socket,
buf, expect-received, 0);
clear_bit(SIGNAL_ASENDER, &mdev->flags);
/* If the data socket received something meanwhile,
* that is good enough: peer is still alive. */
if (time_after(mdev->last_received,
- jiffies - mdev->meta.socket->sk->sk_rcvtimeo))
+ jiffies - mdev->tconn->meta.socket->sk->sk_rcvtimeo))
continue;
if (ping_timeout_active) {
dev_err(DEV, "PingAck did not arrive in time.\n");
* dec_ap_pending will be done in got_BarrierAck
* or (on connection loss) in tl_clear. */
inc_ap_pending(mdev);
- drbd_queue_work(&mdev->data.work, &b->w);
+ drbd_queue_work(&mdev->tconn->data.work, &b->w);
set_bit(CREATE_BARRIER, &mdev->flags);
}
req->w.cb = (req->rq_state & RQ_LOCAL_MASK)
? w_read_retry_remote
: w_send_read_req;
- drbd_queue_work(&mdev->data.work, &req->w);
+ drbd_queue_work(&mdev->tconn->data.work, &req->w);
break;
case QUEUE_FOR_NET_WRITE:
D_ASSERT(req->rq_state & RQ_NET_PENDING);
req->rq_state |= RQ_NET_QUEUED;
req->w.cb = w_send_dblock;
- drbd_queue_work(&mdev->data.work, &req->w);
+ drbd_queue_work(&mdev->tconn->data.work, &req->w);
/* close the epoch, in case it outgrew the limit */
if (mdev->newest_tle->n_writes >= mdev->tconn->net_conf->max_epoch_size)
case QUEUE_FOR_SEND_OOS:
req->rq_state |= RQ_NET_QUEUED;
req->w.cb = w_send_oos;
- drbd_queue_work(&mdev->data.work, &req->w);
+ drbd_queue_work(&mdev->tconn->data.work, &req->w);
break;
case OOS_HANDED_TO_NETWORK:
get_ldev(mdev);
req->w.cb = w_restart_disk_io;
- drbd_queue_work(&mdev->data.work, &req->w);
+ drbd_queue_work(&mdev->tconn->data.work, &req->w);
break;
case RESEND:
We ensure that the peer was not rebooted */
if (!(req->rq_state & RQ_NET_OK)) {
if (req->w.cb) {
- drbd_queue_work(&mdev->data.work, &req->w);
+ drbd_queue_work(&mdev->tconn->data.work, &req->w);
rv = req->rq_state & RQ_WRITE ? MR_WRITE : MR_READ;
}
break;
__drbd_chk_io_error(mdev, false);
spin_unlock_irqrestore(&mdev->req_lock, flags);
- drbd_queue_work(&mdev->data.work, &e->w);
+ drbd_queue_work(&mdev->tconn->data.work, &e->w);
put_ldev(mdev);
}
struct drbd_conf *mdev = (struct drbd_conf *) data;
if (list_empty(&mdev->resync_work.list))
- drbd_queue_work(&mdev->data.work, &mdev->resync_work);
+ drbd_queue_work(&mdev->tconn->data.work, &mdev->resync_work);
}
static void fifo_set(struct fifo_buffer *fb, int value)
for (i = 0; i < number; i++) {
/* Stop generating RS requests, when half of the send buffer is filled */
- mutex_lock(&mdev->data.mutex);
- if (mdev->data.socket) {
- queued = mdev->data.socket->sk->sk_wmem_queued;
- sndbuf = mdev->data.socket->sk->sk_sndbuf;
+ mutex_lock(&mdev->tconn->data.mutex);
+ if (mdev->tconn->data.socket) {
+ queued = mdev->tconn->data.socket->sk->sk_wmem_queued;
+ sndbuf = mdev->tconn->data.socket->sk->sk_sndbuf;
} else {
queued = 1;
sndbuf = 0;
}
- mutex_unlock(&mdev->data.mutex);
+ mutex_unlock(&mdev->tconn->data.mutex);
if (queued > sndbuf / 2)
goto requeue;
{
struct drbd_conf *mdev = (struct drbd_conf *) data;
- drbd_queue_work(&mdev->data.work, &mdev->start_resync_work);
+ drbd_queue_work(&mdev->tconn->data.work, &mdev->start_resync_work);
}
int w_start_resync(struct drbd_conf *mdev, struct drbd_work *w, int cancel)
w = kmalloc(sizeof(struct drbd_work), GFP_ATOMIC);
if (w) {
w->cb = w_resync_finished;
- drbd_queue_work(&mdev->data.work, w);
+ drbd_queue_work(&mdev->tconn->data.work, w);
return 1;
}
dev_err(DEV, "Warn failed to drbd_rs_del_all() and to kmalloc(w).\n");
int w_send_barrier(struct drbd_conf *mdev, struct drbd_work *w, int cancel)
{
struct drbd_tl_epoch *b = container_of(w, struct drbd_tl_epoch, w);
- struct p_barrier *p = &mdev->data.sbuf.barrier;
+ struct p_barrier *p = &mdev->tconn->data.sbuf.barrier;
int ok = 1;
/* really avoid racing with tl_clear. w.cb may have been referenced
/* inc_ap_pending was done where this was queued.
* dec_ap_pending will be done in got_BarrierAck
* or (on connection loss) in w_clear_epoch. */
- ok = _drbd_send_cmd(mdev, mdev->data.socket, P_BARRIER,
+ ok = _drbd_send_cmd(mdev, mdev->tconn->data.socket, P_BARRIER,
(struct p_header80 *)p, sizeof(*p), 0);
drbd_put_data_sock(mdev);
while (get_t_state(thi) == RUNNING) {
drbd_thread_current_set_cpu(mdev);
- if (down_trylock(&mdev->data.work.s)) {
- mutex_lock(&mdev->data.mutex);
- if (mdev->data.socket && !mdev->tconn->net_conf->no_cork)
- drbd_tcp_uncork(mdev->data.socket);
- mutex_unlock(&mdev->data.mutex);
+ if (down_trylock(&mdev->tconn->data.work.s)) {
+ mutex_lock(&mdev->tconn->data.mutex);
+ if (mdev->tconn->data.socket && !mdev->tconn->net_conf->no_cork)
+ drbd_tcp_uncork(mdev->tconn->data.socket);
+ mutex_unlock(&mdev->tconn->data.mutex);
- intr = down_interruptible(&mdev->data.work.s);
+ intr = down_interruptible(&mdev->tconn->data.work.s);
- mutex_lock(&mdev->data.mutex);
- if (mdev->data.socket && !mdev->tconn->net_conf->no_cork)
- drbd_tcp_cork(mdev->data.socket);
- mutex_unlock(&mdev->data.mutex);
+ mutex_lock(&mdev->tconn->data.mutex);
+ if (mdev->tconn->data.socket && !mdev->tconn->net_conf->no_cork)
+ drbd_tcp_cork(mdev->tconn->data.socket);
+ mutex_unlock(&mdev->tconn->data.mutex);
}
if (intr) {
this... */
w = NULL;
- spin_lock_irq(&mdev->data.work.q_lock);
- if (!expect(!list_empty(&mdev->data.work.q))) {
+ spin_lock_irq(&mdev->tconn->data.work.q_lock);
+ if (!expect(!list_empty(&mdev->tconn->data.work.q))) {
/* something terribly wrong in our logic.
* we were able to down() the semaphore,
* but the list is empty... doh.
*
* I'll try to get away just starting over this loop.
*/
- spin_unlock_irq(&mdev->data.work.q_lock);
+ spin_unlock_irq(&mdev->tconn->data.work.q_lock);
continue;
}
- w = list_entry(mdev->data.work.q.next, struct drbd_work, list);
+ w = list_entry(mdev->tconn->data.work.q.next, struct drbd_work, list);
list_del_init(&w->list);
- spin_unlock_irq(&mdev->data.work.q_lock);
+ spin_unlock_irq(&mdev->tconn->data.work.q_lock);
if (!w->cb(mdev, w, mdev->state.conn < C_CONNECTED)) {
/* dev_warn(DEV, "worker: a callback failed! \n"); */
D_ASSERT(test_bit(DEVICE_DYING, &mdev->flags));
D_ASSERT(test_bit(CONFIG_PENDING, &mdev->flags));
- spin_lock_irq(&mdev->data.work.q_lock);
+ spin_lock_irq(&mdev->tconn->data.work.q_lock);
i = 0;
- while (!list_empty(&mdev->data.work.q)) {
- list_splice_init(&mdev->data.work.q, &work_list);
- spin_unlock_irq(&mdev->data.work.q_lock);
+ while (!list_empty(&mdev->tconn->data.work.q)) {
+ list_splice_init(&mdev->tconn->data.work.q, &work_list);
+ spin_unlock_irq(&mdev->tconn->data.work.q_lock);
while (!list_empty(&work_list)) {
w = list_entry(work_list.next, struct drbd_work, list);
i++; /* dead debugging code */
}
- spin_lock_irq(&mdev->data.work.q_lock);
+ spin_lock_irq(&mdev->tconn->data.work.q_lock);
}
- sema_init(&mdev->data.work.s, 0);
+ sema_init(&mdev->tconn->data.work.s, 0);
/* DANGEROUS race: if someone did queue his work within the spinlock,
* but up() ed outside the spinlock, we could get an up() on the
* semaphore without corresponding list entry.
* So don't do that.
*/
- spin_unlock_irq(&mdev->data.work.q_lock);
+ spin_unlock_irq(&mdev->tconn->data.work.q_lock);
D_ASSERT(mdev->state.disk == D_DISKLESS && mdev->state.conn == C_STANDALONE);
/* _drbd_set_state only uses stop_nowait.