diff options
author | Andreas Gruenbacher <agruen@linbit.com> | 2011-03-16 06:52:58 -0400 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2012-11-08 10:44:42 -0500 |
commit | 6bdb9b0e230aae94b084d8a375363ada056653b5 (patch) | |
tree | 86e1e2bd14efc539f80be89b05d2d6e6603883d5 /drivers/block/drbd/drbd_main.c | |
parent | 7fae55da38e810c75b97cc56380aa6f735504216 (diff) |
drbd: drbd_send_dblock(): Return 0 upon success and an error code otherwise
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_main.c')
-rw-r--r-- | drivers/block/drbd/drbd_main.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 77c957ff7a0e..2f203bab5933 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c | |||
@@ -1537,14 +1537,15 @@ static u32 bio_flags_to_wire(struct drbd_conf *mdev, unsigned long bi_rw) | |||
1537 | */ | 1537 | */ |
1538 | int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req) | 1538 | int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req) |
1539 | { | 1539 | { |
1540 | int ok = 1; | 1540 | int err; |
1541 | struct p_data p; | 1541 | struct p_data p; |
1542 | unsigned int dp_flags = 0; | 1542 | unsigned int dp_flags = 0; |
1543 | void *dgb; | 1543 | void *dgb; |
1544 | int dgs; | 1544 | int dgs; |
1545 | 1545 | ||
1546 | if (drbd_get_data_sock(mdev->tconn)) | 1546 | err = drbd_get_data_sock(mdev->tconn); |
1547 | return 0; | 1547 | if (err) |
1548 | return err; | ||
1548 | 1549 | ||
1549 | dgs = (mdev->tconn->agreed_pro_version >= 87 && mdev->tconn->integrity_w_tfm) ? | 1550 | dgs = (mdev->tconn->agreed_pro_version >= 87 && mdev->tconn->integrity_w_tfm) ? |
1550 | crypto_hash_digestsize(mdev->tconn->integrity_w_tfm) : 0; | 1551 | crypto_hash_digestsize(mdev->tconn->integrity_w_tfm) : 0; |
@@ -1562,14 +1563,14 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req) | |||
1562 | 1563 | ||
1563 | p.dp_flags = cpu_to_be32(dp_flags); | 1564 | p.dp_flags = cpu_to_be32(dp_flags); |
1564 | set_bit(UNPLUG_REMOTE, &mdev->flags); | 1565 | set_bit(UNPLUG_REMOTE, &mdev->flags); |
1565 | ok = (sizeof(p) == | 1566 | err = drbd_send_all(mdev->tconn, mdev->tconn->data.socket, &p, |
1566 | drbd_send(mdev->tconn, mdev->tconn->data.socket, &p, sizeof(p), dgs ? MSG_MORE : 0)); | 1567 | sizeof(p), dgs ? MSG_MORE : 0); |
1567 | if (ok && dgs) { | 1568 | if (!err && dgs) { |
1568 | dgb = mdev->tconn->int_dig_out; | 1569 | dgb = mdev->tconn->int_dig_out; |
1569 | drbd_csum_bio(mdev, mdev->tconn->integrity_w_tfm, req->master_bio, dgb); | 1570 | drbd_csum_bio(mdev, mdev->tconn->integrity_w_tfm, req->master_bio, dgb); |
1570 | ok = dgs == drbd_send(mdev->tconn, mdev->tconn->data.socket, dgb, dgs, 0); | 1571 | err = drbd_send_all(mdev->tconn, mdev->tconn->data.socket, dgb, dgs, 0); |
1571 | } | 1572 | } |
1572 | if (ok) { | 1573 | if (!err) { |
1573 | /* For protocol A, we have to memcpy the payload into | 1574 | /* For protocol A, we have to memcpy the payload into |
1574 | * socket buffers, as we may complete right away | 1575 | * socket buffers, as we may complete right away |
1575 | * as soon as we handed it over to tcp, at which point the data | 1576 | * as soon as we handed it over to tcp, at which point the data |
@@ -1582,9 +1583,9 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req) | |||
1582 | * receiving side, we sure have detected corruption elsewhere. | 1583 | * receiving side, we sure have detected corruption elsewhere. |
1583 | */ | 1584 | */ |
1584 | if (mdev->tconn->net_conf->wire_protocol == DRBD_PROT_A || dgs) | 1585 | if (mdev->tconn->net_conf->wire_protocol == DRBD_PROT_A || dgs) |
1585 | ok = !_drbd_send_bio(mdev, req->master_bio); | 1586 | err = _drbd_send_bio(mdev, req->master_bio); |
1586 | else | 1587 | else |
1587 | ok = !_drbd_send_zc_bio(mdev, req->master_bio); | 1588 | err = _drbd_send_zc_bio(mdev, req->master_bio); |
1588 | 1589 | ||
1589 | /* double check digest, sometimes buffers have been modified in flight. */ | 1590 | /* double check digest, sometimes buffers have been modified in flight. */ |
1590 | if (dgs > 0 && dgs <= 64) { | 1591 | if (dgs > 0 && dgs <= 64) { |
@@ -1604,7 +1605,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req) | |||
1604 | 1605 | ||
1605 | drbd_put_data_sock(mdev->tconn); | 1606 | drbd_put_data_sock(mdev->tconn); |
1606 | 1607 | ||
1607 | return ok; | 1608 | return err; |
1608 | } | 1609 | } |
1609 | 1610 | ||
1610 | /* answer packet, used to send data back for read requests: | 1611 | /* answer packet, used to send data back for read requests: |