summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@redhat.com>2017-11-09 10:23:28 +0100
committerMiklos Szeredi <mszeredi@redhat.com>2017-11-09 10:23:28 +0100
commit21a3b317a60197b19c8f67e8016b633942e36bbf (patch)
tree6950ba36f927b5e665af2655ec34924e2701db33
parentovl: split out ovl_get_lowerstack() from ovl_fill_super() (diff)
downloadlinux-21a3b317a60197b19c8f67e8016b633942e36bbf.tar.xz
linux-21a3b317a60197b19c8f67e8016b633942e36bbf.zip
ovl: split out ovl_get_upper() from ovl_fill_super()
And don't clobber ufs->upper_mnt on error. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
-rw-r--r--fs/overlayfs/super.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 6c8703112b8f..21f93cd5782f 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -895,6 +895,23 @@ out:
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_lowerstack(struct super_block *sb, struct ovl_fs *ufs,
struct path **stackp, unsigned int *stacklenp)
{
@@ -1018,15 +1035,9 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
goto out_unlock_workdentry;
if (ufs->config.upperdir) {
- ufs->upper_mnt = clone_private_mount(&upperpath);
- err = PTR_ERR(ufs->upper_mnt);
- if (IS_ERR(ufs->upper_mnt)) {
- pr_err("overlayfs: failed to clone upperpath\n");
+ err = ovl_get_upper(ufs, &upperpath);
+ if (err)
goto out_put_lowerpath;
- }
-
- /* Don't inherit atime flags */
- ufs->upper_mnt->mnt_flags &= ~(MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME);
sb->s_time_gran = ufs->upper_mnt->mnt_sb->s_time_gran;