diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index 3807472b718e..03202ad7b481 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -831,8 +831,9 @@ static const struct xattr_handler *ovl_xattr_handlers[] = { NULL }; -static int ovl_get_upperpath(struct ovl_fs *ufs, struct path *upperpath) +static int ovl_get_upper(struct ovl_fs *ufs, struct path *upperpath) { + struct vfsmount *upper_mnt; int err; err = ovl_mount_dir(ufs->config.upperdir, upperpath); @@ -859,6 +860,17 @@ static int ovl_get_upperpath(struct ovl_fs *ufs, struct path *upperpath) } else { pr_warn("overlayfs: upperdir is in-use by another mount, accessing files from both mounts will result in undefined behavior.\n"); } + + upper_mnt = clone_private_mount(upperpath); + err = PTR_ERR(upper_mnt); + if (IS_ERR(upper_mnt)) { + pr_err("overlayfs: failed to clone upperpath\n"); + goto out; + } + + /* Don't inherit atime flags */ + upper_mnt->mnt_flags &= ~(MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME); + ufs->upper_mnt = upper_mnt; err = 0; out: return err; @@ -954,23 +966,6 @@ static int ovl_get_workpath(struct ovl_fs *ufs, struct path *upperpath, return err; } -static int ovl_get_upper(struct ovl_fs *ufs, struct path *upperpath) -{ - struct vfsmount *upper_mnt; - - upper_mnt = clone_private_mount(upperpath); - if (IS_ERR(upper_mnt)) { - pr_err("overlayfs: failed to clone upperpath\n"); - return PTR_ERR(upper_mnt); - } - - /* Don't inherit atime flags */ - upper_mnt->mnt_flags &= ~(MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME); - ufs->upper_mnt = upper_mnt; - - return 0; -} - static int ovl_get_indexdir(struct ovl_fs *ufs, struct ovl_entry *oe, struct path *upperpath) { @@ -1169,10 +1164,6 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) goto out_err; } - err = ovl_get_upperpath(ufs, &upperpath); - if (err) - goto out_err; - err = ovl_get_upper(ufs, &upperpath); if (err) goto out_err;