diff options
author | Miklos Szeredi <mszeredi@redhat.com> | 2017-11-10 03:39:15 -0500 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2017-11-10 03:39:15 -0500 |
commit | bca44b52f8355b9b391fadfe6e6e8662f23238c2 (patch) | |
tree | 7c89d47cd66d3081a4427d3e02946b3343ee331b | |
parent | 5064975e7fecdf9c7fc550ddef345aa50d0b04bb (diff) |
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>
-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: | |||
876 | return err; | 876 | return err; |
877 | } | 877 | } |
878 | 878 | ||
879 | static int ovl_get_workdir(struct ovl_fs *ufs, struct path *workpath) | 879 | static int ovl_make_workdir(struct ovl_fs *ufs, struct path *workpath) |
880 | { | 880 | { |
881 | struct dentry *temp; | 881 | struct dentry *temp; |
882 | int err; | 882 | int err; |
@@ -931,27 +931,27 @@ static int ovl_get_workdir(struct ovl_fs *ufs, struct path *workpath) | |||
931 | return 0; | 931 | return 0; |
932 | } | 932 | } |
933 | 933 | ||
934 | static int ovl_get_workpath(struct ovl_fs *ufs, struct path *upperpath, | 934 | static int ovl_get_workdir(struct ovl_fs *ufs, struct path *upperpath) |
935 | struct path *workpath) | ||
936 | { | 935 | { |
937 | int err; | 936 | int err; |
937 | struct path workpath = { }; | ||
938 | 938 | ||
939 | err = ovl_mount_dir(ufs->config.workdir, workpath); | 939 | err = ovl_mount_dir(ufs->config.workdir, &workpath); |
940 | if (err) | 940 | if (err) |
941 | goto out; | 941 | goto out; |
942 | 942 | ||
943 | err = -EINVAL; | 943 | err = -EINVAL; |
944 | if (upperpath->mnt != workpath->mnt) { | 944 | if (upperpath->mnt != workpath.mnt) { |
945 | pr_err("overlayfs: workdir and upperdir must reside under the same mount\n"); | 945 | pr_err("overlayfs: workdir and upperdir must reside under the same mount\n"); |
946 | goto out; | 946 | goto out; |
947 | } | 947 | } |
948 | if (!ovl_workdir_ok(workpath->dentry, upperpath->dentry)) { | 948 | if (!ovl_workdir_ok(workpath.dentry, upperpath->dentry)) { |
949 | pr_err("overlayfs: workdir and upperdir must be separate subtrees\n"); | 949 | pr_err("overlayfs: workdir and upperdir must be separate subtrees\n"); |
950 | goto out; | 950 | goto out; |
951 | } | 951 | } |
952 | 952 | ||
953 | err = -EBUSY; | 953 | err = -EBUSY; |
954 | if (ovl_inuse_trylock(workpath->dentry)) { | 954 | if (ovl_inuse_trylock(workpath.dentry)) { |
955 | ufs->workdir_locked = true; | 955 | ufs->workdir_locked = true; |
956 | } else if (ufs->config.index) { | 956 | } else if (ufs->config.index) { |
957 | pr_err("overlayfs: workdir is in-use by another mount, mount with '-o index=off' to override exclusive workdir protection.\n"); | 957 | 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 | pr_warn("overlayfs: workdir is in-use by another mount, accessing files from both mounts will result in undefined behavior.\n"); | 960 | pr_warn("overlayfs: workdir is in-use by another mount, accessing files from both mounts will result in undefined behavior.\n"); |
961 | } | 961 | } |
962 | 962 | ||
963 | ufs->workbasedir = dget(workpath->dentry); | 963 | ufs->workbasedir = dget(workpath.dentry); |
964 | err = ovl_make_workdir(ufs, &workpath); | ||
965 | if (err) | ||
966 | goto out; | ||
967 | |||
964 | err = 0; | 968 | err = 0; |
965 | out: | 969 | out: |
970 | path_put(&workpath); | ||
971 | |||
966 | return err; | 972 | return err; |
967 | } | 973 | } |
968 | 974 | ||
@@ -1124,7 +1130,6 @@ out_free_stack: | |||
1124 | static int ovl_fill_super(struct super_block *sb, void *data, int silent) | 1130 | static int ovl_fill_super(struct super_block *sb, void *data, int silent) |
1125 | { | 1131 | { |
1126 | struct path upperpath = { }; | 1132 | struct path upperpath = { }; |
1127 | struct path workpath = { }; | ||
1128 | struct dentry *root_dentry; | 1133 | struct dentry *root_dentry; |
1129 | struct ovl_entry *oe = NULL; | 1134 | struct ovl_entry *oe = NULL; |
1130 | struct ovl_fs *ufs; | 1135 | struct ovl_fs *ufs; |
@@ -1168,11 +1173,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) | |||
1168 | if (err) | 1173 | if (err) |
1169 | goto out_err; | 1174 | goto out_err; |
1170 | 1175 | ||
1171 | err = ovl_get_workpath(ufs, &upperpath, &workpath); | 1176 | err = ovl_get_workdir(ufs, &upperpath); |
1172 | if (err) | ||
1173 | goto out_err; | ||
1174 | |||
1175 | err = ovl_get_workdir(ufs, &workpath); | ||
1176 | if (err) | 1177 | if (err) |
1177 | goto out_err; | 1178 | goto out_err; |
1178 | 1179 | ||
@@ -1238,7 +1239,6 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) | |||
1238 | for (i = 0; i < numlower; i++) | 1239 | for (i = 0; i < numlower; i++) |
1239 | mntput(stack[i].mnt); | 1240 | mntput(stack[i].mnt); |
1240 | kfree(stack); | 1241 | kfree(stack); |
1241 | path_put(&workpath); | ||
1242 | 1242 | ||
1243 | if (upperpath.dentry) { | 1243 | if (upperpath.dentry) { |
1244 | oe->has_upper = true; | 1244 | oe->has_upper = true; |
@@ -1262,7 +1262,6 @@ out_err: | |||
1262 | for (i = 0; i < numlower; i++) | 1262 | for (i = 0; i < numlower; i++) |
1263 | path_put(&stack[i]); | 1263 | path_put(&stack[i]); |
1264 | kfree(stack); | 1264 | kfree(stack); |
1265 | path_put(&workpath); | ||
1266 | path_put(&upperpath); | 1265 | path_put(&upperpath); |
1267 | ovl_free_fs(ufs); | 1266 | ovl_free_fs(ufs); |
1268 | out: | 1267 | out: |