Skip to content

Commit

Permalink
RxRPC: Don't call skb_add_data() if there's no data to copy
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dhowells committed Apr 1, 2015
1 parent 3af6878 commit aab9483
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions net/rxrpc/ar-output.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit aab9483

Please sign in to comment.