Some fixes or optimization for virtiofs, which are authored by Liu Bo. Liu Bo (2): virtio-fs: disable atomic_o_trunc if no_open is enabled virtiofs: reduce lock contention on fpq->lock fs/fuse/file.c | 11 +++++++++-- fs/fuse/virtio_fs.c | 3 --- 2 files changed, 9 insertions(+), 5 deletions(-) -- 2.27.0
Jeffle Xu
2021-Aug-12 05:46 UTC
[PATCH 1/2] fuse: disable atomic_o_trunc if no_open is enabled
From: Liu Bo <bo.liu at linux.alibaba.com>
When 'no_open' is used by virtiofsd, guest kernel won't send OPEN
request
any more. However, with atomic_o_trunc, SETATTR request is also omitted in
OPEN(O_TRUNC) so that the backend file is not truncated. With a following
GETATTR, inode size on guest side is updated to be same with that on host
side, the end result is that O_TRUNC semantic is broken.
This disables atomic_o_trunc as well if with no_open.
Reviewed-by: Peng Tao <tao.peng at linux.alibaba.com>
Signed-off-by: Liu Bo <bo.liu at linux.alibaba.com>
Signed-off-by: Jeffle Xu <jefflexu at linux.alibaba.com>
---
fs/fuse/file.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index b494ff08f08c..1231128f8dd6 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -151,10 +151,16 @@ struct fuse_file *fuse_file_open(struct fuse_mount *fm,
u64 nodeid,
fuse_file_free(ff);
return ERR_PTR(err);
} else {
- if (isdir)
+ if (isdir) {
fc->no_opendir = 1;
- else
+ } else {
fc->no_open = 1;
+ /*
+ * In case of no_open, disable atomic_o_trunc as
+ * well.
+ */
+ fc->atomic_o_trunc = 0;
+ }
}
}
--
2.27.0
From: Liu Bo <bo.liu at linux.alibaba.com>
Since %req has been removed from fpq->processing_list, no one except
request_wait_answer() is looking at this %req and request_wait_answer()
waits only on FINISH flag, it's OK to remove fpq->lock after %req is
dropped from the list.
Signed-off-by: Liu Bo <bo.liu at linux.alibaba.com>
Signed-off-by: Jeffle Xu <jefflexu at linux.alibaba.com>
---
fs/fuse/virtio_fs.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
index 0050132e2787..7dbf5502c57e 100644
--- a/fs/fuse/virtio_fs.c
+++ b/fs/fuse/virtio_fs.c
@@ -557,7 +557,6 @@ static void copy_args_from_argbuf(struct fuse_args *args,
struct fuse_req *req)
static void virtio_fs_request_complete(struct fuse_req *req,
struct virtio_fs_vq *fsvq)
{
- struct fuse_pqueue *fpq = &fsvq->fud->pq;
struct fuse_args *args;
struct fuse_args_pages *ap;
unsigned int len, i, thislen;
@@ -586,9 +585,7 @@ static void virtio_fs_request_complete(struct fuse_req *req,
}
}
- spin_lock(&fpq->lock);
clear_bit(FR_SENT, &req->flags);
- spin_unlock(&fpq->lock);
fuse_request_end(req);
spin_lock(&fsvq->lock);
--
2.27.0
ping ... On 8/12/21 1:46 PM, Jeffle Xu wrote:> Some fixes or optimization for virtiofs, which are authored by Liu Bo. > > Liu Bo (2): > virtio-fs: disable atomic_o_trunc if no_open is enabled > virtiofs: reduce lock contention on fpq->lock > > fs/fuse/file.c | 11 +++++++++-- > fs/fuse/virtio_fs.c | 3 --- > 2 files changed, 9 insertions(+), 5 deletions(-) >-- Thanks, Jeffle