drbd: Converted drbd_recv() from mdev to tconn

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
This commit is contained in:
Philipp Reisner 2011-02-07 16:56:20 +01:00
parent 8a22cccc20
commit de0ff338d6
1 changed files with 23 additions and 23 deletions

View File

@ -498,7 +498,7 @@ static int drbd_recv_short(struct socket *sock, void *buf, size_t size, int flag
return rv;
}
static int drbd_recv(struct drbd_conf *mdev, void *buf, size_t size)
static int drbd_recv(struct drbd_tconn *tconn, void *buf, size_t size)
{
mm_segment_t oldfs;
struct kvec iov = {
@ -516,7 +516,7 @@ static int drbd_recv(struct drbd_conf *mdev, void *buf, size_t size)
set_fs(KERNEL_DS);
for (;;) {
rv = sock_recvmsg(mdev->tconn->data.socket, &msg, size, msg.msg_flags);
rv = sock_recvmsg(tconn->data.socket, &msg, size, msg.msg_flags);
if (rv == size)
break;
@ -527,12 +527,12 @@ static int drbd_recv(struct drbd_conf *mdev, void *buf, size_t size)
if (rv < 0) {
if (rv == -ECONNRESET)
dev_info(DEV, "sock was reset by peer\n");
conn_info(tconn, "sock was reset by peer\n");
else if (rv != -ERESTARTSYS)
dev_err(DEV, "sock_recvmsg returned %d\n", rv);
conn_err(tconn, "sock_recvmsg returned %d\n", rv);
break;
} else if (rv == 0) {
dev_info(DEV, "sock was shut down by peer\n");
conn_info(tconn, "sock was shut down by peer\n");
break;
} else {
/* signal came in, or peer/link went down,
@ -546,7 +546,7 @@ static int drbd_recv(struct drbd_conf *mdev, void *buf, size_t size)
set_fs(oldfs);
if (rv != size)
drbd_force_state(mdev, NS(conn, C_BROKEN_PIPE));
drbd_force_state(tconn->volume0, NS(conn, C_BROKEN_PIPE));
return rv;
}
@ -949,7 +949,7 @@ static int drbd_recv_header(struct drbd_conf *mdev, enum drbd_packet *cmd,
struct p_header *h = &mdev->tconn->data.rbuf.header;
int r;
r = drbd_recv(mdev, h, sizeof(*h));
r = drbd_recv(mdev->tconn, h, sizeof(*h));
if (unlikely(r != sizeof(*h))) {
if (!signal_pending(current))
dev_warn(DEV, "short read expecting header on sock: r=%d\n", r);
@ -1272,7 +1272,7 @@ read_in_block(struct drbd_conf *mdev, u64 id, sector_t sector,
crypto_hash_digestsize(mdev->tconn->integrity_r_tfm) : 0;
if (dgs) {
rr = drbd_recv(mdev, dig_in, dgs);
rr = drbd_recv(mdev->tconn, dig_in, dgs);
if (rr != dgs) {
if (!signal_pending(current))
dev_warn(DEV,
@ -1313,7 +1313,7 @@ read_in_block(struct drbd_conf *mdev, u64 id, sector_t sector,
page_chain_for_each(page) {
unsigned len = min_t(int, ds, PAGE_SIZE);
data = kmap(page);
rr = drbd_recv(mdev, data, len);
rr = drbd_recv(mdev->tconn, data, len);
if (drbd_insert_fault(mdev, DRBD_FAULT_RECEIVE)) {
dev_err(DEV, "Fault injection: Corrupting data on receive\n");
data[0] = data[0] ^ (unsigned long)-1;
@ -1360,7 +1360,7 @@ static int drbd_drain_block(struct drbd_conf *mdev, int data_size)
data = kmap(page);
while (data_size) {
rr = drbd_recv(mdev, data, min_t(int, data_size, PAGE_SIZE));
rr = drbd_recv(mdev->tconn, data, min_t(int, data_size, PAGE_SIZE));
if (rr != min_t(int, data_size, PAGE_SIZE)) {
rv = 0;
if (!signal_pending(current))
@ -1389,7 +1389,7 @@ static int recv_dless_read(struct drbd_conf *mdev, struct drbd_request *req,
crypto_hash_digestsize(mdev->tconn->integrity_r_tfm) : 0;
if (dgs) {
rr = drbd_recv(mdev, dig_in, dgs);
rr = drbd_recv(mdev->tconn, dig_in, dgs);
if (rr != dgs) {
if (!signal_pending(current))
dev_warn(DEV,
@ -1410,7 +1410,7 @@ static int recv_dless_read(struct drbd_conf *mdev, struct drbd_request *req,
bio_for_each_segment(bvec, bio, i) {
expect = min_t(int, data_size, bvec->bv_len);
rr = drbd_recv(mdev,
rr = drbd_recv(mdev->tconn,
kmap(bvec->bv_page)+bvec->bv_offset,
expect);
kunmap(bvec->bv_page);
@ -2094,7 +2094,7 @@ static int receive_DataRequest(struct drbd_conf *mdev, enum drbd_packet cmd,
peer_req->digest = di;
peer_req->flags |= EE_HAS_DIGEST;
if (drbd_recv(mdev, di->digest, digest_size) != digest_size)
if (drbd_recv(mdev->tconn, di->digest, digest_size) != digest_size)
goto out_free_e;
if (cmd == P_CSUM_RS_REQUEST) {
@ -2785,7 +2785,7 @@ static int receive_protocol(struct drbd_conf *mdev, enum drbd_packet cmd,
if (mdev->tconn->agreed_pro_version >= 87) {
unsigned char *my_alg = mdev->tconn->net_conf->integrity_alg;
if (drbd_recv(mdev, p_integrity_alg, data_size) != data_size)
if (drbd_recv(mdev->tconn, p_integrity_alg, data_size) != data_size)
return false;
p_integrity_alg[SHARED_SECRET_MAX-1] = 0;
@ -2871,7 +2871,7 @@ static int receive_SyncParam(struct drbd_conf *mdev, enum drbd_packet cmd,
/* initialize verify_alg and csums_alg */
memset(p->verify_alg, 0, 2 * SHARED_SECRET_MAX);
if (drbd_recv(mdev, &p->head.payload, header_size) != header_size)
if (drbd_recv(mdev->tconn, &p->head.payload, header_size) != header_size)
return false;
mdev->sync_conf.rate = be32_to_cpu(p->rate);
@ -2885,7 +2885,7 @@ static int receive_SyncParam(struct drbd_conf *mdev, enum drbd_packet cmd,
return false;
}
if (drbd_recv(mdev, p->verify_alg, data_size) != data_size)
if (drbd_recv(mdev->tconn, p->verify_alg, data_size) != data_size)
return false;
/* we expect NUL terminated string */
@ -3424,7 +3424,7 @@ receive_bitmap_plain(struct drbd_conf *mdev, unsigned int data_size,
}
if (want == 0)
return 0;
err = drbd_recv(mdev, buffer, want);
err = drbd_recv(mdev->tconn, buffer, want);
if (err != want) {
if (err >= 0)
err = -EIO;
@ -3613,7 +3613,7 @@ static int receive_bitmap(struct drbd_conf *mdev, enum drbd_packet cmd,
/* use the page buff */
p = buffer;
memcpy(p, h, sizeof(*h));
if (drbd_recv(mdev, p->head.payload, data_size) != data_size)
if (drbd_recv(mdev->tconn, p->head.payload, data_size) != data_size)
goto out;
if (data_size <= (sizeof(*p) - sizeof(p->head))) {
dev_err(DEV, "ReportCBitmap packet too small (l:%u)\n", data_size);
@ -3677,7 +3677,7 @@ static int receive_skip(struct drbd_conf *mdev, enum drbd_packet cmd,
size = data_size;
while (size > 0) {
want = min_t(int, size, sizeof(sink));
r = drbd_recv(mdev, sink, want);
r = drbd_recv(mdev->tconn, sink, want);
if (!expect(r > 0))
break;
size -= r;
@ -3784,7 +3784,7 @@ static void drbdd(struct drbd_conf *mdev)
}
if (shs) {
rv = drbd_recv(mdev, &header->payload, shs);
rv = drbd_recv(mdev->tconn, &header->payload, shs);
if (unlikely(rv != shs)) {
if (!signal_pending(current))
dev_warn(DEV, "short read while reading sub header: rv=%d\n", rv);
@ -4013,7 +4013,7 @@ static int drbd_do_handshake(struct drbd_conf *mdev)
return -1;
}
rv = drbd_recv(mdev, &p->head.payload, expect);
rv = drbd_recv(mdev->tconn, &p->head.payload, expect);
if (rv != expect) {
if (!signal_pending(current))
@ -4116,7 +4116,7 @@ static int drbd_do_auth(struct drbd_conf *mdev)
goto fail;
}
rv = drbd_recv(mdev, peers_ch, length);
rv = drbd_recv(mdev->tconn, peers_ch, length);
if (rv != length) {
if (!signal_pending(current))
@ -4164,7 +4164,7 @@ static int drbd_do_auth(struct drbd_conf *mdev)
goto fail;
}
rv = drbd_recv(mdev, response , resp_size);
rv = drbd_recv(mdev->tconn, response , resp_size);
if (rv != resp_size) {
if (!signal_pending(current))