aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2014-08-29 20:49:51 -0400
committerTheodore Ts'o <tytso@mit.edu>2014-08-29 20:49:51 -0400
commit537d8f93805ace30ce097736d3aac041931274b1 (patch)
tree9f9c7fcd90d388d0fb5cc37e0e9250b6cf35412b /fs/ext4
parentd4f03186c8986ffde34d06fe74a99aab08f7ee0b (diff)
ext4: convert ext4_dx_find_entry() to use the ERR_PTR convention
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/namei.c46
1 files changed, 20 insertions, 26 deletions
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 90a3cdca3f88..1421ec1cd7e4 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -270,8 +270,7 @@ static int ext4_htree_next_block(struct inode *dir, __u32 hash,
270 __u32 *start_hash); 270 __u32 *start_hash);
271static struct buffer_head * ext4_dx_find_entry(struct inode *dir, 271static struct buffer_head * ext4_dx_find_entry(struct inode *dir,
272 const struct qstr *d_name, 272 const struct qstr *d_name,
273 struct ext4_dir_entry_2 **res_dir, 273 struct ext4_dir_entry_2 **res_dir);
274 int *err);
275static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, 274static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry,
276 struct inode *inode); 275 struct inode *inode);
277 276
@@ -1258,17 +1257,13 @@ static struct buffer_head * ext4_find_entry (struct inode *dir,
1258 goto restart; 1257 goto restart;
1259 } 1258 }
1260 if (is_dx(dir)) { 1259 if (is_dx(dir)) {
1261 bh = ext4_dx_find_entry(dir, d_name, res_dir, &err); 1260 bh = ext4_dx_find_entry(dir, d_name, res_dir);
1262 /* 1261 /*
1263 * On success, or if the error was file not found, 1262 * On success, or if the error was file not found,
1264 * return. Otherwise, fall back to doing a search the 1263 * return. Otherwise, fall back to doing a search the
1265 * old fashioned way. 1264 * old fashioned way.
1266 */ 1265 */
1267 if (err == -ENOENT) 1266 if (!IS_ERR(bh) || PTR_ERR(bh) != ERR_BAD_DX_DIR)
1268 return NULL;
1269 if (err && err != ERR_BAD_DX_DIR)
1270 return ERR_PTR(err);
1271 if (bh)
1272 return bh; 1267 return bh;
1273 dxtrace(printk(KERN_DEBUG "ext4_find_entry: dx failed, " 1268 dxtrace(printk(KERN_DEBUG "ext4_find_entry: dx failed, "
1274 "falling back\n")); 1269 "falling back\n"));
@@ -1366,34 +1361,32 @@ cleanup_and_exit:
1366} 1361}
1367 1362
1368static struct buffer_head * ext4_dx_find_entry(struct inode *dir, const struct qstr *d_name, 1363static struct buffer_head * ext4_dx_find_entry(struct inode *dir, const struct qstr *d_name,
1369 struct ext4_dir_entry_2 **res_dir, int *err) 1364 struct ext4_dir_entry_2 **res_dir)
1370{ 1365{
1371 struct super_block * sb = dir->i_sb; 1366 struct super_block * sb = dir->i_sb;
1372 struct dx_hash_info hinfo; 1367 struct dx_hash_info hinfo;
1373 struct dx_frame frames[2], *frame; 1368 struct dx_frame frames[2], *frame;
1374 struct buffer_head *bh; 1369 struct buffer_head *bh;
1375 ext4_lblk_t block; 1370 ext4_lblk_t block;
1376 int retval; 1371 int err = 0, retval;
1377 1372
1378 if (!(frame = dx_probe(d_name, dir, &hinfo, frames, err))) 1373 frame = dx_probe(d_name, dir, &hinfo, frames, &err);
1379 return NULL; 1374 if (err)
1375 return ERR_PTR(err);
1380 do { 1376 do {
1381 block = dx_get_block(frame->at); 1377 block = dx_get_block(frame->at);
1382 bh = ext4_read_dirblock(dir, block, DIRENT); 1378 bh = ext4_read_dirblock(dir, block, DIRENT);
1383 if (IS_ERR(bh)) { 1379 if (IS_ERR(bh))
1384 *err = PTR_ERR(bh);
1385 goto errout; 1380 goto errout;
1386 } 1381
1387 retval = search_dirblock(bh, dir, d_name, 1382 retval = search_dirblock(bh, dir, d_name,
1388 block << EXT4_BLOCK_SIZE_BITS(sb), 1383 block << EXT4_BLOCK_SIZE_BITS(sb),
1389 res_dir); 1384 res_dir);
1390 if (retval == 1) { /* Success! */ 1385 if (retval == 1)
1391 dx_release(frames); 1386 goto success;
1392 return bh;
1393 }
1394 brelse(bh); 1387 brelse(bh);
1395 if (retval == -1) { 1388 if (retval == -1) {
1396 *err = ERR_BAD_DX_DIR; 1389 bh = ERR_PTR(ERR_BAD_DX_DIR);
1397 goto errout; 1390 goto errout;
1398 } 1391 }
1399 1392
@@ -1402,18 +1395,19 @@ static struct buffer_head * ext4_dx_find_entry(struct inode *dir, const struct q
1402 frames, NULL); 1395 frames, NULL);
1403 if (retval < 0) { 1396 if (retval < 0) {
1404 ext4_warning(sb, 1397 ext4_warning(sb,
1405 "error reading index page in directory #%lu", 1398 "error %d reading index page in directory #%lu",
1406 dir->i_ino); 1399 retval, dir->i_ino);
1407 *err = retval; 1400 bh = ERR_PTR(retval);
1408 goto errout; 1401 goto errout;
1409 } 1402 }
1410 } while (retval == 1); 1403 } while (retval == 1);
1411 1404
1412 *err = -ENOENT; 1405 bh = NULL;
1413errout: 1406errout:
1414 dxtrace(printk(KERN_DEBUG "%s not found\n", d_name->name)); 1407 dxtrace(printk(KERN_DEBUG "%s not found\n", d_name->name));
1415 dx_release (frames); 1408success:
1416 return NULL; 1409 dx_release(frames);
1410 return bh;
1417} 1411}
1418 1412
1419static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) 1413static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)