fuse: update atime on DAX read
Subsystems (2)
PATCH 1/1 fuse: update atime on DAX read
Address the TODO comment in fuse_dax_read_iter() which has been present since the initial DAX implementation in commit c2d0ad00d948 ("virtiofs:
implement dax read/write operations").
Simply calling file_accessed() is insufficient for FUSE, as it only updates the local inode without notifying the server.
This patch introduces fuse_flush_atime() to explicitly send atime updates to the server via SETATTR, followed by fuse_invalidate_atime() to invalidate the attribute cache.
--- fs/fuse/dax.c | 4 +++- fs/fuse/dir.c | 20 ++++++++++++++++++++ fs/fuse/fuse_i.h | 1 + 3 files changed, 24 insertions(+), 1 deletion(-)
fs/fuse/dax.c +3 -1
@@ -688,7 +688,9 @@ ssize_t fuse_dax_read_iter(struct kiocb *iocb, struct iov_iter *to) ret =dax_iomap_rw (iocb, to, &fuse_iomap_ops);inode_unlock_shared (inode); -/* TODO file_accessed(iocb->f_filp) */ +file_accessed (iocb->ki_filp); +fuse_flush_atime (inode); +fuse_invalidate_atime (inode);return ret; }
fs/fuse/dir.c +20 -0
@@ -2113,6 +2113,26 @@ int fuse_flush_times(struct inode *inode, struct fuse_file *ff)return fuse_simple_request (fm, &args); } +/* +* Flush inode->i_atime to the server +*/ +int fuse_flush_atime (struct inode *inode) +{ +struct fuse_mount *fm =get_fuse_mount (inode); +FUSE_ARGS (args); +struct fuse_setattr_in inarg; +struct fuse_attr_out outarg; + +memset (&inarg,0 ,sizeof (inarg)); +memset (&outarg,0 ,sizeof (outarg)); + + inarg.valid =FATTR_ATIME |FATTR_ATIME_NOW ; + +fuse_setattr_fill (fm->fc, &args, inode, &inarg, &outarg); + +return fuse_simple_request (fm, &args); +} +/* * Set attributes, and at the same time refresh them. *
fs/fuse/fuse_i.h +1 -0
@@ -1467,6 +1467,7 @@ int fuse_dev_release(struct inode *inode, struct file *file);bool fuse_write_update_attr (struct inode *inode,loff_t pos,ssize_t written);int fuse_flush_times (struct inode *inode,struct fuse_file *ff); +int fuse_flush_atime (struct inode *inode);int fuse_write_inode (struct inode *inode,struct writeback_control *wbc); int fuse_do_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
Signature · 8 lines
2.50.1 Amazon Web Services EMEA SARL, 38 avenue John F. Kennedy, L-1855 Luxembourg, R.C.S. Luxembourg B186284 Amazon Web Services EMEA SARL, Irish Branch, One Burlington Plaza, Burlington Road, Dublin 4, Ireland, branch registration number 908705
Miklos Szeredi
maintainerQuoted 5 lines · Yuto Ohnuki
Address the TODO comment in
fuse_dax_read_iter()which has been present since the initial DAX implementation in commitc2d0ad00d948("virtiofs:
implement dax read/write operations").
Quoted 8 lines
Simply calling
file_accessed()is insufficient for FUSE, as it only updates the local inode without notifying the server.This patch introduces
fuse_flush_atime()to explicitly send atime updates to the server via SETATTR, followed byfuse_invalidate_atime()to invalidate the attribute cache.Signed-off-by Yuto Ohnuki <[email protected]>
Does this actually do anything useful?
Fuse hasn't supported atime updates at all, see:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/fuse/inode.c#n509
Thanks,
Miklos