Recently we found the performance of small direct writes is bad when writeback_cache enabled. This is because we need to get attrs from userspace in fuse_update_get_attr() on each write. The timeout for the attributes doesn't work since every direct write will invalidate the attrs in fuse_direct_IO(). To fix it, this patch tries to avoid invalidating attrs if writeback_cache is enabled since we should trust local size/ctime/mtime in this case. Signed-off-by: Xie Yongji <xieyongji@xxxxxxxxxxxxx> --- fs/fuse/file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 11404f8c21c7..5561d4cc735c 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -2868,8 +2868,11 @@ fuse_direct_IO(struct kiocb *iocb, struct iov_iter *iter) } if (iov_iter_rw(iter) == WRITE) { + struct fuse_conn *fc = get_fuse_conn(inode); + ret = fuse_direct_io(io, iter, &pos, FUSE_DIO_WRITE); - fuse_invalidate_attr(inode); + if (!fc->writeback_cache) + fuse_invalidate_attr(inode); } else { ret = __fuse_direct_read(io, iter, &pos); } -- 2.11.0