aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@redhat.com>2017-11-09 04:23:29 -0500
committerMiklos Szeredi <mszeredi@redhat.com>2017-11-09 04:23:29 -0500
commit95e6d4177cb7a2d7a760180e13f32adaf4188833 (patch)
tree8a0b5389e0a5a05c84dff9d6dc851faa71102279
parentf7e3a7d947f83684f6622b592136da54bed922e6 (diff)
ovl: grab reference to workbasedir early
and related cleanups. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
-rw-r--r--fs/overlayfs/super.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 6bb874da174d..255c0523148f 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -889,7 +889,7 @@ static int ovl_get_workpath(struct ovl_fs *ufs, struct path *upperpath,
889 pr_warn("overlayfs: workdir is in-use by another mount, accessing files from both mounts will result in undefined behavior.\n"); 889 pr_warn("overlayfs: workdir is in-use by another mount, accessing files from both mounts will result in undefined behavior.\n");
890 } 890 }
891 891
892 ufs->workbasedir = workpath->dentry; 892 ufs->workbasedir = dget(workpath->dentry);
893 err = 0; 893 err = 0;
894out: 894out:
895 return err; 895 return err;
@@ -918,7 +918,7 @@ static int ovl_get_workdir(struct super_block *sb, struct ovl_fs *ufs,
918 struct dentry *temp; 918 struct dentry *temp;
919 int err; 919 int err;
920 920
921 ufs->workdir = ovl_workdir_create(sb, ufs, workpath->dentry, 921 ufs->workdir = ovl_workdir_create(sb, ufs, ufs->workbasedir,
922 OVL_WORKDIR_NAME, false); 922 OVL_WORKDIR_NAME, false);
923 if (!ufs->workdir) 923 if (!ufs->workdir)
924 return 0; 924 return 0;
@@ -971,7 +971,7 @@ static int ovl_get_workdir(struct super_block *sb, struct ovl_fs *ufs,
971 971
972static int ovl_get_indexdir(struct super_block *sb, struct ovl_fs *ufs, 972static int ovl_get_indexdir(struct super_block *sb, struct ovl_fs *ufs,
973 struct ovl_entry *oe, 973 struct ovl_entry *oe,
974 struct path *upperpath, struct path *workpath) 974 struct path *upperpath)
975{ 975{
976 int err; 976 int err;
977 977
@@ -985,7 +985,7 @@ static int ovl_get_indexdir(struct super_block *sb, struct ovl_fs *ufs,
985 goto out; 985 goto out;
986 } 986 }
987 987
988 ufs->indexdir = ovl_workdir_create(sb, ufs, workpath->dentry, 988 ufs->indexdir = ovl_workdir_create(sb, ufs, ufs->workbasedir,
989 OVL_INDEXDIR_NAME, true); 989 OVL_INDEXDIR_NAME, true);
990 if (ufs->indexdir) { 990 if (ufs->indexdir) {
991 /* Verify upper root is index dir origin */ 991 /* Verify upper root is index dir origin */
@@ -1212,7 +1212,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
1212 } 1212 }
1213 1213
1214 if (!(ovl_force_readonly(ufs)) && ufs->config.index) { 1214 if (!(ovl_force_readonly(ufs)) && ufs->config.index) {
1215 err = ovl_get_indexdir(sb, ufs, oe, &upperpath, &workpath); 1215 err = ovl_get_indexdir(sb, ufs, oe, &upperpath);
1216 if (err) 1216 if (err)
1217 goto out_put_indexdir; 1217 goto out_put_indexdir;
1218 } 1218 }
@@ -1243,7 +1243,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
1243 for (i = 0; i < numlower; i++) 1243 for (i = 0; i < numlower; i++)
1244 mntput(stack[i].mnt); 1244 mntput(stack[i].mnt);
1245 kfree(stack); 1245 kfree(stack);
1246 mntput(workpath.mnt); 1246 path_put(&workpath);
1247 1247
1248 if (upperpath.dentry) { 1248 if (upperpath.dentry) {
1249 oe->has_upper = true; 1249 oe->has_upper = true;
@@ -1283,7 +1283,8 @@ out_put_lowerpath:
1283 kfree(stack); 1283 kfree(stack);
1284out_unlock_workdentry: 1284out_unlock_workdentry:
1285 if (ufs->workdir_locked) 1285 if (ufs->workdir_locked)
1286 ovl_inuse_unlock(workpath.dentry); 1286 ovl_inuse_unlock(ufs->workbasedir);
1287 dput(ufs->workbasedir);
1287 path_put(&workpath); 1288 path_put(&workpath);
1288out_unlock_upperdentry: 1289out_unlock_upperdentry:
1289 if (ufs->upperdir_locked) 1290 if (ufs->upperdir_locked)