提交 aab94830 编写于 作者: D David Howells

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: NDavid Howells <dhowells@redhat.com>
上级 3af6878e
...@@ -549,8 +549,6 @@ static int rxrpc_send_data(struct kiocb *iocb, ...@@ -549,8 +549,6 @@ static int rxrpc_send_data(struct kiocb *iocb,
if (len > iov_iter_count(&msg->msg_iter)) if (len > iov_iter_count(&msg->msg_iter))
len = iov_iter_count(&msg->msg_iter); len = iov_iter_count(&msg->msg_iter);
do { do {
int copy;
if (!skb) { if (!skb) {
size_t size, chunk, max, space; size_t size, chunk, max, space;
...@@ -616,23 +614,25 @@ static int rxrpc_send_data(struct kiocb *iocb, ...@@ -616,23 +614,25 @@ static int rxrpc_send_data(struct kiocb *iocb,
sp = rxrpc_skb(skb); sp = rxrpc_skb(skb);
/* append next segment of data to the current buffer */ /* append next segment of data to the current buffer */
copy = skb_tailroom(skb); if (len > 0) {
ASSERTCMP(copy, >, 0); int copy = skb_tailroom(skb);
if (copy > len) ASSERTCMP(copy, >, 0);
copy = len; if (copy > len)
if (copy > sp->remain) copy = len;
copy = sp->remain; if (copy > sp->remain)
copy = sp->remain;
_debug("add");
ret = skb_add_data(skb, &msg->msg_iter, copy); _debug("add");
_debug("added"); ret = skb_add_data(skb, &msg->msg_iter, copy);
if (ret < 0) _debug("added");
goto efault; if (ret < 0)
sp->remain -= copy; goto efault;
skb->mark += copy; sp->remain -= copy;
copied += copy; skb->mark += copy;
copied += copy;
len -= copy;
len -= copy;
}
/* check for the far side aborting the call or a network error /* check for the far side aborting the call or a network error
* occurring */ * occurring */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册