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:
@@ -526,7 +526,7 @@ static int ceph_tcp_recvmsg(struct socket *sock, void *buf, size_t len)
|
||||
if (!buf)
|
||||
msg.msg_flags |= MSG_TRUNC;
|
||||
|
||||
iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &iov, 1, len);
|
||||
iov_iter_kvec(&msg.msg_iter, READ, &iov, 1, len);
|
||||
r = sock_recvmsg(sock, &msg, msg.msg_flags);
|
||||
if (r == -EAGAIN)
|
||||
r = 0;
|
||||
@@ -545,7 +545,7 @@ static int ceph_tcp_recvpage(struct socket *sock, struct page *page,
|
||||
int r;
|
||||
|
||||
BUG_ON(page_offset + length > PAGE_SIZE);
|
||||
iov_iter_bvec(&msg.msg_iter, READ | ITER_BVEC, &bvec, 1, length);
|
||||
iov_iter_bvec(&msg.msg_iter, READ, &bvec, 1, length);
|
||||
r = sock_recvmsg(sock, &msg, msg.msg_flags);
|
||||
if (r == -EAGAIN)
|
||||
r = 0;
|
||||
@@ -607,7 +607,7 @@ static int ceph_tcp_sendpage(struct socket *sock, struct page *page,
|
||||
else
|
||||
msg.msg_flags |= MSG_EOR; /* superfluous, but what the hell */
|
||||
|
||||
iov_iter_bvec(&msg.msg_iter, WRITE | ITER_BVEC, &bvec, 1, size);
|
||||
iov_iter_bvec(&msg.msg_iter, WRITE, &bvec, 1, size);
|
||||
ret = sock_sendmsg(sock, &msg);
|
||||
if (ret == -EAGAIN)
|
||||
ret = 0;
|
||||
|
Reference in New Issue
Block a user