diff options
author | Philipp Reisner <philipp.reisner@linbit.com> | 2011-02-07 10:56:20 -0500 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2011-09-28 04:29:52 -0400 |
commit | de0ff338d61645f39e0687c9c3560d8b64bed4a3 (patch) | |
tree | 9634301f519fe8cb142edc225731f0f7389f7bf0 /drivers/block/drbd/drbd_receiver.c | |
parent | 8a22cccc2068b35124f340fcc3f38b730007deff (diff) |
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>
Diffstat (limited to 'drivers/block/drbd/drbd_receiver.c')
-rw-r--r-- | drivers/block/drbd/drbd_receiver.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index 565f2ea47ab8..1368fc3518df 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c | |||
@@ -498,7 +498,7 @@ static int drbd_recv_short(struct socket *sock, void *buf, size_t size, int flag | |||
498 | return rv; | 498 | return rv; |
499 | } | 499 | } |
500 | 500 | ||
501 | static int drbd_recv(struct drbd_conf *mdev, void *buf, size_t size) | 501 | static int drbd_recv(struct drbd_tconn *tconn, void *buf, size_t size) |
502 | { | 502 | { |
503 | mm_segment_t oldfs; | 503 | mm_segment_t oldfs; |
504 | struct kvec iov = { | 504 | struct kvec iov = { |
@@ -516,7 +516,7 @@ static int drbd_recv(struct drbd_conf *mdev, void *buf, size_t size) | |||
516 | set_fs(KERNEL_DS); | 516 | set_fs(KERNEL_DS); |
517 | 517 | ||
518 | for (;;) { | 518 | for (;;) { |
519 | rv = sock_recvmsg(mdev->tconn->data.socket, &msg, size, msg.msg_flags); | 519 | rv = sock_recvmsg(tconn->data.socket, &msg, size, msg.msg_flags); |
520 | if (rv == size) | 520 | if (rv == size) |
521 | break; | 521 | break; |
522 | 522 | ||
@@ -527,12 +527,12 @@ static int drbd_recv(struct drbd_conf *mdev, void *buf, size_t size) | |||
527 | 527 | ||
528 | if (rv < 0) { | 528 | if (rv < 0) { |
529 | if (rv == -ECONNRESET) | 529 | if (rv == -ECONNRESET) |
530 | dev_info(DEV, "sock was reset by peer\n"); | 530 | conn_info(tconn, "sock was reset by peer\n"); |
531 | else if (rv != -ERESTARTSYS) | 531 | else if (rv != -ERESTARTSYS) |
532 | dev_err(DEV, "sock_recvmsg returned %d\n", rv); | 532 | conn_err(tconn, "sock_recvmsg returned %d\n", rv); |
533 | break; | 533 | break; |
534 | } else if (rv == 0) { | 534 | } else if (rv == 0) { |
535 | dev_info(DEV, "sock was shut down by peer\n"); | 535 | conn_info(tconn, "sock was shut down by peer\n"); |
536 | break; | 536 | break; |
537 | } else { | 537 | } else { |
538 | /* signal came in, or peer/link went down, | 538 | /* 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) | |||
546 | set_fs(oldfs); | 546 | set_fs(oldfs); |
547 | 547 | ||
548 | if (rv != size) | 548 | if (rv != size) |
549 | drbd_force_state(mdev, NS(conn, C_BROKEN_PIPE)); | 549 | drbd_force_state(tconn->volume0, NS(conn, C_BROKEN_PIPE)); |
550 | 550 | ||
551 | return rv; | 551 | return rv; |
552 | } | 552 | } |
@@ -949,7 +949,7 @@ static int drbd_recv_header(struct drbd_conf *mdev, enum drbd_packet *cmd, | |||
949 | struct p_header *h = &mdev->tconn->data.rbuf.header; | 949 | struct p_header *h = &mdev->tconn->data.rbuf.header; |
950 | int r; | 950 | int r; |
951 | 951 | ||
952 | r = drbd_recv(mdev, h, sizeof(*h)); | 952 | r = drbd_recv(mdev->tconn, h, sizeof(*h)); |
953 | if (unlikely(r != sizeof(*h))) { | 953 | if (unlikely(r != sizeof(*h))) { |
954 | if (!signal_pending(current)) | 954 | if (!signal_pending(current)) |
955 | dev_warn(DEV, "short read expecting header on sock: r=%d\n", r); | 955 | 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, | |||
1272 | crypto_hash_digestsize(mdev->tconn->integrity_r_tfm) : 0; | 1272 | crypto_hash_digestsize(mdev->tconn->integrity_r_tfm) : 0; |
1273 | 1273 | ||
1274 | if (dgs) { | 1274 | if (dgs) { |
1275 | rr = drbd_recv(mdev, dig_in, dgs); | 1275 | rr = drbd_recv(mdev->tconn, dig_in, dgs); |
1276 | if (rr != dgs) { | 1276 | if (rr != dgs) { |
1277 | if (!signal_pending(current)) | 1277 | if (!signal_pending(current)) |
1278 | dev_warn(DEV, | 1278 | dev_warn(DEV, |
@@ -1313,7 +1313,7 @@ read_in_block(struct drbd_conf *mdev, u64 id, sector_t sector, | |||
1313 | page_chain_for_each(page) { | 1313 | page_chain_for_each(page) { |
1314 | unsigned len = min_t(int, ds, PAGE_SIZE); | 1314 | unsigned len = min_t(int, ds, PAGE_SIZE); |
1315 | data = kmap(page); | 1315 | data = kmap(page); |
1316 | rr = drbd_recv(mdev, data, len); | 1316 | rr = drbd_recv(mdev->tconn, data, len); |
1317 | if (drbd_insert_fault(mdev, DRBD_FAULT_RECEIVE)) { | 1317 | if (drbd_insert_fault(mdev, DRBD_FAULT_RECEIVE)) { |
1318 | dev_err(DEV, "Fault injection: Corrupting data on receive\n"); | 1318 | dev_err(DEV, "Fault injection: Corrupting data on receive\n"); |
1319 | data[0] = data[0] ^ (unsigned long)-1; | 1319 | data[0] = data[0] ^ (unsigned long)-1; |
@@ -1360,7 +1360,7 @@ static int drbd_drain_block(struct drbd_conf *mdev, int data_size) | |||
1360 | 1360 | ||
1361 | data = kmap(page); | 1361 | data = kmap(page); |
1362 | while (data_size) { | 1362 | while (data_size) { |
1363 | rr = drbd_recv(mdev, data, min_t(int, data_size, PAGE_SIZE)); | 1363 | rr = drbd_recv(mdev->tconn, data, min_t(int, data_size, PAGE_SIZE)); |
1364 | if (rr != min_t(int, data_size, PAGE_SIZE)) { | 1364 | if (rr != min_t(int, data_size, PAGE_SIZE)) { |
1365 | rv = 0; | 1365 | rv = 0; |
1366 | if (!signal_pending(current)) | 1366 | if (!signal_pending(current)) |
@@ -1389,7 +1389,7 @@ static int recv_dless_read(struct drbd_conf *mdev, struct drbd_request *req, | |||
1389 | crypto_hash_digestsize(mdev->tconn->integrity_r_tfm) : 0; | 1389 | crypto_hash_digestsize(mdev->tconn->integrity_r_tfm) : 0; |
1390 | 1390 | ||
1391 | if (dgs) { | 1391 | if (dgs) { |
1392 | rr = drbd_recv(mdev, dig_in, dgs); | 1392 | rr = drbd_recv(mdev->tconn, dig_in, dgs); |
1393 | if (rr != dgs) { | 1393 | if (rr != dgs) { |
1394 | if (!signal_pending(current)) | 1394 | if (!signal_pending(current)) |
1395 | dev_warn(DEV, | 1395 | dev_warn(DEV, |
@@ -1410,7 +1410,7 @@ static int recv_dless_read(struct drbd_conf *mdev, struct drbd_request *req, | |||
1410 | 1410 | ||
1411 | bio_for_each_segment(bvec, bio, i) { | 1411 | bio_for_each_segment(bvec, bio, i) { |
1412 | expect = min_t(int, data_size, bvec->bv_len); | 1412 | expect = min_t(int, data_size, bvec->bv_len); |
1413 | rr = drbd_recv(mdev, | 1413 | rr = drbd_recv(mdev->tconn, |
1414 | kmap(bvec->bv_page)+bvec->bv_offset, | 1414 | kmap(bvec->bv_page)+bvec->bv_offset, |
1415 | expect); | 1415 | expect); |
1416 | kunmap(bvec->bv_page); | 1416 | kunmap(bvec->bv_page); |
@@ -2094,7 +2094,7 @@ static int receive_DataRequest(struct drbd_conf *mdev, enum drbd_packet cmd, | |||
2094 | peer_req->digest = di; | 2094 | peer_req->digest = di; |
2095 | peer_req->flags |= EE_HAS_DIGEST; | 2095 | peer_req->flags |= EE_HAS_DIGEST; |
2096 | 2096 | ||
2097 | if (drbd_recv(mdev, di->digest, digest_size) != digest_size) | 2097 | if (drbd_recv(mdev->tconn, di->digest, digest_size) != digest_size) |
2098 | goto out_free_e; | 2098 | goto out_free_e; |
2099 | 2099 | ||
2100 | if (cmd == P_CSUM_RS_REQUEST) { | 2100 | if (cmd == P_CSUM_RS_REQUEST) { |
@@ -2785,7 +2785,7 @@ static int receive_protocol(struct drbd_conf *mdev, enum drbd_packet cmd, | |||
2785 | if (mdev->tconn->agreed_pro_version >= 87) { | 2785 | if (mdev->tconn->agreed_pro_version >= 87) { |
2786 | unsigned char *my_alg = mdev->tconn->net_conf->integrity_alg; | 2786 | unsigned char *my_alg = mdev->tconn->net_conf->integrity_alg; |
2787 | 2787 | ||
2788 | if (drbd_recv(mdev, p_integrity_alg, data_size) != data_size) | 2788 | if (drbd_recv(mdev->tconn, p_integrity_alg, data_size) != data_size) |
2789 | return false; | 2789 | return false; |
2790 | 2790 | ||
2791 | p_integrity_alg[SHARED_SECRET_MAX-1] = 0; | 2791 | p_integrity_alg[SHARED_SECRET_MAX-1] = 0; |
@@ -2871,7 +2871,7 @@ static int receive_SyncParam(struct drbd_conf *mdev, enum drbd_packet cmd, | |||
2871 | /* initialize verify_alg and csums_alg */ | 2871 | /* initialize verify_alg and csums_alg */ |
2872 | memset(p->verify_alg, 0, 2 * SHARED_SECRET_MAX); | 2872 | memset(p->verify_alg, 0, 2 * SHARED_SECRET_MAX); |
2873 | 2873 | ||
2874 | if (drbd_recv(mdev, &p->head.payload, header_size) != header_size) | 2874 | if (drbd_recv(mdev->tconn, &p->head.payload, header_size) != header_size) |
2875 | return false; | 2875 | return false; |
2876 | 2876 | ||
2877 | mdev->sync_conf.rate = be32_to_cpu(p->rate); | 2877 | 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, | |||
2885 | return false; | 2885 | return false; |
2886 | } | 2886 | } |
2887 | 2887 | ||
2888 | if (drbd_recv(mdev, p->verify_alg, data_size) != data_size) | 2888 | if (drbd_recv(mdev->tconn, p->verify_alg, data_size) != data_size) |
2889 | return false; | 2889 | return false; |
2890 | 2890 | ||
2891 | /* we expect NUL terminated string */ | 2891 | /* we expect NUL terminated string */ |
@@ -3424,7 +3424,7 @@ receive_bitmap_plain(struct drbd_conf *mdev, unsigned int data_size, | |||
3424 | } | 3424 | } |
3425 | if (want == 0) | 3425 | if (want == 0) |
3426 | return 0; | 3426 | return 0; |
3427 | err = drbd_recv(mdev, buffer, want); | 3427 | err = drbd_recv(mdev->tconn, buffer, want); |
3428 | if (err != want) { | 3428 | if (err != want) { |
3429 | if (err >= 0) | 3429 | if (err >= 0) |
3430 | err = -EIO; | 3430 | err = -EIO; |
@@ -3613,7 +3613,7 @@ static int receive_bitmap(struct drbd_conf *mdev, enum drbd_packet cmd, | |||
3613 | /* use the page buff */ | 3613 | /* use the page buff */ |
3614 | p = buffer; | 3614 | p = buffer; |
3615 | memcpy(p, h, sizeof(*h)); | 3615 | memcpy(p, h, sizeof(*h)); |
3616 | if (drbd_recv(mdev, p->head.payload, data_size) != data_size) | 3616 | if (drbd_recv(mdev->tconn, p->head.payload, data_size) != data_size) |
3617 | goto out; | 3617 | goto out; |
3618 | if (data_size <= (sizeof(*p) - sizeof(p->head))) { | 3618 | if (data_size <= (sizeof(*p) - sizeof(p->head))) { |
3619 | dev_err(DEV, "ReportCBitmap packet too small (l:%u)\n", data_size); | 3619 | 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, | |||
3677 | size = data_size; | 3677 | size = data_size; |
3678 | while (size > 0) { | 3678 | while (size > 0) { |
3679 | want = min_t(int, size, sizeof(sink)); | 3679 | want = min_t(int, size, sizeof(sink)); |
3680 | r = drbd_recv(mdev, sink, want); | 3680 | r = drbd_recv(mdev->tconn, sink, want); |
3681 | if (!expect(r > 0)) | 3681 | if (!expect(r > 0)) |
3682 | break; | 3682 | break; |
3683 | size -= r; | 3683 | size -= r; |
@@ -3784,7 +3784,7 @@ static void drbdd(struct drbd_conf *mdev) | |||
3784 | } | 3784 | } |
3785 | 3785 | ||
3786 | if (shs) { | 3786 | if (shs) { |
3787 | rv = drbd_recv(mdev, &header->payload, shs); | 3787 | rv = drbd_recv(mdev->tconn, &header->payload, shs); |
3788 | if (unlikely(rv != shs)) { | 3788 | if (unlikely(rv != shs)) { |
3789 | if (!signal_pending(current)) | 3789 | if (!signal_pending(current)) |
3790 | dev_warn(DEV, "short read while reading sub header: rv=%d\n", rv); | 3790 | 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) | |||
4013 | return -1; | 4013 | return -1; |
4014 | } | 4014 | } |
4015 | 4015 | ||
4016 | rv = drbd_recv(mdev, &p->head.payload, expect); | 4016 | rv = drbd_recv(mdev->tconn, &p->head.payload, expect); |
4017 | 4017 | ||
4018 | if (rv != expect) { | 4018 | if (rv != expect) { |
4019 | if (!signal_pending(current)) | 4019 | if (!signal_pending(current)) |
@@ -4116,7 +4116,7 @@ static int drbd_do_auth(struct drbd_conf *mdev) | |||
4116 | goto fail; | 4116 | goto fail; |
4117 | } | 4117 | } |
4118 | 4118 | ||
4119 | rv = drbd_recv(mdev, peers_ch, length); | 4119 | rv = drbd_recv(mdev->tconn, peers_ch, length); |
4120 | 4120 | ||
4121 | if (rv != length) { | 4121 | if (rv != length) { |
4122 | if (!signal_pending(current)) | 4122 | if (!signal_pending(current)) |
@@ -4164,7 +4164,7 @@ static int drbd_do_auth(struct drbd_conf *mdev) | |||
4164 | goto fail; | 4164 | goto fail; |
4165 | } | 4165 | } |
4166 | 4166 | ||
4167 | rv = drbd_recv(mdev, response , resp_size); | 4167 | rv = drbd_recv(mdev->tconn, response , resp_size); |
4168 | 4168 | ||
4169 | if (rv != resp_size) { | 4169 | if (rv != resp_size) { |
4170 | if (!signal_pending(current)) | 4170 | if (!signal_pending(current)) |