iov_iter: Separate type from direction and use accessor functions
In the iov_iter struct, separate the iterator type from the iterator direction and use accessor functions to access them in most places. Convert a bunch of places to use switch-statements to access them rather then chains of bitwise-AND statements. This makes it easier to add further iterator types. Also, this can be more efficient as to implement a switch of small contiguous integers, the compiler can use ~50% fewer compare instructions than it has to use bitwise-and instructions. Further, cease passing the iterator type into the iterator setup function. The iterator function can set that itself. Only the direction is required. Signed-off-by: David Howells <dhowells@redhat.com>
This commit is contained in:
@@ -286,7 +286,7 @@ static void afs_load_bvec(struct afs_call *call, struct msghdr *msg,
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
iov_iter_bvec(&msg->msg_iter, WRITE | ITER_BVEC, bv, nr, bytes);
|
||||
iov_iter_bvec(&msg->msg_iter, WRITE, bv, nr, bytes);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -401,8 +401,7 @@ long afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call,
|
||||
|
||||
msg.msg_name = NULL;
|
||||
msg.msg_namelen = 0;
|
||||
iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, iov, 1,
|
||||
call->request_size);
|
||||
iov_iter_kvec(&msg.msg_iter, WRITE, iov, 1, call->request_size);
|
||||
msg.msg_control = NULL;
|
||||
msg.msg_controllen = 0;
|
||||
msg.msg_flags = MSG_WAITALL | (call->send_pages ? MSG_MORE : 0);
|
||||
@@ -432,7 +431,7 @@ error_do_abort:
|
||||
rxrpc_kernel_abort_call(call->net->socket, rxcall,
|
||||
RX_USER_ABORT, ret, "KSD");
|
||||
} else {
|
||||
iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, NULL, 0, 0);
|
||||
iov_iter_kvec(&msg.msg_iter, READ, NULL, 0, 0);
|
||||
rxrpc_kernel_recv_data(call->net->socket, rxcall,
|
||||
&msg.msg_iter, false,
|
||||
&call->abort_code, &call->service_id);
|
||||
@@ -468,7 +467,7 @@ static void afs_deliver_to_call(struct afs_call *call)
|
||||
if (state == AFS_CALL_SV_AWAIT_ACK) {
|
||||
struct iov_iter iter;
|
||||
|
||||
iov_iter_kvec(&iter, READ | ITER_KVEC, NULL, 0, 0);
|
||||
iov_iter_kvec(&iter, READ, NULL, 0, 0);
|
||||
ret = rxrpc_kernel_recv_data(call->net->socket,
|
||||
call->rxcall, &iter, false,
|
||||
&remote_abort,
|
||||
@@ -825,7 +824,7 @@ void afs_send_empty_reply(struct afs_call *call)
|
||||
|
||||
msg.msg_name = NULL;
|
||||
msg.msg_namelen = 0;
|
||||
iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, NULL, 0, 0);
|
||||
iov_iter_kvec(&msg.msg_iter, WRITE, NULL, 0, 0);
|
||||
msg.msg_control = NULL;
|
||||
msg.msg_controllen = 0;
|
||||
msg.msg_flags = 0;
|
||||
@@ -864,7 +863,7 @@ void afs_send_simple_reply(struct afs_call *call, const void *buf, size_t len)
|
||||
iov[0].iov_len = len;
|
||||
msg.msg_name = NULL;
|
||||
msg.msg_namelen = 0;
|
||||
iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, iov, 1, len);
|
||||
iov_iter_kvec(&msg.msg_iter, WRITE, iov, 1, len);
|
||||
msg.msg_control = NULL;
|
||||
msg.msg_controllen = 0;
|
||||
msg.msg_flags = 0;
|
||||
@@ -905,7 +904,7 @@ int afs_extract_data(struct afs_call *call, void *buf, size_t count,
|
||||
|
||||
iov.iov_base = buf + call->offset;
|
||||
iov.iov_len = count - call->offset;
|
||||
iov_iter_kvec(&iter, ITER_KVEC | READ, &iov, 1, count - call->offset);
|
||||
iov_iter_kvec(&iter, READ, &iov, 1, count - call->offset);
|
||||
|
||||
ret = rxrpc_kernel_recv_data(net->socket, call->rxcall, &iter,
|
||||
want_more, &remote_abort,
|
||||
|
Reference in New Issue
Block a user