vmci: get rid of qp_memcpy_from_queue()
switch both of its users to qp_memcpy_from_queue_iov() - just make it take iov_iter * instead of msghdr * and arrange for a iov_iter for it in all cases. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
19c5b89d8d
commit
ce3d6e7d42
|
@ -441,13 +441,11 @@ static int __qp_memcpy_from_queue(void *dest,
|
||||||
to_copy = size - bytes_copied;
|
to_copy = size - bytes_copied;
|
||||||
|
|
||||||
if (is_iovec) {
|
if (is_iovec) {
|
||||||
struct msghdr *msg = dest;
|
struct iov_iter *to = dest;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
/* The iovec will track bytes_copied internally. */
|
err = copy_to_iter((u8 *)va + page_offset, to_copy, to);
|
||||||
err = memcpy_to_msg(msg, (u8 *)va + page_offset,
|
if (err != to_copy) {
|
||||||
to_copy);
|
|
||||||
if (err != 0) {
|
|
||||||
if (kernel_if->host)
|
if (kernel_if->host)
|
||||||
kunmap(kernel_if->u.h.page[page_index]);
|
kunmap(kernel_if->u.h.page[page_index]);
|
||||||
return VMCI_ERROR_INVALID_ARGS;
|
return VMCI_ERROR_INVALID_ARGS;
|
||||||
|
@ -577,15 +575,6 @@ static int qp_memcpy_to_queue(struct vmci_queue *queue,
|
||||||
(u8 *)src + src_offset, size, false);
|
(u8 *)src + src_offset, size, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qp_memcpy_from_queue(void *dest,
|
|
||||||
size_t dest_offset,
|
|
||||||
const struct vmci_queue *queue,
|
|
||||||
u64 queue_offset, size_t size)
|
|
||||||
{
|
|
||||||
return __qp_memcpy_from_queue((u8 *)dest + dest_offset,
|
|
||||||
queue, queue_offset, size, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copies from a given iovec from a VMCI Queue.
|
* Copies from a given iovec from a VMCI Queue.
|
||||||
*/
|
*/
|
||||||
|
@ -3159,18 +3148,22 @@ ssize_t vmci_qpair_dequeue(struct vmci_qp *qpair,
|
||||||
int buf_type)
|
int buf_type)
|
||||||
{
|
{
|
||||||
ssize_t result;
|
ssize_t result;
|
||||||
|
struct iov_iter to;
|
||||||
|
struct kvec v = {.iov_base = buf, .iov_len = buf_size};
|
||||||
|
|
||||||
if (!qpair || !buf)
|
if (!qpair || !buf)
|
||||||
return VMCI_ERROR_INVALID_ARGS;
|
return VMCI_ERROR_INVALID_ARGS;
|
||||||
|
|
||||||
|
iov_iter_kvec(&to, READ | ITER_KVEC, &v, 1, buf_size);
|
||||||
|
|
||||||
qp_lock(qpair);
|
qp_lock(qpair);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
result = qp_dequeue_locked(qpair->produce_q,
|
result = qp_dequeue_locked(qpair->produce_q,
|
||||||
qpair->consume_q,
|
qpair->consume_q,
|
||||||
qpair->consume_q_size,
|
qpair->consume_q_size,
|
||||||
buf, buf_size,
|
&to, buf_size,
|
||||||
qp_memcpy_from_queue, true);
|
qp_memcpy_from_queue_iov, true);
|
||||||
|
|
||||||
if (result == VMCI_ERROR_QUEUEPAIR_NOT_READY &&
|
if (result == VMCI_ERROR_QUEUEPAIR_NOT_READY &&
|
||||||
!qp_wait_for_ready_queue(qpair))
|
!qp_wait_for_ready_queue(qpair))
|
||||||
|
@ -3200,19 +3193,23 @@ ssize_t vmci_qpair_peek(struct vmci_qp *qpair,
|
||||||
size_t buf_size,
|
size_t buf_size,
|
||||||
int buf_type)
|
int buf_type)
|
||||||
{
|
{
|
||||||
|
struct iov_iter to;
|
||||||
|
struct kvec v = {.iov_base = buf, .iov_len = buf_size};
|
||||||
ssize_t result;
|
ssize_t result;
|
||||||
|
|
||||||
if (!qpair || !buf)
|
if (!qpair || !buf)
|
||||||
return VMCI_ERROR_INVALID_ARGS;
|
return VMCI_ERROR_INVALID_ARGS;
|
||||||
|
|
||||||
|
iov_iter_kvec(&to, READ | ITER_KVEC, &v, 1, buf_size);
|
||||||
|
|
||||||
qp_lock(qpair);
|
qp_lock(qpair);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
result = qp_dequeue_locked(qpair->produce_q,
|
result = qp_dequeue_locked(qpair->produce_q,
|
||||||
qpair->consume_q,
|
qpair->consume_q,
|
||||||
qpair->consume_q_size,
|
qpair->consume_q_size,
|
||||||
buf, buf_size,
|
&to, buf_size,
|
||||||
qp_memcpy_from_queue, false);
|
qp_memcpy_from_queue_iov, false);
|
||||||
|
|
||||||
if (result == VMCI_ERROR_QUEUEPAIR_NOT_READY &&
|
if (result == VMCI_ERROR_QUEUEPAIR_NOT_READY &&
|
||||||
!qp_wait_for_ready_queue(qpair))
|
!qp_wait_for_ready_queue(qpair))
|
||||||
|
@ -3295,7 +3292,7 @@ ssize_t vmci_qpair_dequev(struct vmci_qp *qpair,
|
||||||
result = qp_dequeue_locked(qpair->produce_q,
|
result = qp_dequeue_locked(qpair->produce_q,
|
||||||
qpair->consume_q,
|
qpair->consume_q,
|
||||||
qpair->consume_q_size,
|
qpair->consume_q_size,
|
||||||
msg, msg_data_left(msg),
|
&msg->msg_iter, msg_data_left(msg),
|
||||||
qp_memcpy_from_queue_iov,
|
qp_memcpy_from_queue_iov,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
|
@ -3339,7 +3336,7 @@ ssize_t vmci_qpair_peekv(struct vmci_qp *qpair,
|
||||||
result = qp_dequeue_locked(qpair->produce_q,
|
result = qp_dequeue_locked(qpair->produce_q,
|
||||||
qpair->consume_q,
|
qpair->consume_q,
|
||||||
qpair->consume_q_size,
|
qpair->consume_q_size,
|
||||||
msg, msg_data_left(msg),
|
&msg->msg_iter, msg_data_left(msg),
|
||||||
qp_memcpy_from_queue_iov,
|
qp_memcpy_from_queue_iov,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue