Re: [RFC PATCH 04/35] ovl: copy up times

From: Amir Goldstein
Date: Fri Apr 13 2018 - 04:25:32 EST


On Thu, Apr 12, 2018 at 6:07 PM, Miklos Szeredi <mszeredi@xxxxxxxxxx> wrote:
> Copy up mtime and ctime to overlay inode after times in real object are
> modified. Be careful not to dirty cachelines when not necessary.
>
> This is in preparation for moving overlay functionality out of the VFS.
>
> This patch shouldn't have any observable effect.
>
> Signed-off-by: Miklos Szeredi <mszeredi@xxxxxxxxxx>
> ---
> fs/overlayfs/dir.c | 5 +++++
> fs/overlayfs/inode.c | 1 +
> fs/overlayfs/overlayfs.h | 7 +++++++
> fs/overlayfs/util.c | 19 +++++++++++++++++++
> 4 files changed, 32 insertions(+)
>
> diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
> index 839709c7803a..cd0fa2363723 100644
> --- a/fs/overlayfs/dir.c
> +++ b/fs/overlayfs/dir.c
> @@ -507,6 +507,7 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
> else
> err = ovl_create_over_whiteout(dentry, inode, attr,
> hardlink);
> + ovl_copytimes_with_parent(dentry);
> }
> out_revert_creds:
> revert_creds(old_cred);
> @@ -768,6 +769,7 @@ static int ovl_do_remove(struct dentry *dentry, bool is_dir)
> drop_nlink(dentry->d_inode);
> }
> ovl_nlink_end(dentry, locked);
> + ovl_copytimes_with_parent(dentry);
> out_drop_write:
> ovl_drop_write(dentry);
> out:
> @@ -1079,6 +1081,9 @@ static int ovl_rename(struct inode *olddir, struct dentry *old,
> ovl_dentry_version_inc(new->d_parent, ovl_type_origin(old) ||
> (d_inode(new) && ovl_type_origin(new)));
>
> + ovl_copytimes_with_parent(old);
> + ovl_copytimes_with_parent(new);
> +

All the ovl_copytimes_with_parent() calls you added can be replaced with a
single call in ovl_dentry_version_inc(). Just need to change its name and
pass it the child instead of the parent dentry.

Thanks,
Amir.