netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org
Subject: [PATCH 09/17] RxRPC: Use iov_iter_count() in rxrpc_send_data() instead of the len argument
Date: Sat, 11 Apr 2015 22:18:20 +0100	[thread overview]
Message-ID: <1428787108-13650-9-git-send-email-viro@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20150411211742.GJ889@ZenIV.linux.org.uk>

From: David Howells <dhowells@redhat.com>

Use iov_iter_count() in rxrpc_send_data() to get the remaining data length
instead of using the len argument as the len argument is now redundant.

Signed-off-by: David Howells <dhowells@redhat.com>
---
 net/rxrpc/ar-output.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
index f48dc1a..de8d2f1 100644
--- a/net/rxrpc/ar-output.c
+++ b/net/rxrpc/ar-output.c
@@ -546,8 +546,6 @@ static int rxrpc_send_data(struct kiocb *iocb,
 	call->tx_pending = NULL;
 
 	copied = 0;
-	if (len > iov_iter_count(&msg->msg_iter))
-		len = iov_iter_count(&msg->msg_iter);
 	do {
 		if (!skb) {
 			size_t size, chunk, max, space;
@@ -570,8 +568,8 @@ static int rxrpc_send_data(struct kiocb *iocb,
 			max &= ~(call->conn->size_align - 1UL);
 
 			chunk = max;
-			if (chunk > len && !more)
-				chunk = len;
+			if (chunk > iov_iter_count(&msg->msg_iter) && !more)
+				chunk = iov_iter_count(&msg->msg_iter);
 
 			space = chunk + call->conn->size_align;
 			space &= ~(call->conn->size_align - 1UL);
@@ -614,11 +612,11 @@ static int rxrpc_send_data(struct kiocb *iocb,
 		sp = rxrpc_skb(skb);
 
 		/* append next segment of data to the current buffer */
-		if (len > 0) {
+		if (iov_iter_count(&msg->msg_iter) > 0) {
 			int copy = skb_tailroom(skb);
 			ASSERTCMP(copy, >, 0);
-			if (copy > len)
-				copy = len;
+			if (copy > iov_iter_count(&msg->msg_iter))
+				copy = iov_iter_count(&msg->msg_iter);
 			if (copy > sp->remain)
 				copy = sp->remain;
 
@@ -630,8 +628,6 @@ static int rxrpc_send_data(struct kiocb *iocb,
 			sp->remain -= copy;
 			skb->mark += copy;
 			copied += copy;
-
-			len -= copy;
 		}
 
 		/* check for the far side aborting the call or a network error
@@ -640,7 +636,8 @@ static int rxrpc_send_data(struct kiocb *iocb,
 			goto call_aborted;
 
 		/* add the packet to the send queue if it's now full */
-		if (sp->remain <= 0 || (!len && !more)) {
+		if (sp->remain <= 0 ||
+		    (iov_iter_count(&msg->msg_iter) == 0 && !more)) {
 			struct rxrpc_connection *conn = call->conn;
 			uint32_t seq;
 			size_t pad;
@@ -670,7 +667,7 @@ static int rxrpc_send_data(struct kiocb *iocb,
 			sp->hdr.serviceId = conn->service_id;
 
 			sp->hdr.flags = conn->out_clientflag;
-			if (len == 0 && !more)
+			if (iov_iter_count(&msg->msg_iter) == 0 && !more)
 				sp->hdr.flags |= RXRPC_LAST_PACKET;
 			else if (CIRC_SPACE(call->acks_head, call->acks_tail,
 					    call->acks_winsz) > 1)
@@ -686,10 +683,11 @@ static int rxrpc_send_data(struct kiocb *iocb,
 
 			memcpy(skb->head, &sp->hdr,
 			       sizeof(struct rxrpc_header));
-			rxrpc_queue_packet(call, skb, !iov_iter_count(&msg->msg_iter) && !more);
+			rxrpc_queue_packet(call, skb,
+					   iov_iter_count(&msg->msg_iter) == 0 && !more);
 			skb = NULL;
 		}
-	} while (len > 0);
+	} while (iov_iter_count(&msg->msg_iter) > 0);
 
 success:
 	ret = copied;
-- 
2.1.4

  parent reply	other threads:[~2015-04-11 21:18 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-11 21:17 [call for review] netdev-related stuff in vfs.git Al Viro
2015-04-11 21:18 ` [PATCH 01/17] fs: remove ki_nbytes Al Viro
2015-04-11 21:18 ` [PATCH 02/17] fuse: handle synchronous iocbs internally Al Viro
2015-04-11 21:18 ` [PATCH 03/17] fs: don't allow to complete sync iocbs through aio_complete Al Viro
2015-04-14 18:00   ` Tadeusz Struk
2015-04-14 18:26     ` Al Viro
2015-04-14 18:37       ` Tadeusz Struk
2015-04-14 19:22         ` Al Viro
2015-04-11 21:18 ` [PATCH 04/17] fs: split generic and aio kiocb Al Viro
2015-04-11 21:18 ` [PATCH 05/17] fs: move struct kiocb to fs.h Al Viro
2015-04-11 21:18 ` [PATCH 06/17] saner iov_iter initialization primitives Al Viro
2015-04-11 21:18 ` [PATCH 07/17] RxRPC: Fix the conversion to iov_iter Al Viro
2015-04-11 21:18 ` [PATCH 08/17] RxRPC: Don't call skb_add_data() if there's no data to copy Al Viro
2015-04-11 21:18 ` Al Viro [this message]
2015-04-11 21:18 ` [PATCH 10/17] AFS: afs_send_empty_reply() doesn't require an iovec array Al Viro
2015-04-11 21:18 ` [PATCH 11/17] RxRPC: Handle VERSION Rx protocol packets Al Viro
2015-04-11 21:18 ` [PATCH 12/17] kafs: Add more "unified AFS" error codes Al Viro
2015-04-11 21:18 ` [PATCH 13/17] net: switch sendto() and recvfrom() to import_single_range() Al Viro
2015-04-11 21:18 ` [PATCH 14/17] net: switch importing msghdr from userland to {compat_,}import_iovec() Al Viro
2015-04-11 21:18 ` [PATCH 15/17] switch kernel_sendmsg() and kernel_recvmsg() to iov_iter_kvec() Al Viro
2015-04-14 16:21   ` David Laight
2015-04-14 16:34     ` Al Viro
2015-04-14 16:36       ` David Laight
2015-04-14 16:59         ` Al Viro
2015-04-15  9:08           ` David Laight
2015-04-15  9:36             ` Daniel Borkmann
2015-04-15  9:53               ` David Laight
2015-04-11 21:18 ` [PATCH 16/17] get rid of the size argument of sock_sendmsg() Al Viro
2015-04-14 16:25   ` David Laight
2015-04-14 16:35     ` Al Viro
2015-04-14 16:44       ` Al Viro
2015-04-14 17:55       ` David Miller
2015-04-15  8:37         ` David Laight
2015-04-15 10:15           ` Eric Dumazet
2015-04-15 16:06           ` David Miller
2015-04-11 21:18 ` [PATCH 17/17] new helper: msg_data_left() Al Viro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1428787108-13650-9-git-send-email-viro@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).