aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDmitriy Monakhov <dmonakhov@sw.ru>2007-05-08 03:25:34 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:01 -0400
commitfedee54d8f12cdfde299f181fec5c62b0c647ad6 (patch)
tree815a5de82d0c242bb1e6a012a237d0715c3b08af /fs
parent753e9c5cd9b123156152c66c816f751954b15e53 (diff)
ext3: dirindex error pointer issues
- ext3_dx_find_entry() exit with out setting proper error pointer - do_split() exit with out setting proper error pointer it is realy painful because many callers contain folowing code: de = do_split(handle,dir, &bh, frame, &hinfo, &retval); if (!(de)) return retval; <<< WOW retval wasn't changed by do_split(), so caller failed <<< but return SUCCESS :) - Rearrange do_split() error path. Current error path is realy ugly, all this up and down jump stuff doesn't make code easy to understand. [dmonakhov@sw.ru: fix annoying fake error messages] Signed-off-by: Monakhov Dmitriy <dmonakhov@openvz.org> Cc: Andreas Dilger <adilger@clusterfs.com> Cc: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Monakhov Dmitriy <dmonakhov@openvz.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/ext3/namei.c26
-rw-r--r--fs/ext4/namei.c26
2 files changed, 30 insertions, 22 deletions
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index 49159f13cc1f..7edb617fd33d 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -969,6 +969,7 @@ static struct buffer_head * ext3_dx_find_entry(struct dentry *dentry,
969 (block<<EXT3_BLOCK_SIZE_BITS(sb)) 969 (block<<EXT3_BLOCK_SIZE_BITS(sb))
970 +((char *)de - bh->b_data))) { 970 +((char *)de - bh->b_data))) {
971 brelse (bh); 971 brelse (bh);
972 *err = ERR_BAD_DX_DIR;
972 goto errout; 973 goto errout;
973 } 974 }
974 *res_dir = de; 975 *res_dir = de;
@@ -1134,9 +1135,9 @@ static struct ext3_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
1134 char *data1 = (*bh)->b_data, *data2; 1135 char *data1 = (*bh)->b_data, *data2;
1135 unsigned split; 1136 unsigned split;
1136 struct ext3_dir_entry_2 *de = NULL, *de2; 1137 struct ext3_dir_entry_2 *de = NULL, *de2;
1137 int err; 1138 int err = 0;
1138 1139
1139 bh2 = ext3_append (handle, dir, &newblock, error); 1140 bh2 = ext3_append (handle, dir, &newblock, &err);
1140 if (!(bh2)) { 1141 if (!(bh2)) {
1141 brelse(*bh); 1142 brelse(*bh);
1142 *bh = NULL; 1143 *bh = NULL;
@@ -1145,14 +1146,9 @@ static struct ext3_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
1145 1146
1146 BUFFER_TRACE(*bh, "get_write_access"); 1147 BUFFER_TRACE(*bh, "get_write_access");
1147 err = ext3_journal_get_write_access(handle, *bh); 1148 err = ext3_journal_get_write_access(handle, *bh);
1148 if (err) { 1149 if (err)
1149 journal_error: 1150 goto journal_error;
1150 brelse(*bh); 1151
1151 brelse(bh2);
1152 *bh = NULL;
1153 ext3_std_error(dir->i_sb, err);
1154 goto errout;
1155 }
1156 BUFFER_TRACE(frame->bh, "get_write_access"); 1152 BUFFER_TRACE(frame->bh, "get_write_access");
1157 err = ext3_journal_get_write_access(handle, frame->bh); 1153 err = ext3_journal_get_write_access(handle, frame->bh);
1158 if (err) 1154 if (err)
@@ -1195,8 +1191,16 @@ static struct ext3_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
1195 goto journal_error; 1191 goto journal_error;
1196 brelse (bh2); 1192 brelse (bh2);
1197 dxtrace(dx_show_index ("frame", frame->entries)); 1193 dxtrace(dx_show_index ("frame", frame->entries));
1198errout:
1199 return de; 1194 return de;
1195
1196journal_error:
1197 brelse(*bh);
1198 brelse(bh2);
1199 *bh = NULL;
1200 ext3_std_error(dir->i_sb, err);
1201errout:
1202 *error = err;
1203 return NULL;
1200} 1204}
1201#endif 1205#endif
1202 1206
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index e7e1d79a7d75..757c1384c2d6 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -967,6 +967,7 @@ static struct buffer_head * ext4_dx_find_entry(struct dentry *dentry,
967 (block<<EXT4_BLOCK_SIZE_BITS(sb)) 967 (block<<EXT4_BLOCK_SIZE_BITS(sb))
968 +((char *)de - bh->b_data))) { 968 +((char *)de - bh->b_data))) {
969 brelse (bh); 969 brelse (bh);
970 *err = ERR_BAD_DX_DIR;
970 goto errout; 971 goto errout;
971 } 972 }
972 *res_dir = de; 973 *res_dir = de;
@@ -1132,9 +1133,9 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
1132 char *data1 = (*bh)->b_data, *data2; 1133 char *data1 = (*bh)->b_data, *data2;
1133 unsigned split; 1134 unsigned split;
1134 struct ext4_dir_entry_2 *de = NULL, *de2; 1135 struct ext4_dir_entry_2 *de = NULL, *de2;
1135 int err; 1136 int err = 0;
1136 1137
1137 bh2 = ext4_append (handle, dir, &newblock, error); 1138 bh2 = ext4_append (handle, dir, &newblock, &err);
1138 if (!(bh2)) { 1139 if (!(bh2)) {
1139 brelse(*bh); 1140 brelse(*bh);
1140 *bh = NULL; 1141 *bh = NULL;
@@ -1143,14 +1144,9 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
1143 1144
1144 BUFFER_TRACE(*bh, "get_write_access"); 1145 BUFFER_TRACE(*bh, "get_write_access");
1145 err = ext4_journal_get_write_access(handle, *bh); 1146 err = ext4_journal_get_write_access(handle, *bh);
1146 if (err) { 1147 if (err)
1147 journal_error: 1148 goto journal_error;
1148 brelse(*bh); 1149
1149 brelse(bh2);
1150 *bh = NULL;
1151 ext4_std_error(dir->i_sb, err);
1152 goto errout;
1153 }
1154 BUFFER_TRACE(frame->bh, "get_write_access"); 1150 BUFFER_TRACE(frame->bh, "get_write_access");
1155 err = ext4_journal_get_write_access(handle, frame->bh); 1151 err = ext4_journal_get_write_access(handle, frame->bh);
1156 if (err) 1152 if (err)
@@ -1193,8 +1189,16 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
1193 goto journal_error; 1189 goto journal_error;
1194 brelse (bh2); 1190 brelse (bh2);
1195 dxtrace(dx_show_index ("frame", frame->entries)); 1191 dxtrace(dx_show_index ("frame", frame->entries));
1196errout:
1197 return de; 1192 return de;
1193
1194journal_error:
1195 brelse(*bh);
1196 brelse(bh2);
1197 *bh = NULL;
1198 ext4_std_error(dir->i_sb, err);
1199errout:
1200 *error = err;
1201 return NULL;
1198} 1202}
1199#endif 1203#endif
1200 1204