From df8781b5290d04108861e1bd0525ed01379a6b63 Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Thu, 18 Mar 2004 05:39:05 -0800 Subject: [PATCH] [PATCH] add touch_atime() helper Preparation for per-mountpoint noatime, nodiratime and later - per-mountpoint r/o. Depends on file_accessed() patch, should go after it. New helper - touch_atime(mnt, dentry). It's a wrapper for update_atime() and that's where all future per-mountpoint checks will go. --- fs/namei.c | 4 ++-- fs/nfsd/vfs.c | 2 +- fs/stat.c | 2 +- include/linux/fs.h | 8 +++++++- net/unix/af_unix.c | 4 ++-- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 28c2be94ac6be..e6320d133c5f3 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -412,7 +412,7 @@ static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd) goto loop; current->link_count++; current->total_link_count++; - update_atime(dentry->d_inode); + touch_atime(nd->mnt, dentry); err = dentry->d_inode->i_op->follow_link(dentry, nd); current->link_count--; return err; @@ -1368,7 +1368,7 @@ do_link: error = security_inode_follow_link(dentry, nd); if (error) goto exit_dput; - update_atime(dentry->d_inode); + touch_atime(nd->mnt, dentry); error = dentry->d_inode->i_op->follow_link(dentry, nd); dput(dentry); if (error) diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 4dbd4d2fd0be5..f5586d815f7f8 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -1143,7 +1143,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp) if (!inode->i_op || !inode->i_op->readlink) goto out; - update_atime(inode); + touch_atime(fhp->fh_export->ex_mnt, dentry); /* N.B. Why does this call need a get_fs()?? * Remove the set_fs and watch the fireworks:-) --okir */ diff --git a/fs/stat.c b/fs/stat.c index fcd4da8045bb7..e62d3c60d6147 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -272,7 +272,7 @@ asmlinkage long sys_readlink(const char __user * path, char __user * buf, int bu if (inode->i_op && inode->i_op->readlink) { error = security_inode_readlink(nd.dentry); if (!error) { - update_atime(inode); + touch_atime(nd.mnt, nd.dentry); error = inode->i_op->readlink(nd.dentry, buf, bufsiz); } } diff --git a/include/linux/fs.h b/include/linux/fs.h index c069102db2074..9c609f4febbc9 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -914,9 +914,15 @@ static inline void mark_inode_dirty_sync(struct inode *inode) __mark_inode_dirty(inode, I_DIRTY_SYNC); } +static inline void touch_atime(struct vfsmount *mnt, struct dentry *dentry) +{ + /* per-mountpoint checks will go here */ + update_atime(dentry->d_inode); +} + static inline void file_accessed(struct file *file) { - update_atime(file->f_dentry->d_inode); + touch_atime(file->f_vfsmnt, file->f_dentry); } diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 69e641f1d00eb..146a454032d89 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -691,7 +691,7 @@ static struct sock *unix_find_other(struct sockaddr_un *sunname, int len, goto put_fail; if (u->sk_type == type) - update_atime(nd.dentry->d_inode); + touch_atime(nd.mnt, nd.dentry); path_release(&nd); @@ -707,7 +707,7 @@ static struct sock *unix_find_other(struct sockaddr_un *sunname, int len, struct dentry *dentry; dentry = unix_sk(u)->dentry; if (dentry) - update_atime(dentry->d_inode); + touch_atime(unix_sk(u)->mnt, dentry); } else goto fail; } -- 2.53.0