Commit de0ff338 authored by Philipp Reisner's avatar Philipp Reisner

drbd: Converted drbd_recv() from mdev to tconn

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