提交 bca44b52 编写于 作者: M 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: NMiklos Szeredi <mszeredi@redhat.com>
上级 5064975e
......@@ -876,7 +876,7 @@ static int ovl_get_upper(struct ovl_fs *ufs, struct path *upperpath)
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;
int err;
......@@ -931,27 +931,27 @@ static int ovl_get_workdir(struct ovl_fs *ufs, struct path *workpath)
return 0;
}
static int ovl_get_workpath(struct ovl_fs *ufs, struct path *upperpath,
struct path *workpath)
static int ovl_get_workdir(struct ovl_fs *ufs, struct path *upperpath)
{
int err;
struct path workpath = { };
err = ovl_mount_dir(ufs->config.workdir, workpath);
err = ovl_mount_dir(ufs->config.workdir, &workpath);
if (err)
goto out;
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");
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");
goto out;
}
err = -EBUSY;
if (ovl_inuse_trylock(workpath->dentry)) {
if (ovl_inuse_trylock(workpath.dentry)) {
ufs->workdir_locked = true;
} 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");
......@@ -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");
}
ufs->workbasedir = dget(workpath->dentry);
ufs->workbasedir = dget(workpath.dentry);
err = ovl_make_workdir(ufs, &workpath);
if (err)
goto out;
err = 0;
out:
path_put(&workpath);
return err;
}
......@@ -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)
{
struct path upperpath = { };
struct path workpath = { };
struct dentry *root_dentry;
struct ovl_entry *oe = NULL;
struct ovl_fs *ufs;
......@@ -1168,11 +1173,7 @@ 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);
if (err)
goto out_err;
err = ovl_get_workdir(ufs, &workpath);
err = ovl_get_workdir(ufs, &upperpath);
if (err)
goto out_err;
......@@ -1238,7 +1239,6 @@ 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);
path_put(&workpath);
if (upperpath.dentry) {
oe->has_upper = true;
......@@ -1262,7 +1262,6 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
for (i = 0; i < numlower; i++)
path_put(&stack[i]);
kfree(stack);
path_put(&workpath);
path_put(&upperpath);
ovl_free_fs(ufs);
out:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册