diff mbox series

[v2,10/12,xen] fix "direction" argument of iov_iter_kvec()

Message ID 20221028023352.3532080-10-viro@zeniv.linux.org.uk (mailing list archive)
State New, archived
Headers show
Series [v2,01/12] get rid of unlikely() on page_copy_sane() calls | expand

Commit Message

Al Viro Oct. 28, 2022, 2:33 a.m. UTC
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 drivers/xen/pvcalls-back.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

John Stoffel Oct. 28, 2022, 12:48 p.m. UTC | #1
On Fri, Oct 28, 2022 at 03:33:50AM +0100, Al Viro wrote:
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
> ---
>  drivers/xen/pvcalls-back.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/xen/pvcalls-back.c b/drivers/xen/pvcalls-back.c
> index d6f945fd4147..21b9c850a382 100644
> --- a/drivers/xen/pvcalls-back.c
> +++ b/drivers/xen/pvcalls-back.c
> @@ -129,13 +129,13 @@ static bool pvcalls_conn_back_read(void *opaque)
>  	if (masked_prod < masked_cons) {
>  		vec[0].iov_base = data->in + masked_prod;
>  		vec[0].iov_len = wanted;
> -		iov_iter_kvec(&msg.msg_iter, WRITE, vec, 1, wanted);
> +		iov_iter_kvec(&msg.msg_iter, READ, vec, 1, wanted);


Wouldn't it make more sense to use READER and WRITER here, since the
current READ/WRITE are 100% non-obvious?  This is probably a bigger
change, but this just looks wrong and will be so easy for people to
screw up again and again down the line.


>  	} else {
>  		vec[0].iov_base = data->in + masked_prod;
>  		vec[0].iov_len = array_size - masked_prod;
>  		vec[1].iov_base = data->in;
>  		vec[1].iov_len = wanted - vec[0].iov_len;
> -		iov_iter_kvec(&msg.msg_iter, WRITE, vec, 2, wanted);
> +		iov_iter_kvec(&msg.msg_iter, READ, vec, 2, wanted);
>  	}
>  
>  	atomic_set(&map->read, 0);
> @@ -188,13 +188,13 @@ static bool pvcalls_conn_back_write(struct sock_mapping *map)
>  	if (pvcalls_mask(prod, array_size) > pvcalls_mask(cons, array_size)) {
>  		vec[0].iov_base = data->out + pvcalls_mask(cons, array_size);
>  		vec[0].iov_len = size;
> -		iov_iter_kvec(&msg.msg_iter, READ, vec, 1, size);
> +		iov_iter_kvec(&msg.msg_iter, WRITE, vec, 1, size);
>  	} else {
>  		vec[0].iov_base = data->out + pvcalls_mask(cons, array_size);
>  		vec[0].iov_len = array_size - pvcalls_mask(cons, array_size);
>  		vec[1].iov_base = data->out;
>  		vec[1].iov_len = size - vec[0].iov_len;
> -		iov_iter_kvec(&msg.msg_iter, READ, vec, 2, size);
> +		iov_iter_kvec(&msg.msg_iter, WRITE, vec, 2, size);
>  	}
>  
>  	atomic_set(&map->write, 0);
> -- 
> 2.30.2
> 

--
John Stoffel Oct. 28, 2022, 12:49 p.m. UTC | #2
On Fri, Oct 28, 2022 at 08:48:22AM -0400, John Stoffel wrote:
> On Fri, Oct 28, 2022 at 03:33:50AM +0100, Al Viro wrote:
> > Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
> > ---
> >  drivers/xen/pvcalls-back.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/xen/pvcalls-back.c b/drivers/xen/pvcalls-back.c
> > index d6f945fd4147..21b9c850a382 100644
> > --- a/drivers/xen/pvcalls-back.c
> > +++ b/drivers/xen/pvcalls-back.c
> > @@ -129,13 +129,13 @@ static bool pvcalls_conn_back_read(void *opaque)
> >  	if (masked_prod < masked_cons) {
> >  		vec[0].iov_base = data->in + masked_prod;
> >  		vec[0].iov_len = wanted;
> > -		iov_iter_kvec(&msg.msg_iter, WRITE, vec, 1, wanted);
> > +		iov_iter_kvec(&msg.msg_iter, READ, vec, 1, wanted);
> 
> 
> Wouldn't it make more sense to use READER and WRITER here, since the
> current READ/WRITE are 100% non-obvious?  This is probably a bigger
> change, but this just looks wrong and will be so easy for people to
> screw up again and again down the line.

And if I had only made it down to patch 12, I would have seen that you
fixed this.  Sorry for the noise!
diff mbox series

Patch

diff --git a/drivers/xen/pvcalls-back.c b/drivers/xen/pvcalls-back.c
index d6f945fd4147..21b9c850a382 100644
--- a/drivers/xen/pvcalls-back.c
+++ b/drivers/xen/pvcalls-back.c
@@ -129,13 +129,13 @@  static bool pvcalls_conn_back_read(void *opaque)
 	if (masked_prod < masked_cons) {
 		vec[0].iov_base = data->in + masked_prod;
 		vec[0].iov_len = wanted;
-		iov_iter_kvec(&msg.msg_iter, WRITE, vec, 1, wanted);
+		iov_iter_kvec(&msg.msg_iter, READ, vec, 1, wanted);
 	} else {
 		vec[0].iov_base = data->in + masked_prod;
 		vec[0].iov_len = array_size - masked_prod;
 		vec[1].iov_base = data->in;
 		vec[1].iov_len = wanted - vec[0].iov_len;
-		iov_iter_kvec(&msg.msg_iter, WRITE, vec, 2, wanted);
+		iov_iter_kvec(&msg.msg_iter, READ, vec, 2, wanted);
 	}
 
 	atomic_set(&map->read, 0);
@@ -188,13 +188,13 @@  static bool pvcalls_conn_back_write(struct sock_mapping *map)
 	if (pvcalls_mask(prod, array_size) > pvcalls_mask(cons, array_size)) {
 		vec[0].iov_base = data->out + pvcalls_mask(cons, array_size);
 		vec[0].iov_len = size;
-		iov_iter_kvec(&msg.msg_iter, READ, vec, 1, size);
+		iov_iter_kvec(&msg.msg_iter, WRITE, vec, 1, size);
 	} else {
 		vec[0].iov_base = data->out + pvcalls_mask(cons, array_size);
 		vec[0].iov_len = array_size - pvcalls_mask(cons, array_size);
 		vec[1].iov_base = data->out;
 		vec[1].iov_len = size - vec[0].iov_len;
-		iov_iter_kvec(&msg.msg_iter, READ, vec, 2, size);
+		iov_iter_kvec(&msg.msg_iter, WRITE, vec, 2, size);
 	}
 
 	atomic_set(&map->write, 0);