diff options
author | Miklos Szeredi <mszeredi@redhat.com> | 2017-11-10 09:39:15 +0100 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2017-11-10 09:39:15 +0100 |
commit | bca44b52f8355b9b391fadfe6e6e8662f23238c2 (patch) | |
tree | 7c89d47cd66d3081a4427d3e02946b3343ee331b /fs/overlayfs | |
parent | ovl: clean up getting upper layer (diff) | |
download | linux-bca44b52f8355b9b391fadfe6e6e8662f23238c2.tar.xz linux-bca44b52f8355b9b391fadfe6e6e8662f23238c2.zip |
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: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/overlayfs')
-rw-r--r-- | fs/overlayfs/super.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index 03202ad7b481..115cbf3303de 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -876,7 +876,7 @@ out: 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 @@ out_free_stack: 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 @@ out_err: for (i = 0; i < numlower; i++) path_put(&stack[i]); kfree(stack); - path_put(&workpath); path_put(&upperpath); ovl_free_fs(ufs); out: |