virtiofs: miscellaneous fixes
Subsystems (4)
cover virtiofs: miscellaneous fixes
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(-)
Signature · 1 line
2.27.0
PATCH 1/2 fuse: disable atomic_o_trunc if no_open is enabled
From: Liu Bo <[email protected]>
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.
--- fs/fuse/file.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
fs/fuse/file.c +8 -2
@@ -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 ; + } } }
Signature · 1 line
2.27.0
Miklos Szeredi
maintainerRe: [PATCH 1/2] fuse: disable atomic_o_trunc if no_open is enabled
Quoted 10 lines · Jeffle Xu
From: Liu Bo <[email protected]>
When '
no_open' is used by virtiofsd, guest kernel won't send OPEN request any more. However, withatomic_o_trunc, SETATTR request is also omitted inOPEN(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 thatO_TRUNCsemantic is broken.This disables
atomic_o_truncas well if withno_open.
I don't quite get it why one would want to enable atomic_o_trunc with no_open in the first place?
Thanks,
Miklos
Re: [PATCH 1/2] fuse: disable atomic_o_trunc if no_open is enabled
Quoted 10 lines · Miklos Szeredi
Quoted 9 lines · Jeffle Xu
From: Liu Bo <[email protected]>
When '
no_open' is used by virtiofsd, guest kernel won't send OPEN request any more. However, withatomic_o_trunc, SETATTR request is also omitted inOPEN(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 thatO_TRUNCsemantic is broken.
Quoted 4 lines
Quoted 1 line
This disables
atomic_o_truncas well if withno_open.I don't quite get it why one would want to enable
atomic_o_truncwithno_openin the first place?
Oops..We didn't realize that it could also be worked around by fuse daemon side. Please ignore this.
Signature · 2 lines
Thanks, Jeffle
PATCH 2/2 virtiofs: reduce lock contention on fpq->lock
In reply to Jeffle XuFrom: Liu Bo <[email protected]>
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.
--- fs/fuse/virtio_fs.c | 3 --- 1 file changed, 3 deletions(-)
fs/fuse/virtio_fs.c +0 -3
@@ -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);
Signature · 1 line
2.27.0
Miklos Szeredi
maintainerRe: [PATCH 2/2] virtiofs: reduce lock contention on fpq->lock
Quoted 7 lines · Jeffle Xu
From: Liu Bo <[email protected]>
Since %req has been removed from
fpq->processing_list, no one exceptrequest_wait_answer()is looking at this %req andrequest_wait_answer()waits only on FINISH flag, it's OK to removefpq->lockafter %req is dropped from the list.
I'll accept a patch to remove FR_SENT completely from virtiofs.
This flag is used for queuing interrupts but interrupts are not yet
implemented in virtiofs. When blocking lock support is added the
interrupt handling needs to be properly designed.
Thanks,
Miklos
Vivek Goyal
maintainerRe: [PATCH 2/2] virtiofs: reduce lock contention on fpq->lock
Quoted 11 lines · Miklos Szeredi
Quoted 7 lines · Jeffle Xu
From: Liu Bo <[email protected]>
Since %req has been removed from
fpq->processing_list, no one exceptrequest_wait_answer()is looking at this %req andrequest_wait_answer()waits only on FINISH flag, it's OK to removefpq->lockafter %req is dropped from the list.I'll accept a patch to remove
FR_SENTcompletely from virtiofs.
Recently I was also looking at FR_SENT flag and was wondering if it is atomic bit flag, then why do we need to take spin lock around it. Probably we need just some barrier if code needs it but not necessarily any lock.
But I agree that FR_SENT seems not usable from virtiofs point of view as we don't have support for interrupt request.
Quoted 3 lines
This flag is used for queuing interrupts but interrupts are not yet
implemented in virtiofs. When blocking lock support is added the
interrupt handling needs to be properly designed.
Hmm.., I did not think about this. I was getting ready to post patches for blocking posix locks but it does not have any support for interrupting the locking request (either blocked or queued).
Is implementing interrupt support a requirement for getting blocking posix lock patches in?
Thanks
Vivek
ping ...
Quoted 10 lines · Jeffle Xu
Some fixes or optimization for virtiofs, which are authored by Liu Bo.
Liu Bo (2):
virtio-fs: disableatomic_o_truncifno_openis enabled
virtiofs: reduce lock contention onfpq->lockfs/fuse/file.c | 11 +++++++++-- fs/fuse/virtio_fs.c | 3 --- 2 files changed, 9 insertions(+), 5 deletions(-)
Signature · 2 lines
Thanks, Jeffle