aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2011-01-25 11:19:34 -0500
committerSage Weil <sage@newdream.net>2011-01-25 11:19:34 -0500
commit42961d2333a1855c649fa3790e258ab4f0fa66a4 (patch)
tree7858f28e3a3c5ff1f0dc6f6165251c68b9709b4d /net
parent98bdb0aa007ff7e8e0061936d8d0e210faf2e655 (diff)
libceph: fix socket write error handling
Pass errors from writing to the socket up the stack. If we get -EAGAIN, return 0 from the helper to simplify the callers' checks. Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'net')
-rw-r--r--net/ceph/messenger.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index d95576d40c98..35b36b86d762 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -268,13 +268,17 @@ static int ceph_tcp_sendmsg(struct socket *sock, struct kvec *iov,
268 size_t kvlen, size_t len, int more) 268 size_t kvlen, size_t len, int more)
269{ 269{
270 struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL }; 270 struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL };
271 int r;
271 272
272 if (more) 273 if (more)
273 msg.msg_flags |= MSG_MORE; 274 msg.msg_flags |= MSG_MORE;
274 else 275 else
275 msg.msg_flags |= MSG_EOR; /* superfluous, but what the hell */ 276 msg.msg_flags |= MSG_EOR; /* superfluous, but what the hell */
276 277
277 return kernel_sendmsg(sock, &msg, iov, kvlen, len); 278 r = kernel_sendmsg(sock, &msg, iov, kvlen, len);
279 if (r == -EAGAIN)
280 r = 0;
281 return r;
278} 282}
279 283
280 284
@@ -851,6 +855,8 @@ static int write_partial_msg_pages(struct ceph_connection *con)
851 (msg->pages || msg->pagelist || msg->bio || in_trail)) 855 (msg->pages || msg->pagelist || msg->bio || in_trail))
852 kunmap(page); 856 kunmap(page);
853 857
858 if (ret == -EAGAIN)
859 ret = 0;
854 if (ret <= 0) 860 if (ret <= 0)
855 goto out; 861 goto out;
856 862
@@ -1741,16 +1747,12 @@ more_kvec:
1741 if (con->out_skip) { 1747 if (con->out_skip) {
1742 ret = write_partial_skip(con); 1748 ret = write_partial_skip(con);
1743 if (ret <= 0) 1749 if (ret <= 0)
1744 goto done; 1750 goto out;
1745 if (ret < 0) {
1746 dout("try_write write_partial_skip err %d\n", ret);
1747 goto done;
1748 }
1749 } 1751 }
1750 if (con->out_kvec_left) { 1752 if (con->out_kvec_left) {
1751 ret = write_partial_kvec(con); 1753 ret = write_partial_kvec(con);
1752 if (ret <= 0) 1754 if (ret <= 0)
1753 goto done; 1755 goto out;
1754 } 1756 }
1755 1757
1756 /* msg pages? */ 1758 /* msg pages? */
@@ -1765,11 +1767,11 @@ more_kvec:
1765 if (ret == 1) 1767 if (ret == 1)
1766 goto more_kvec; /* we need to send the footer, too! */ 1768 goto more_kvec; /* we need to send the footer, too! */
1767 if (ret == 0) 1769 if (ret == 0)
1768 goto done; 1770 goto out;
1769 if (ret < 0) { 1771 if (ret < 0) {
1770 dout("try_write write_partial_msg_pages err %d\n", 1772 dout("try_write write_partial_msg_pages err %d\n",
1771 ret); 1773 ret);
1772 goto done; 1774 goto out;
1773 } 1775 }
1774 } 1776 }
1775 1777
@@ -1793,10 +1795,9 @@ do_next:
1793 /* Nothing to do! */ 1795 /* Nothing to do! */
1794 clear_bit(WRITE_PENDING, &con->state); 1796 clear_bit(WRITE_PENDING, &con->state);
1795 dout("try_write nothing else to write.\n"); 1797 dout("try_write nothing else to write.\n");
1796done:
1797 ret = 0; 1798 ret = 0;
1798out: 1799out:
1799 dout("try_write done on %p\n", con); 1800 dout("try_write done on %p ret %d\n", con, ret);
1800 return ret; 1801 return ret;
1801} 1802}
1802 1803