summaryrefslogtreecommitdiff
path: root/net/rxrpc/ar-output.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2015-04-01 17:48:00 +0300
committerDavid Howells <dhowells@redhat.com>2015-04-01 17:48:00 +0300
commitaab94830a7fdf17aac07fea54d4cb43b0ad001b8 (patch)
treeff11c65eb69d92afe9ac4f265be9c6f64cb864fc /net/rxrpc/ar-output.c
parent3af6878ecad229346fbc2c8f2663089aa6aef20d (diff)
downloadlinux-aab94830a7fdf17aac07fea54d4cb43b0ad001b8.tar.xz
RxRPC: Don't call skb_add_data() if there's no data to copy
Don't call skb_add_data() in rxrpc_send_data() if there's no data to copy and also skip the calculations associated with it in such a case. Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'net/rxrpc/ar-output.c')
-rw-r--r--net/rxrpc/ar-output.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
index 833a33b5c180..f48dc1aa4840 100644
--- a/net/rxrpc/ar-output.c
+++ b/net/rxrpc/ar-output.c
@@ -549,8 +549,6 @@ static int rxrpc_send_data(struct kiocb *iocb,
if (len > iov_iter_count(&msg->msg_iter))
len = iov_iter_count(&msg->msg_iter);
do {
- int copy;
-
if (!skb) {
size_t size, chunk, max, space;
@@ -616,23 +614,25 @@ static int rxrpc_send_data(struct kiocb *iocb,
sp = rxrpc_skb(skb);
/* append next segment of data to the current buffer */
- copy = skb_tailroom(skb);
- ASSERTCMP(copy, >, 0);
- if (copy > len)
- copy = len;
- if (copy > sp->remain)
- copy = sp->remain;
-
- _debug("add");
- ret = skb_add_data(skb, &msg->msg_iter, copy);
- _debug("added");
- if (ret < 0)
- goto efault;
- sp->remain -= copy;
- skb->mark += copy;
- copied += copy;
-
- len -= copy;
+ if (len > 0) {
+ int copy = skb_tailroom(skb);
+ ASSERTCMP(copy, >, 0);
+ if (copy > len)
+ copy = len;
+ if (copy > sp->remain)
+ copy = sp->remain;
+
+ _debug("add");
+ ret = skb_add_data(skb, &msg->msg_iter, copy);
+ _debug("added");
+ if (ret < 0)
+ goto efault;
+ sp->remain -= copy;
+ skb->mark += copy;
+ copied += copy;
+
+ len -= copy;
+ }
/* check for the far side aborting the call or a network error
* occurring */