1
0
Fork 0

ovl: grab reference to workbasedir early

and related cleanups.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
hifive-unleashed-5.1
Miklos Szeredi 2017-11-09 10:23:29 +01:00
parent f7e3a7d947
commit 95e6d4177c
1 changed files with 8 additions and 7 deletions

View File

@ -889,7 +889,7 @@ static int ovl_get_workpath(struct ovl_fs *ufs, struct path *upperpath,
pr_warn("overlayfs: workdir is in-use by another mount, accessing files from both mounts will result in undefined behavior.\n");
}
ufs->workbasedir = workpath->dentry;
ufs->workbasedir = dget(workpath->dentry);
err = 0;
out:
return err;
@ -918,7 +918,7 @@ static int ovl_get_workdir(struct super_block *sb, struct ovl_fs *ufs,
struct dentry *temp;
int err;
ufs->workdir = ovl_workdir_create(sb, ufs, workpath->dentry,
ufs->workdir = ovl_workdir_create(sb, ufs, ufs->workbasedir,
OVL_WORKDIR_NAME, false);
if (!ufs->workdir)
return 0;
@ -971,7 +971,7 @@ static int ovl_get_workdir(struct super_block *sb, struct ovl_fs *ufs,
static int ovl_get_indexdir(struct super_block *sb, struct ovl_fs *ufs,
struct ovl_entry *oe,
struct path *upperpath, struct path *workpath)
struct path *upperpath)
{
int err;
@ -985,7 +985,7 @@ static int ovl_get_indexdir(struct super_block *sb, struct ovl_fs *ufs,
goto out;
}
ufs->indexdir = ovl_workdir_create(sb, ufs, workpath->dentry,
ufs->indexdir = ovl_workdir_create(sb, ufs, ufs->workbasedir,
OVL_INDEXDIR_NAME, true);
if (ufs->indexdir) {
/* Verify upper root is index dir origin */
@ -1212,7 +1212,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
}
if (!(ovl_force_readonly(ufs)) && ufs->config.index) {
err = ovl_get_indexdir(sb, ufs, oe, &upperpath, &workpath);
err = ovl_get_indexdir(sb, ufs, oe, &upperpath);
if (err)
goto out_put_indexdir;
}
@ -1243,7 +1243,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
for (i = 0; i < numlower; i++)
mntput(stack[i].mnt);
kfree(stack);
mntput(workpath.mnt);
path_put(&workpath);
if (upperpath.dentry) {
oe->has_upper = true;
@ -1283,7 +1283,8 @@ out_put_lowerpath:
kfree(stack);
out_unlock_workdentry:
if (ufs->workdir_locked)
ovl_inuse_unlock(workpath.dentry);
ovl_inuse_unlock(ufs->workbasedir);
dput(ufs->workbasedir);
path_put(&workpath);
out_unlock_upperdentry:
if (ufs->upperdir_locked)