virtiofsd: Few cleanups in virtio_send_data_iov()
cover virtiofsd: Few cleanups in virtio_send_data_iov()
Hi,
Code in virtio_send_data_iov() little twisted and complicated. This patch series just tries to simplify it a bit to make it little easier to read this piece of code.
Thanks
Vivek
Vivek Goyal (7):
virtiofsd: Check for EINTR in preadv() and retry
virtiofsd: Get rid of unreachable code in read
virtiofsd: Use iov_discard_front() to skip bytes
virtiofsd: get rid of in_sg_left variable
virtiofsd: Simplify skip byte logic
virtiofsd: Check EOF before short read
virtiofsd: Set req->reply_sent right after sending reply
tools/virtiofsd/fuse_virtio.c | 67 +++++++++++------------------------ 1 file changed, 21 insertions(+), 46 deletions(-)
Signature · 1 line
2.25.4
PATCH 1/7 virtiofsd: Check for EINTR in preadv() and retry
We don't seem to check for EINTR and retry. There are other places in code where we check for EINTR. So lets add a check.
--- tools/virtiofsd/fuse_virtio.c | 3 +++ 1 file changed, 3 insertions(+)
tools/virtiofsd/fuse_virtio.c +3 -0
@@ -421,6 +421,9 @@ int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch,if (ret ==-1 ) { ret = errno; +if (ret ==EINTR ) { +continue ; + }fuse_log (FUSE_LOG_DEBUG ,"%s: preadv failed (%m) len=%zd\n" , __func__, len); goto err;
Signature · 1 line
2.25.4
Re: [PATCH 1/7] virtiofsd: Check for EINTR in preadv() and retry
Quoted 4 lines · * Vivek Goyal ([email protected]) wrote:
We don't seem to check for EINTR and retry. There are other places in code where we check for EINTR. So lets add a check.
Signed-off-by Vivek Goyal <[email protected]>
Quoted 21 lines
--- tools/virtiofsd/fuse_virtio.c | 3 +++ 1 file changed, 3 insertions(+)tools/virtiofsd/fuse_virtio.c +3
-0@@ -421,6 +421,9 @@ int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch,if (ret ==-1 ) { ret = errno; +if (ret ==EINTR ) { +continue ; + }fuse_log (FUSE_LOG_DEBUG ,"%s: preadv failed (%m) len=%zd\n" , __func__, len); goto err;Signature · 1 line
2.25.4
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 2/7 virtiofsd: Get rid of unreachable code in read
In reply to Vivek Goyalpvreadv() can return following.
- error
- 0 in case of EOF
- short read
We seem to handle all the cases already. We are retrying read in case of short read. So another check for short read seems like dead code. Get rid of it.
--- tools/virtiofsd/fuse_virtio.c | 5 ----- 1 file changed, 5 deletions(-)
tools/virtiofsd/fuse_virtio.c +0 -5
@@ -446,11 +446,6 @@ int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch, in_sg_left);break ; } -if (ret != len) { -fuse_log (FUSE_LOG_DEBUG ,"%s: ret!=len\n" , __func__); - ret =EIO ; - goto err; - } in_sg_left -= ret; len -= ret; }while (in_sg_left);
Signature · 1 line
2.25.4
Re: [PATCH 2/7] virtiofsd: Get rid of unreachable code in read
Quoted 11 lines · * Vivek Goyal ([email protected]) wrote:
pvreadv()can return following.- error
- 0 in case of EOF
- short readWe seem to handle all the cases already. We are retrying read in case of short read. So another check for short read seems like dead code. Get rid of it.
Signed-off-by Vivek Goyal <[email protected]>
Quoted 23 lines
--- tools/virtiofsd/fuse_virtio.c | 5 ----- 1 file changed, 5 deletions(-)tools/virtiofsd/fuse_virtio.c +0
-5@@ -446,11 +446,6 @@ int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch, in_sg_left);break ; } -if (ret != len) { -fuse_log (FUSE_LOG_DEBUG ,"%s: ret!=len\n" , __func__); - ret =EIO ; - goto err; - } in_sg_left -= ret; len -= ret; }while (in_sg_left);Signature · 1 line
2.25.4
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 3/7 virtiofsd: Use iov_discard_front() to skip bytes
In reply to Vivek GoyalThere are places where we need to skip few bytes from front of the iovec array. We have our own custom code for that. Looks like iov_discard_front() can do same thing. So use that helper instead.
--- tools/virtiofsd/fuse_virtio.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
tools/virtiofsd/fuse_virtio.c +3 -11
@@ -389,23 +389,15 @@ int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch,memcpy (in_sg_cpy, in_sg,sizeof (struct iovec ) * in_num);/* These get updated as we skip */ struct iovec *in_sg_ptr = in_sg_cpy; -int in_sg_cpy_count = in_num; +unsigned int in_sg_cpy_count = in_num;/* skip over parts of in_sg that contained the header iov */ size_t skip_size = iov_len;size_t in_sg_left =0 ; do { - while (skip_size != 0 && in_sg_cpy_count) { - if (skip_size >= in_sg_ptr[0].iov_len) { - skip_size -= in_sg_ptr[0].iov_len; - in_sg_ptr++; - in_sg_cpy_count--; - } else { - in_sg_ptr[0].iov_len -= skip_size; - in_sg_ptr[0].iov_base += skip_size; - break; - } + if (skip_size != 0) { + iov_discard_front(&in_sg_ptr, &in_sg_cpy_count, skip_size); } int i;
Signature · 1 line
2.25.4
Re: [PATCH 3/7] virtiofsd: Use iov_discard_front() to skip bytes
Quoted 5 lines · * Vivek Goyal ([email protected]) wrote:
There are places where we need to skip few bytes from front of the iovec array. We have our own custom code for that. Looks like
iov_discard_front()can do same thing. So use that helper instead.Signed-off-by Vivek Goyal <[email protected]>
Oh nice; I hadn't noticed that file; I bet there are loads of other places that can use it (and I still don't get why iov functions aren't part of libc)
Quoted 38 lines
--- tools/virtiofsd/fuse_virtio.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)tools/virtiofsd/fuse_virtio.c +3
-11@@ -389,23 +389,15 @@ int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch,memcpy (in_sg_cpy, in_sg,sizeof (struct iovec ) * in_num);/* These get updated as we skip */ struct iovec *in_sg_ptr = in_sg_cpy; -int in_sg_cpy_count = in_num; +unsigned int in_sg_cpy_count = in_num;/* skip over parts of in_sg that contained the header iov */ size_t skip_size = iov_len;size_t in_sg_left =0 ; do { - while (skip_size != 0 && in_sg_cpy_count) { - if (skip_size >= in_sg_ptr[0].iov_len) { - skip_size -= in_sg_ptr[0].iov_len; - in_sg_ptr++; - in_sg_cpy_count--; - } else { - in_sg_ptr[0].iov_len -= skip_size; - in_sg_ptr[0].iov_base += skip_size; - break; - } + if (skip_size != 0) { + iov_discard_front(&in_sg_ptr, &in_sg_cpy_count, skip_size); } int i;Signature · 1 line
2.25.4
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 4/7 virtiofsd: get rid of in_sg_left variable
In reply to Vivek Goyalin_sg_left seems to be being used primarly for debugging purpose. It is keeping track of how many bytes are left in the scatter list we are reading into.
We already have another variable "len" which keeps track how many bytes are left to be read. And in_sg_left is greater than or equal to len. We have already ensured that in the beginning of function.
if (in_len < tosend_len) {
fuse_log(FUSE_LOG_ERR, "%s: elem %d too small for data len %zd\n",
__func__, elem->index, tosend_len);
ret = E2BIG;
goto err;
}So in_sg_left seems like a redundant variable. It probably was useful for debugging when code was being developed. Get rid of it. It helps simplify this function.
--- tools/virtiofsd/fuse_virtio.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
tools/virtiofsd/fuse_virtio.c +6 -11
@@ -394,20 +394,16 @@ int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch,/* skip over parts of in_sg that contained the header iov */ size_t skip_size = iov_len; -size_t in_sg_left =0 ; do { if (skip_size != 0) { iov_discard_front(&in_sg_ptr, &in_sg_cpy_count, skip_size); } - int i; - for (i = 0, in_sg_left = 0; i < in_sg_cpy_count; i++) { - in_sg_left += in_sg_ptr[i].iov_len; - } fuse_log(FUSE_LOG_DEBUG, "%s: after skip skip_size=%zd in_sg_cpy_count=%d " - "in_sg_left=%zd\n", - __func__, skip_size, in_sg_cpy_count, in_sg_left); + "len remaining=%zd\n", __func__, skip_size, in_sg_cpy_count, + len); + ret = preadv(buf->buf[0].fd, in_sg_ptr, in_sg_cpy_count, buf->buf[0].pos);
@@ -434,13 +430,12 @@ int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch, }if (!ret) {/* EOF case? */ -fuse_log (FUSE_LOG_DEBUG ,"%s: !ret in_sg_left=%zd\n" , __func__, - in_sg_left); +fuse_log (FUSE_LOG_DEBUG ,"%s: !ret len remaining=%zd\n" , __func__, + len);break ; } - in_sg_left -= ret; len -= ret; - }while (in_sg_left); + }while (len);/* Need to fix out->len on EOF */ if (len) {
Signature · 1 line
2.25.4
Re: [PATCH 4/7] virtiofsd: get rid of in_sg_left variable
Quoted 15 lines · * Vivek Goyal ([email protected]) wrote:
in_sg_leftseems to be being used primarly for debugging purpose. It is keeping track of how many bytes are left in the scatter list we are reading into.We already have another variable "len" which keeps track how many bytes are left to be read. And
in_sg_leftis greater than or equal to len. We have already ensured that in the beginning of function.if (in_len < tosend_len) { fuse_log(FUSE_LOG_ERR, "%s: elem %d too small for data len %zd\n", __func__, elem->index, tosend_len); ret = E2BIG; goto err; }
Quoted 5 lines
So
in_sg_leftseems like a redundant variable. It probably was useful for debugging when code was being developed. Get rid of it. It helps simplify this function.Signed-off-by Vivek Goyal <[email protected]>
Quoted 52 lines
--- tools/virtiofsd/fuse_virtio.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)tools/virtiofsd/fuse_virtio.c +6
-11@@ -394,20 +394,16 @@ int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch,/* skip over parts of in_sg that contained the header iov */ size_t skip_size = iov_len; -size_t in_sg_left =0 ; do { if (skip_size != 0) { iov_discard_front(&in_sg_ptr, &in_sg_cpy_count, skip_size); } - int i; - for (i = 0, in_sg_left = 0; i < in_sg_cpy_count; i++) { - in_sg_left += in_sg_ptr[i].iov_len; - } fuse_log(FUSE_LOG_DEBUG, "%s: after skip skip_size=%zd in_sg_cpy_count=%d " - "in_sg_left=%zd\n", - __func__, skip_size, in_sg_cpy_count, in_sg_left); + "len remaining=%zd\n", __func__, skip_size, in_sg_cpy_count, + len); + ret = preadv(buf->buf[0].fd, in_sg_ptr, in_sg_cpy_count, buf->buf[0].pos);@@ -434,13 +430,12 @@ int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch, }if (!ret) {/* EOF case? */ -fuse_log (FUSE_LOG_DEBUG ,"%s: !ret in_sg_left=%zd\n" , __func__, - in_sg_left); +fuse_log (FUSE_LOG_DEBUG ,"%s: !ret len remaining=%zd\n" , __func__, + len);break ; } - in_sg_left -= ret; len -= ret; - }while (in_sg_left); + }while (len);/* Need to fix out->len on EOF */ if (len) {Signature · 1 line
2.25.4
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 5/7 virtiofsd: Simplify skip byte logic
In reply to Vivek GoyalWe need to skip bytes in two cases.
a. Before we start reading into in_sg, we need to skip iov_len bytes
in the beginning which typically will have fuse_out_header.
b. If preadv() does a short read, then we need to retry preadv() with
remainig bytes and skip the bytes preadv() read in short read.
For case a, there is no reason that skipping logic be inside the while loop. Move it outside. And only retain logic "b" inside while loop.
Also get rid of variable "skip_size". Looks like we can do without it.
--- tools/virtiofsd/fuse_virtio.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
tools/virtiofsd/fuse_virtio.c +4 -10
@@ -392,17 +392,11 @@ int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch,unsigned int in_sg_cpy_count = in_num;/* skip over parts of in_sg that contained the header iov */ -size_t skip_size = iov_len; +iov_discard_front (&in_sg_ptr, &in_sg_cpy_count, iov_len); do { - if (skip_size != 0) { - iov_discard_front(&in_sg_ptr, &in_sg_cpy_count, skip_size); - } - - fuse_log(FUSE_LOG_DEBUG, - "%s: after skip skip_size=%zd in_sg_cpy_count=%d " - "len remaining=%zd\n", __func__, skip_size, in_sg_cpy_count, - len); + fuse_log(FUSE_LOG_DEBUG, "%s: in_sg_cpy_count=%d len remaining=%zd\n", + __func__, in_sg_cpy_count, len); ret = preadv(buf->buf[0].fd, in_sg_ptr, in_sg_cpy_count, buf->buf[0].pos);
@@ -421,7 +415,7 @@ int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch,if (ret < len && ret) {fuse_log (FUSE_LOG_DEBUG ,"%s: ret < len\n" , __func__);/* Skip over this much next time around */ - skip_size = ret; +iov_discard_front (&in_sg_ptr, &in_sg_cpy_count, ret); buf->buf[0 ].pos += ret; len -= ret;
Signature · 1 line
2.25.4
Re: [PATCH 5/7] virtiofsd: Simplify skip byte logic
Quoted 8 lines · * Vivek Goyal ([email protected]) wrote:
We need to skip bytes in two cases.
a. Before we start reading into
in_sg, we need to skipiov_lenbytes
in the beginning which typically will havefuse_out_header.b. If
preadv()does a short read, then we need to retrypreadv()with
remainig bytes and skip the bytespreadv()read in short read.
Quoted 6 lines
For case a, there is no reason that skipping logic be inside the while loop. Move it outside. And only retain logic "b" inside while loop.
Also get rid of variable "
skip_size". Looks like we can do without it.Signed-off-by Vivek Goyal <[email protected]>
Yep, now iov_discard_front makes it easy to skip.
Quoted 41 lines
--- tools/virtiofsd/fuse_virtio.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)tools/virtiofsd/fuse_virtio.c +4
-10@@ -392,17 +392,11 @@ int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch,unsigned int in_sg_cpy_count = in_num;/* skip over parts of in_sg that contained the header iov */ -size_t skip_size = iov_len; +iov_discard_front (&in_sg_ptr, &in_sg_cpy_count, iov_len); do { - if (skip_size != 0) { - iov_discard_front(&in_sg_ptr, &in_sg_cpy_count, skip_size); - } - - fuse_log(FUSE_LOG_DEBUG, - "%s: after skip skip_size=%zd in_sg_cpy_count=%d " - "len remaining=%zd\n", __func__, skip_size, in_sg_cpy_count, - len); + fuse_log(FUSE_LOG_DEBUG, "%s: in_sg_cpy_count=%d len remaining=%zd\n", + __func__, in_sg_cpy_count, len); ret = preadv(buf->buf[0].fd, in_sg_ptr, in_sg_cpy_count, buf->buf[0].pos);@@ -421,7 +415,7 @@ int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch,if (ret < len && ret) {fuse_log (FUSE_LOG_DEBUG ,"%s: ret < len\n" , __func__);/* Skip over this much next time around */ - skip_size = ret; +iov_discard_front (&in_sg_ptr, &in_sg_cpy_count, ret); buf->buf[0 ].pos += ret; len -= ret;Signature · 1 line
2.25.4
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 6/7 virtiofsd: Check EOF before short read
In reply to Vivek GoyalIn virtio_send_data_iov() we are checking first for short read and then EOF condition. Change the order. Basically check for error and EOF first and last remaining piece is short ready which will lead to retry automatically at the end of while loop.
Just that it is little simpler to read to the code. There is no need to call "continue" and also one less call of "len-=ret".
--- tools/virtiofsd/fuse_virtio.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
tools/virtiofsd/fuse_virtio.c +10 -11
@@ -410,25 +410,24 @@ int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch, __func__, len); goto err; } -fuse_log (FUSE_LOG_DEBUG ,"%s: preadv ret=%d len=%zd\n" , __func__, - ret, len); -if (ret < len && ret) { -fuse_log (FUSE_LOG_DEBUG ,"%s: ret < len\n" , __func__); -/* Skip over this much next time around */ -iov_discard_front (&in_sg_ptr, &in_sg_cpy_count, ret); - buf->buf[0 ].pos += ret; - len -= ret; -/* Lets do another read */ -continue ; - }if (!ret) {/* EOF case? */ fuse_log (FUSE_LOG_DEBUG ,"%s: !ret len remaining=%zd\n" , __func__, len);break ; } +fuse_log (FUSE_LOG_DEBUG ,"%s: preadv ret=%d len=%zd\n" , __func__, + ret, len); + len -= ret; +/* Short read. Retry reading remaining bytes */ +if (len) { +fuse_log (FUSE_LOG_DEBUG ,"%s: ret < len\n" , __func__); +/* Skip over this much next time around */ +iov_discard_front (&in_sg_ptr, &in_sg_cpy_count, ret); + buf->buf[0 ].pos += ret; + } }while (len);/* Need to fix out->len on EOF */
Signature · 1 line
2.25.4
Re: [PATCH 6/7] virtiofsd: Check EOF before short read
Quoted 9 lines · * Vivek Goyal ([email protected]) wrote:
In
virtio_send_data_iov()we are checking first for short read and then EOF condition. Change the order. Basically check for error and EOF first and last remaining piece is short ready which will lead to retry automatically at the end of while loop.Just that it is little simpler to read to the code. There is no need to call "continue" and also one less call of "len-=ret".
Signed-off-by Vivek Goyal <[email protected]>
Quoted 47 lines
--- tools/virtiofsd/fuse_virtio.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)tools/virtiofsd/fuse_virtio.c +10
-11@@ -410,25 +410,24 @@ int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch, __func__, len); goto err; } -fuse_log (FUSE_LOG_DEBUG ,"%s: preadv ret=%d len=%zd\n" , __func__, - ret, len); -if (ret < len && ret) { -fuse_log (FUSE_LOG_DEBUG ,"%s: ret < len\n" , __func__); -/* Skip over this much next time around */ -iov_discard_front (&in_sg_ptr, &in_sg_cpy_count, ret); - buf->buf[0 ].pos += ret; - len -= ret; -/* Lets do another read */ -continue ; - }if (!ret) {/* EOF case? */ fuse_log (FUSE_LOG_DEBUG ,"%s: !ret len remaining=%zd\n" , __func__, len);break ; } +fuse_log (FUSE_LOG_DEBUG ,"%s: preadv ret=%d len=%zd\n" , __func__, + ret, len); + len -= ret; +/* Short read. Retry reading remaining bytes */ +if (len) { +fuse_log (FUSE_LOG_DEBUG ,"%s: ret < len\n" , __func__); +/* Skip over this much next time around */ +iov_discard_front (&in_sg_ptr, &in_sg_cpy_count, ret); + buf->buf[0 ].pos += ret; + } }while (len);/* Need to fix out->len on EOF */ Signature · 1 line
2.25.4
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
PATCH 7/7 virtiofsd: Set req->reply_sent right after sending reply
In reply to Vivek GoyalThere is no reason to set it in label "err". We should be able to set it right after sending reply. It is easier to read.
--- tools/virtiofsd/fuse_virtio.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
tools/virtiofsd/fuse_virtio.c +1 -4
@@ -446,12 +446,9 @@ int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch,vu_queue_notify (dev, q);pthread_mutex_unlock (&qi->vq_lock);vu_dispatch_unlock (qi->virtio_dev); + req->reply_sent = true; err: -if (ret ==0 ) { - req->reply_sent = true; - } -return ret; }
Signature · 1 line
2.25.4
Re: [Virtio-fs] [PATCH 7/7] virtiofsd: Set req->reply_sent right after sending reply
Quoted 13 lines · Vivek Goyal
There is no reason to set it in label "err". We should be able to set it right after sending reply. It is easier to read.
Signed-off-by Vivek Goyal <[email protected]>--- tools/virtiofsd/fuse_virtio.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)tools/virtiofsd/fuse_virtio.c +0
-0
tools/virtiofsd/fuse_virtio.c int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch, · line 451
Quoted 6 lines
tools/virtiofsd/fuse_virtio.c +1
-0@@ -446,12 +446,9 @@ int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch,vu_queue_notify (dev, q);pthread_mutex_unlock (&qi->vq_lock);vu_dispatch_unlock (qi->virtio_dev); + req->reply_sent = true; err:
Just a really minor comment: after all these changes, I would venture that "out" is a more appropriate label name than "err" at this point.
Quoted 8 lines
tools/virtiofsd/fuse_virtio.c +0
-4-if (ret ==0 ) { - req->reply_sent = true; - } -return ret; }
Re: [Virtio-fs] [PATCH 7/7] virtiofsd: Set req->reply_sent right after sending reply
Quoted 19 lines · Connor Kuehl
Quoted 18 lines · Vivek Goyal
There is no reason to set it in label "err". We should be able to set it right after sending reply. It is easier to read.
Signed-off-by Vivek Goyal <[email protected]>--- tools/virtiofsd/fuse_virtio.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)tools/virtiofsd/fuse_virtio.c +1
-0@@ -446,12 +446,9 @@ int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch,vu_queue_notify (dev, q);pthread_mutex_unlock (&qi->vq_lock);vu_dispatch_unlock (qi->virtio_dev); + req->reply_sent = true;
Quoted 4 lines
tools/virtiofsd/fuse_virtio.c int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch, · line 451
Quoted 1 line
tools/virtiofsd/fuse_virtio.c +0
-0err:Just a really minor comment: after all these changes, I would venture that "out" is a more appropriate label name than "err" at this point.
May be. This path is used both by error path as well as success path. Just that value of "ret" changes. I am not particular about it. So I will change this to "out".
Thanks
Vivek
Quoted 10 lines
Quoted 9 lines
tools/virtiofsd/fuse_virtio.c +0
-4-if (ret ==0 ) { - req->reply_sent = true; - } -return ret; }
Re: [Virtio-fs] [PATCH 7/7] virtiofsd: Set req->reply_sent right after sending reply
Quoted 20 lines · * Vivek Goyal ([email protected]) wrote:
Quoted 19 lines · Connor Kuehl
Quoted 18 lines · Vivek Goyal
There is no reason to set it in label "err". We should be able to set it right after sending reply. It is easier to read.
Signed-off-by Vivek Goyal <[email protected]>--- tools/virtiofsd/fuse_virtio.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)tools/virtiofsd/fuse_virtio.c +1
-0@@ -446,12 +446,9 @@ int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch,vu_queue_notify (dev, q);pthread_mutex_unlock (&qi->vq_lock);vu_dispatch_unlock (qi->virtio_dev); + req->reply_sent = true;
Quoted 8 lines
Quoted 4 lines
tools/virtiofsd/fuse_virtio.c int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch, · line 451
Quoted 1 line
tools/virtiofsd/fuse_virtio.c +0
-0err:Just a really minor comment: after all these changes, I would venture that "out" is a more appropriate label name than "err" at this point.
May be. This path is used both by error path as well as success path. Just that value of "ret" changes. I am not particular about it. So I will change this to "out".
Well, if it only does 'return ret' we can get rid of the label and just do return's at the places that did the goto's.
Dave
Quoted 17 lines
Thanks
VivekQuoted 10 lines
tools/virtiofsd/fuse_virtio.c int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch, · line 454
Quoted 9 lines
tools/virtiofsd/fuse_virtio.c +0
-4-if (ret ==0 ) { - req->reply_sent = true; - } -return ret; }_______________________________________________
Virtio-fs mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/virtio-fs
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [PATCH 7/7] virtiofsd: Set req->reply_sent right after sending reply
In reply to Vivek GoyalQuoted 4 lines · * Vivek Goyal ([email protected]) wrote:
There is no reason to set it in label "err". We should be able to set it right after sending reply. It is easier to read.
Signed-off-by Vivek Goyal <[email protected]>
Quoted 25 lines
--- tools/virtiofsd/fuse_virtio.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)tools/virtiofsd/fuse_virtio.c +1
-4@@ -446,12 +446,9 @@ int virtio_send_data_iov(struct fuse_session *se, struct fuse_chan *ch,vu_queue_notify (dev, q);pthread_mutex_unlock (&qi->vq_lock);vu_dispatch_unlock (qi->virtio_dev); + req->reply_sent = true; err: -if (ret ==0 ) { - req->reply_sent = true; - } -return ret; }Signature · 1 line
2.25.4
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [PATCH 0/7] virtiofsd: Few cleanups in virtio_send_data_iov()
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Quoted 1 line
- [tag update] patchew/[email protected] -> patchew/[email protected]
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
b6ced9e virtiofsd: Set req->reply_sent right after sending reply c866cc2 virtiofsd: Check EOF before short read
8d45f07 virtiofsd: Simplify skip byte logic
b7afa17 virtiofsd: get rid of in_sg_left variable 37ba755 virtiofsd: Use iov_discard_front() to skip bytes f87fbd3 virtiofsd: Get rid of unreachable code in read cc6fb4a virtiofsd: Check for EINTR in preadv() and retry
=== OUTPUT BEGIN ===
1/7 Checking commit cc6fb4a9cf99 (virtiofsd: Check for EINTR in preadv() and retry) 2/7 Checking commit f87fbd364bcd (virtiofsd: Get rid of unreachable code in read) 3/7 Checking commit 37ba755df99d (virtiofsd: Use iov_discard_front() to skip bytes)
ERROR: code indent should never use tabs
#44: FILE: tools/virtiofsd/fuse_virtio.c:400:
+^I iov_discard_front(&in_sg_ptr, &in_sg_cpy_count, skip_size);$
total: 1 errors, 0 warnings, 26 lines checked
Patch 3/7 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
4/7 Checking commit b7afa17acdc2 (virtiofsd: get rid of in_sg_left variable) 5/7 Checking commit 8d45f07e917d (virtiofsd: Simplify skip byte logic)
6/7 Checking commit c866cc21d91c (virtiofsd: Check EOF before short read) 7/7 Checking commit b6ced9e49587 (virtiofsd: Set req->reply_sent right after sending reply) === OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Quoted 18 lines · Vivek Goyal
Hi,
Code in
virtio_send_data_iov()little twisted and complicated. This patch series just tries to simplify it a bit to make it little easier to read this piece of code.Thanks
VivekVivek Goyal (7):
virtiofsd: Check for EINTR inpreadv()and retry
virtiofsd: Get rid of unreachable code in read
virtiofsd: Useiov_discard_front()to skip bytes
virtiofsd: get rid ofin_sg_leftvariable
virtiofsd: Simplify skip byte logic
virtiofsd: Check EOF before short read
virtiofsd: Setreq->reply_sentright after sending reply
Quoted 3 lines
tools/virtiofsd/fuse_virtio.c | 67 +++++++++++------------------------ 1 file changed, 21 insertions(+), 46 deletions(-)
With the codestyle fix to appease the bot:
(For the series)
Quoted 23 lines · Connor Kuehl
Quoted 18 lines · Vivek Goyal
Hi,
Code in
virtio_send_data_iov()little twisted and complicated. This patch series just tries to simplify it a bit to make it little easier to read this piece of code.Thanks
VivekVivek Goyal (7):
virtiofsd: Check for EINTR inpreadv()and retry
virtiofsd: Get rid of unreachable code in read
virtiofsd: Useiov_discard_front()to skip bytes
virtiofsd: get rid ofin_sg_leftvariable
virtiofsd: Simplify skip byte logic
virtiofsd: Check EOF before short read
virtiofsd: Setreq->reply_sentright after sending replyQuoted 3 lines
tools/virtiofsd/fuse_virtio.c | 67 +++++++++++------------------------ 1 file changed, 21 insertions(+), 46 deletions(-)
Quoted 5 lines
With the codestyle fix to appease the bot:
Reviewed-by Connor Kuehl <[email protected]>(For the series)
Thanks. I will fix the coding style issue and repost the patch series.
Vivek