Skip to content

Commit

Permalink
ovl: grab reference to workbasedir early
Browse files Browse the repository at this point in the history
and related cleanups.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
  • Loading branch information
Miklos Szeredi committed Nov 9, 2017
1 parent f7e3a7d commit 95e6d41
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions fs/overlayfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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 */
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1283,7 +1283,8 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
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)
Expand Down

0 comments on commit 95e6d41

Please sign in to comment.