[Virtio-fs] [PATCH v4 2/2] virtiofsd: use fuse_buf_writev to replace fuse_buf_write for better performance

Stefan Hajnoczi stefanha at redhat.com
Wed Aug 14 12:52:35 UTC 2019


On Fri, Aug 09, 2019 at 08:53:20AM +0800, piaojun wrote:
> diff --git a/contrib/virtiofsd/buffer.c b/contrib/virtiofsd/buffer.c
> index cec762f..d127c45 100644
> --- a/contrib/virtiofsd/buffer.c
> +++ b/contrib/virtiofsd/buffer.c
> @@ -318,11 +318,22 @@ static int fuse_bufvec_advance(struct fuse_bufvec *bufv, size_t len)
>  ssize_t fuse_buf_copy(fuse_req_t req, struct fuse_bufvec *dstv, struct fuse_bufvec *srcv,
>  		      enum fuse_buf_copy_flags flags)
>  {
> +	size_t i;
>  	size_t copied = 0;
> 
>  	if (dstv == srcv)
>  		return fuse_buf_size(dstv);
> 
> +	/* use writev to improve bandwidth when all the
> +	 * src buffers already mapped by the daemon
> +	 * process */

Some more checks to make this generic:

> +	for (i = 0; i < srcv->count; i++) {
> +		if (srcv->buf[i].flags & FUSE_BUF_PHYS_ADDR)
> +			break;

                if (srcv->buf[i].flags & FUSE_BUF_IS_FD)
		        break;

> +	}
> +	if (i == srcv->count)

Please verify the preconditions for the destination buffer too:

  && dstv->count == 1 && dstv->idx == 0 && dstv->off == 0 &&
  (dstv->buf[0].flags & FUSE_BUF_IS_FD)

> +		return fuse_buf_writev(req, &dstv->buf[0], srcv);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virtio-fs/attachments/20190814/6979356e/attachment.sig>


More information about the Virtio-fs mailing list