aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2
diff options
context:
space:
mode:
authorBob Peterson <rpeterso@redhat.com>2014-09-29 08:52:04 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2014-10-01 09:06:15 -0400
commit19aeb5a65f1a6504fc665466c188241e7393d66f (patch)
treeed2f2cb66536ab4dfa5b1c2bffe9780889ad369c /fs/gfs2
parent00a158be83839f2d5370612d633eb2643ddf844e (diff)
GFS2: Make rename not save dirent location
This patch fixes a regression in the patch "GFS2: Remember directory insert point", commit 2b47dad866d04f14c328f888ba5406057b8c7d33. The problem had to do with the rename function: The function found space for the new dirent, and remembered that location. But then the old dirent was removed, which often moved the eligible location for the renamed dirent. Putting the new dirent at the saved location caused file system corruption. This patch adds a new "save_loc" variable to struct gfs2_diradd. If 1, the dirent location is saved. If 0, the dirent location is not saved and the buffer_head is released as per previous behavior. Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/dir.c9
-rw-r--r--fs/gfs2/dir.h1
-rw-r--r--fs/gfs2/inode.c6
3 files changed, 11 insertions, 5 deletions
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index 1a349f9a9685..5d4261ff5d23 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -2100,8 +2100,13 @@ int gfs2_diradd_alloc_required(struct inode *inode, const struct qstr *name,
2100 } 2100 }
2101 if (IS_ERR(dent)) 2101 if (IS_ERR(dent))
2102 return PTR_ERR(dent); 2102 return PTR_ERR(dent);
2103 da->bh = bh; 2103
2104 da->dent = dent; 2104 if (da->save_loc) {
2105 da->bh = bh;
2106 da->dent = dent;
2107 } else {
2108 brelse(bh);
2109 }
2105 return 0; 2110 return 0;
2106} 2111}
2107 2112
diff --git a/fs/gfs2/dir.h b/fs/gfs2/dir.h
index 126c65dda028..e1b309c24dab 100644
--- a/fs/gfs2/dir.h
+++ b/fs/gfs2/dir.h
@@ -23,6 +23,7 @@ struct gfs2_diradd {
23 unsigned nr_blocks; 23 unsigned nr_blocks;
24 struct gfs2_dirent *dent; 24 struct gfs2_dirent *dent;
25 struct buffer_head *bh; 25 struct buffer_head *bh;
26 int save_loc;
26}; 27};
27 28
28extern struct inode *gfs2_dir_search(struct inode *dir, 29extern struct inode *gfs2_dir_search(struct inode *dir,
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 9516f5c02151..fcf42eadb69c 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -600,7 +600,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
600 int error, free_vfs_inode = 0; 600 int error, free_vfs_inode = 0;
601 u32 aflags = 0; 601 u32 aflags = 0;
602 unsigned blocks = 1; 602 unsigned blocks = 1;
603 struct gfs2_diradd da = { .bh = NULL, }; 603 struct gfs2_diradd da = { .bh = NULL, .save_loc = 1, };
604 604
605 if (!name->len || name->len > GFS2_FNAMESIZE) 605 if (!name->len || name->len > GFS2_FNAMESIZE)
606 return -ENAMETOOLONG; 606 return -ENAMETOOLONG;
@@ -900,7 +900,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
900 struct gfs2_inode *ip = GFS2_I(inode); 900 struct gfs2_inode *ip = GFS2_I(inode);
901 struct gfs2_holder ghs[2]; 901 struct gfs2_holder ghs[2];
902 struct buffer_head *dibh; 902 struct buffer_head *dibh;
903 struct gfs2_diradd da = { .bh = NULL, }; 903 struct gfs2_diradd da = { .bh = NULL, .save_loc = 1, };
904 int error; 904 int error;
905 905
906 if (S_ISDIR(inode->i_mode)) 906 if (S_ISDIR(inode->i_mode))
@@ -1338,7 +1338,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
1338 struct gfs2_rgrpd *nrgd; 1338 struct gfs2_rgrpd *nrgd;
1339 unsigned int num_gh; 1339 unsigned int num_gh;
1340 int dir_rename = 0; 1340 int dir_rename = 0;
1341 struct gfs2_diradd da = { .nr_blocks = 0, }; 1341 struct gfs2_diradd da = { .nr_blocks = 0, .save_loc = 0, };
1342 unsigned int x; 1342 unsigned int x;
1343 int error; 1343 int error;
1344 1344