afs_send_pages(): use ITER_BVEC

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2016-01-09 20:36:51 -05:00
parent be6e4d66f0
commit 39c6aceae9
1 changed files with 7 additions and 8 deletions

View File

@ -249,8 +249,7 @@ void afs_flat_call_destructor(struct afs_call *call)
/* /*
* attach the data from a bunch of pages on an inode to a call * attach the data from a bunch of pages on an inode to a call
*/ */
static int afs_send_pages(struct afs_call *call, struct msghdr *msg, static int afs_send_pages(struct afs_call *call, struct msghdr *msg)
struct kvec *iov)
{ {
struct page *pages[8]; struct page *pages[8];
unsigned count, n, loop, offset, to; unsigned count, n, loop, offset, to;
@ -273,20 +272,21 @@ static int afs_send_pages(struct afs_call *call, struct msghdr *msg,
loop = 0; loop = 0;
do { do {
struct bio_vec bvec = {.bv_page = pages[loop],
.bv_offset = offset};
msg->msg_flags = 0; msg->msg_flags = 0;
to = PAGE_SIZE; to = PAGE_SIZE;
if (first + loop >= last) if (first + loop >= last)
to = call->last_to; to = call->last_to;
else else
msg->msg_flags = MSG_MORE; msg->msg_flags = MSG_MORE;
iov->iov_base = kmap(pages[loop]) + offset; bvec.bv_len = to - offset;
iov->iov_len = to - offset;
offset = 0; offset = 0;
_debug("- range %u-%u%s", _debug("- range %u-%u%s",
offset, to, msg->msg_flags ? " [more]" : ""); offset, to, msg->msg_flags ? " [more]" : "");
iov_iter_kvec(&msg->msg_iter, WRITE | ITER_KVEC, iov_iter_bvec(&msg->msg_iter, WRITE | ITER_BVEC,
iov, 1, to - offset); &bvec, 1, to - offset);
/* have to change the state *before* sending the last /* have to change the state *before* sending the last
* packet as RxRPC might give us the reply before it * packet as RxRPC might give us the reply before it
@ -295,7 +295,6 @@ static int afs_send_pages(struct afs_call *call, struct msghdr *msg,
call->state = AFS_CALL_AWAIT_REPLY; call->state = AFS_CALL_AWAIT_REPLY;
ret = rxrpc_kernel_send_data(afs_socket, call->rxcall, ret = rxrpc_kernel_send_data(afs_socket, call->rxcall,
msg, to - offset); msg, to - offset);
kunmap(pages[loop]);
if (ret < 0) if (ret < 0)
break; break;
} while (++loop < count); } while (++loop < count);
@ -379,7 +378,7 @@ int afs_make_call(struct in_addr *addr, struct afs_call *call, gfp_t gfp,
goto error_do_abort; goto error_do_abort;
if (call->send_pages) { if (call->send_pages) {
ret = afs_send_pages(call, &msg, iov); ret = afs_send_pages(call, &msg);
if (ret < 0) if (ret < 0)
goto error_do_abort; goto error_do_abort;
} }