Commit bca44b52 authored by Miklos Szeredi's avatar Miklos Szeredi

ovl: clean up workdir creation

Move calling ovl_get_workdir() into ovl_get_workpath().

Rename ovl_get_workdir() to ovl_make_workdir() and ovl_get_workpath() to
ovl_get_workdir().

Workpath is now not needed outside ovl_get_workdir().
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
parent 5064975e
...@@ -876,7 +876,7 @@ static int ovl_get_upper(struct ovl_fs *ufs, struct path *upperpath) ...@@ -876,7 +876,7 @@ static int ovl_get_upper(struct ovl_fs *ufs, struct path *upperpath)
return err; return err;
} }
static int ovl_get_workdir(struct ovl_fs *ufs, struct path *workpath) static int ovl_make_workdir(struct ovl_fs *ufs, struct path *workpath)
{ {
struct dentry *temp; struct dentry *temp;
int err; int err;
...@@ -931,27 +931,27 @@ static int ovl_get_workdir(struct ovl_fs *ufs, struct path *workpath) ...@@ -931,27 +931,27 @@ static int ovl_get_workdir(struct ovl_fs *ufs, struct path *workpath)
return 0; return 0;
} }
static int ovl_get_workpath(struct ovl_fs *ufs, struct path *upperpath, static int ovl_get_workdir(struct ovl_fs *ufs, struct path *upperpath)
struct path *workpath)
{ {
int err; int err;
struct path workpath = { };
err = ovl_mount_dir(ufs->config.workdir, workpath); err = ovl_mount_dir(ufs->config.workdir, &workpath);
if (err) if (err)
goto out; goto out;
err = -EINVAL; err = -EINVAL;
if (upperpath->mnt != workpath->mnt) { if (upperpath->mnt != workpath.mnt) {
pr_err("overlayfs: workdir and upperdir must reside under the same mount\n"); pr_err("overlayfs: workdir and upperdir must reside under the same mount\n");
goto out; goto out;
} }
if (!ovl_workdir_ok(workpath->dentry, upperpath->dentry)) { if (!ovl_workdir_ok(workpath.dentry, upperpath->dentry)) {
pr_err("overlayfs: workdir and upperdir must be separate subtrees\n"); pr_err("overlayfs: workdir and upperdir must be separate subtrees\n");
goto out; goto out;
} }
err = -EBUSY; err = -EBUSY;
if (ovl_inuse_trylock(workpath->dentry)) { if (ovl_inuse_trylock(workpath.dentry)) {
ufs->workdir_locked = true; ufs->workdir_locked = true;
} else if (ufs->config.index) { } else if (ufs->config.index) {
pr_err("overlayfs: workdir is in-use by another mount, mount with '-o index=off' to override exclusive workdir protection.\n"); pr_err("overlayfs: workdir is in-use by another mount, mount with '-o index=off' to override exclusive workdir protection.\n");
...@@ -960,9 +960,15 @@ static int ovl_get_workpath(struct ovl_fs *ufs, struct path *upperpath, ...@@ -960,9 +960,15 @@ 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"); pr_warn("overlayfs: workdir is in-use by another mount, accessing files from both mounts will result in undefined behavior.\n");
} }
ufs->workbasedir = dget(workpath->dentry); ufs->workbasedir = dget(workpath.dentry);
err = ovl_make_workdir(ufs, &workpath);
if (err)
goto out;
err = 0; err = 0;
out: out:
path_put(&workpath);
return err; return err;
} }
...@@ -1124,7 +1130,6 @@ static int ovl_get_lowerstack(struct super_block *sb, struct ovl_fs *ufs, ...@@ -1124,7 +1130,6 @@ static int ovl_get_lowerstack(struct super_block *sb, struct ovl_fs *ufs,
static int ovl_fill_super(struct super_block *sb, void *data, int silent) static int ovl_fill_super(struct super_block *sb, void *data, int silent)
{ {
struct path upperpath = { }; struct path upperpath = { };
struct path workpath = { };
struct dentry *root_dentry; struct dentry *root_dentry;
struct ovl_entry *oe = NULL; struct ovl_entry *oe = NULL;
struct ovl_fs *ufs; struct ovl_fs *ufs;
...@@ -1168,11 +1173,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) ...@@ -1168,11 +1173,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
if (err) if (err)
goto out_err; goto out_err;
err = ovl_get_workpath(ufs, &upperpath, &workpath); err = ovl_get_workdir(ufs, &upperpath);
if (err)
goto out_err;
err = ovl_get_workdir(ufs, &workpath);
if (err) if (err)
goto out_err; goto out_err;
...@@ -1238,7 +1239,6 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) ...@@ -1238,7 +1239,6 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
for (i = 0; i < numlower; i++) for (i = 0; i < numlower; i++)
mntput(stack[i].mnt); mntput(stack[i].mnt);
kfree(stack); kfree(stack);
path_put(&workpath);
if (upperpath.dentry) { if (upperpath.dentry) {
oe->has_upper = true; oe->has_upper = true;
...@@ -1262,7 +1262,6 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) ...@@ -1262,7 +1262,6 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
for (i = 0; i < numlower; i++) for (i = 0; i < numlower; i++)
path_put(&stack[i]); path_put(&stack[i]);
kfree(stack); kfree(stack);
path_put(&workpath);
path_put(&upperpath); path_put(&upperpath);
ovl_free_fs(ufs); ovl_free_fs(ufs);
out: out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment