linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vfs: update atime using file->f_inode
@ 2016-01-31 13:19 Konstantin Khlebnikov
  2016-03-17 16:36 ` Miklos Szeredi
  0 siblings, 1 reply; 2+ messages in thread
From: Konstantin Khlebnikov @ 2016-01-31 13:19 UTC (permalink / raw)
  To: linux-fsdevel, linux-unionfs, Alexander Viro; +Cc: linux-kernel, Miklos Szeredi

This fixes some cases of missing atime update for overlayfs.

Signed-off-by: Konstantin Khlebnikov <koct9i@gmail.com>
---
 fs/inode.c         |   15 +++++++++++++--
 include/linux/fs.h |    6 +-----
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/fs/inode.c b/fs/inode.c
index 9f62db3bcc3e..6a4dd94c0ea3 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1631,10 +1631,9 @@ bool atime_needs_update(const struct path *path, struct inode *inode)
 	return true;
 }
 
-void touch_atime(const struct path *path)
+static void touch_inode_atime(const struct path *path, struct inode *inode)
 {
 	struct vfsmount *mnt = path->mnt;
-	struct inode *inode = d_inode(path->dentry);
 	struct timespec now;
 
 	if (!atime_needs_update(path, inode))
@@ -1660,8 +1659,20 @@ void touch_atime(const struct path *path)
 skip_update:
 	sb_end_write(inode->i_sb);
 }
+
+void touch_atime(const struct path *path)
+{
+	touch_inode_atime(path, d_inode(path->dentry));
+}
 EXPORT_SYMBOL(touch_atime);
 
+void file_accessed(const struct file *file)
+{
+	if (!(file->f_flags & O_NOATIME))
+		touch_inode_atime(&file->f_path, file_inode(file));
+}
+EXPORT_SYMBOL(file_accessed);
+
 /*
  * The logic we want is
  *
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 1a2046275cdf..22c89094a7e3 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1951,11 +1951,7 @@ enum file_time_flags {
 
 extern bool atime_needs_update(const struct path *, struct inode *);
 extern void touch_atime(const struct path *);
-static inline void file_accessed(struct file *file)
-{
-	if (!(file->f_flags & O_NOATIME))
-		touch_atime(&file->f_path);
-}
+extern void file_accessed(const struct file *file);
 
 int sync_inode(struct inode *inode, struct writeback_control *wbc);
 int sync_inode_metadata(struct inode *inode, int wait);


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] vfs: update atime using file->f_inode
  2016-01-31 13:19 [PATCH] vfs: update atime using file->f_inode Konstantin Khlebnikov
@ 2016-03-17 16:36 ` Miklos Szeredi
  0 siblings, 0 replies; 2+ messages in thread
From: Miklos Szeredi @ 2016-03-17 16:36 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: linux-fsdevel, linux-unionfs, Alexander Viro, linux-kernel

On Sun, Jan 31, 2016 at 04:19:46PM +0300, Konstantin Khlebnikov wrote:
> This fixes some cases of missing atime update for overlayfs.

Problem is it will update atime on lower layer, even if it's explicitly marked
read-only.  Which I think is a pretty bad breakage of assumptions.

The following patch updates atime (untested) but only in the upper layer.
Obviously it makes no sense to copy-up due to an atime update.

Thanks,
Miklos
---
 fs/overlayfs/inode.c |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -370,6 +370,27 @@ struct inode *ovl_d_select_inode(struct
 	return d_backing_inode(realpath.dentry);
 }
 
+static int ovl_update_time(struct inode *inode, struct timespec *ts, int flags)
+{
+	struct dentry *alias;
+	struct path upperpath;
+
+	if (!(flags & S_ATIME))
+		return 0;
+
+	alias = d_find_any_alias(inode);
+	if (!alias)
+		return 0;
+
+	ovl_path_upper(alias, &upperpath);
+	if (!upperpath.dentry)
+		return 0;
+
+	touch_atime(&upperpath);
+
+	return 0;
+}
+
 static const struct inode_operations ovl_file_inode_operations = {
 	.setattr	= ovl_setattr,
 	.permission	= ovl_permission,
@@ -378,6 +399,7 @@ static const struct inode_operations ovl
 	.getxattr	= ovl_getxattr,
 	.listxattr	= ovl_listxattr,
 	.removexattr	= ovl_removexattr,
+	.update_time	= ovl_update_time,
 };
 
 static const struct inode_operations ovl_symlink_inode_operations = {

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-03-17 16:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-31 13:19 [PATCH] vfs: update atime using file->f_inode Konstantin Khlebnikov
2016-03-17 16:36 ` Miklos Szeredi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).