summaryrefslogtreecommitdiff
path: root/fs/overlayfs
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@redhat.com>2017-11-10 09:39:15 +0100
committerMiklos Szeredi <mszeredi@redhat.com>2017-11-10 09:39:15 +0100
commitc6fe62549313555ed56b83bb8338383d78e768cb (patch)
tree768403134155d4dae48a7e7199eeaff338671b8e /fs/overlayfs
parenta9075cdb467dd3b01b57f8786e6ea1eca05a76b4 (diff)
ovl: change order of setup in ovl_fill_super()
Move ovl_get_upper() immediately after ovl_get_upperpath(), ovl_get_workdir() immediately after ovl_get_workdir() and ovl_get_lower_layers() immediately after ovl_get_lowerstack(). Also move prepare_creds() up to where other allocations are happening. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/overlayfs')
-rw-r--r--fs/overlayfs/super.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 5a5b41c542fb..c695ea569a99 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -1151,6 +1151,10 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
if (!ufs)
goto out;
+ ufs->creator_cred = cred = prepare_creds();
+ if (!cred)
+ goto out_err;
+
ufs->config.redirect_dir = ovl_redirect_dir_def;
ufs->config.index = ovl_index_def;
err = ovl_parse_opt((char *) data, &ufs->config);
@@ -1176,27 +1180,25 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
if (err)
goto out_err;
- err = ovl_get_workpath(ufs, &upperpath, &workpath);
+ err = ovl_get_upper(ufs, &upperpath);
if (err)
goto out_err;
- sb->s_stack_depth = upperpath.mnt->mnt_sb->s_stack_depth;
- }
- err = ovl_get_lowerstack(sb, ufs, &stack, &numlower);
- if (err)
- goto out_err;
-
- if (ufs->config.upperdir) {
- err = ovl_get_upper(ufs, &upperpath);
+ err = ovl_get_workpath(ufs, &upperpath, &workpath);
if (err)
goto out_err;
- sb->s_time_gran = ufs->upper_mnt->mnt_sb->s_time_gran;
-
err = ovl_get_workdir(sb, ufs, &workpath);
if (err)
goto out_err;
+
+ sb->s_stack_depth = ufs->upper_mnt->mnt_sb->s_stack_depth;
+ sb->s_time_gran = ufs->upper_mnt->mnt_sb->s_time_gran;
+
}
+ err = ovl_get_lowerstack(sb, ufs, &stack, &numlower);
+ if (err)
+ goto out_err;
err = ovl_get_lower_layers(ufs, stack, numlower);
if (err)
@@ -1228,11 +1230,6 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
if (!ufs->indexdir)
ufs->config.index = false;
- err = -ENOMEM;
- ufs->creator_cred = cred = prepare_creds();
- if (!cred)
- goto out_err;
-
/* Never override disk quota limits or use reserved space */
cap_lower(cred->cap_effective, CAP_SYS_RESOURCE);
@@ -1242,6 +1239,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
sb->s_fs_info = ufs;
sb->s_flags |= MS_POSIXACL | MS_NOREMOTELOCK;
+ err = -ENOMEM;
root_dentry = d_make_root(ovl_new_inode(sb, S_IFDIR, 0));
if (!root_dentry)
goto out_err;