diff options
Diffstat (limited to 'fs/ext4/namei.c')
-rw-r--r-- | fs/ext4/namei.c | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 6d2c1b897fc7..17a17e10dd60 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c | |||
@@ -1292,9 +1292,6 @@ errout: | |||
1292 | * add_dirent_to_buf will attempt search the directory block for | 1292 | * add_dirent_to_buf will attempt search the directory block for |
1293 | * space. It will return -ENOSPC if no space is available, and -EIO | 1293 | * space. It will return -ENOSPC if no space is available, and -EIO |
1294 | * and -EEXIST if directory entry already exists. | 1294 | * and -EEXIST if directory entry already exists. |
1295 | * | ||
1296 | * NOTE! bh is NOT released in the case where ENOSPC is returned. In | ||
1297 | * all other cases bh is released. | ||
1298 | */ | 1295 | */ |
1299 | static int add_dirent_to_buf(handle_t *handle, struct dentry *dentry, | 1296 | static int add_dirent_to_buf(handle_t *handle, struct dentry *dentry, |
1300 | struct inode *inode, struct ext4_dir_entry_2 *de, | 1297 | struct inode *inode, struct ext4_dir_entry_2 *de, |
@@ -1315,14 +1312,10 @@ static int add_dirent_to_buf(handle_t *handle, struct dentry *dentry, | |||
1315 | top = bh->b_data + blocksize - reclen; | 1312 | top = bh->b_data + blocksize - reclen; |
1316 | while ((char *) de <= top) { | 1313 | while ((char *) de <= top) { |
1317 | if (!ext4_check_dir_entry("ext4_add_entry", dir, de, | 1314 | if (!ext4_check_dir_entry("ext4_add_entry", dir, de, |
1318 | bh, offset)) { | 1315 | bh, offset)) |
1319 | brelse(bh); | ||
1320 | return -EIO; | 1316 | return -EIO; |
1321 | } | 1317 | if (ext4_match(namelen, name, de)) |
1322 | if (ext4_match(namelen, name, de)) { | ||
1323 | brelse(bh); | ||
1324 | return -EEXIST; | 1318 | return -EEXIST; |
1325 | } | ||
1326 | nlen = EXT4_DIR_REC_LEN(de->name_len); | 1319 | nlen = EXT4_DIR_REC_LEN(de->name_len); |
1327 | rlen = ext4_rec_len_from_disk(de->rec_len, blocksize); | 1320 | rlen = ext4_rec_len_from_disk(de->rec_len, blocksize); |
1328 | if ((de->inode? rlen - nlen: rlen) >= reclen) | 1321 | if ((de->inode? rlen - nlen: rlen) >= reclen) |
@@ -1337,7 +1330,6 @@ static int add_dirent_to_buf(handle_t *handle, struct dentry *dentry, | |||
1337 | err = ext4_journal_get_write_access(handle, bh); | 1330 | err = ext4_journal_get_write_access(handle, bh); |
1338 | if (err) { | 1331 | if (err) { |
1339 | ext4_std_error(dir->i_sb, err); | 1332 | ext4_std_error(dir->i_sb, err); |
1340 | brelse(bh); | ||
1341 | return err; | 1333 | return err; |
1342 | } | 1334 | } |
1343 | 1335 | ||
@@ -1377,7 +1369,6 @@ static int add_dirent_to_buf(handle_t *handle, struct dentry *dentry, | |||
1377 | err = ext4_handle_dirty_metadata(handle, dir, bh); | 1369 | err = ext4_handle_dirty_metadata(handle, dir, bh); |
1378 | if (err) | 1370 | if (err) |
1379 | ext4_std_error(dir->i_sb, err); | 1371 | ext4_std_error(dir->i_sb, err); |
1380 | brelse(bh); | ||
1381 | return 0; | 1372 | return 0; |
1382 | } | 1373 | } |
1383 | 1374 | ||
@@ -1471,7 +1462,9 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry, | |||
1471 | if (!(de)) | 1462 | if (!(de)) |
1472 | return retval; | 1463 | return retval; |
1473 | 1464 | ||
1474 | return add_dirent_to_buf(handle, dentry, inode, de, bh); | 1465 | retval = add_dirent_to_buf(handle, dentry, inode, de, bh); |
1466 | brelse(bh); | ||
1467 | return retval; | ||
1475 | } | 1468 | } |
1476 | 1469 | ||
1477 | /* | 1470 | /* |
@@ -1514,8 +1507,10 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry, | |||
1514 | if(!bh) | 1507 | if(!bh) |
1515 | return retval; | 1508 | return retval; |
1516 | retval = add_dirent_to_buf(handle, dentry, inode, NULL, bh); | 1509 | retval = add_dirent_to_buf(handle, dentry, inode, NULL, bh); |
1517 | if (retval != -ENOSPC) | 1510 | if (retval != -ENOSPC) { |
1511 | brelse(bh); | ||
1518 | return retval; | 1512 | return retval; |
1513 | } | ||
1519 | 1514 | ||
1520 | if (blocks == 1 && !dx_fallback && | 1515 | if (blocks == 1 && !dx_fallback && |
1521 | EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_DIR_INDEX)) | 1516 | EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_DIR_INDEX)) |
@@ -1528,7 +1523,9 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry, | |||
1528 | de = (struct ext4_dir_entry_2 *) bh->b_data; | 1523 | de = (struct ext4_dir_entry_2 *) bh->b_data; |
1529 | de->inode = 0; | 1524 | de->inode = 0; |
1530 | de->rec_len = ext4_rec_len_to_disk(blocksize, blocksize); | 1525 | de->rec_len = ext4_rec_len_to_disk(blocksize, blocksize); |
1531 | return add_dirent_to_buf(handle, dentry, inode, de, bh); | 1526 | retval = add_dirent_to_buf(handle, dentry, inode, de, bh); |
1527 | brelse(bh); | ||
1528 | return retval; | ||
1532 | } | 1529 | } |
1533 | 1530 | ||
1534 | /* | 1531 | /* |
@@ -1561,10 +1558,8 @@ static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, | |||
1561 | goto journal_error; | 1558 | goto journal_error; |
1562 | 1559 | ||
1563 | err = add_dirent_to_buf(handle, dentry, inode, NULL, bh); | 1560 | err = add_dirent_to_buf(handle, dentry, inode, NULL, bh); |
1564 | if (err != -ENOSPC) { | 1561 | if (err != -ENOSPC) |
1565 | bh = NULL; | ||
1566 | goto cleanup; | 1562 | goto cleanup; |
1567 | } | ||
1568 | 1563 | ||
1569 | /* Block full, should compress but for now just split */ | 1564 | /* Block full, should compress but for now just split */ |
1570 | dxtrace(printk(KERN_DEBUG "using %u of %u node entries\n", | 1565 | dxtrace(printk(KERN_DEBUG "using %u of %u node entries\n", |
@@ -1657,7 +1652,6 @@ static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, | |||
1657 | if (!de) | 1652 | if (!de) |
1658 | goto cleanup; | 1653 | goto cleanup; |
1659 | err = add_dirent_to_buf(handle, dentry, inode, de, bh); | 1654 | err = add_dirent_to_buf(handle, dentry, inode, de, bh); |
1660 | bh = NULL; | ||
1661 | goto cleanup; | 1655 | goto cleanup; |
1662 | 1656 | ||
1663 | journal_error: | 1657 | journal_error: |
@@ -1775,7 +1769,7 @@ static int ext4_create(struct inode *dir, struct dentry *dentry, int mode, | |||
1775 | retry: | 1769 | retry: |
1776 | handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + | 1770 | handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + |
1777 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + | 1771 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + |
1778 | 2*EXT4_QUOTA_INIT_BLOCKS(dir->i_sb)); | 1772 | EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb)); |
1779 | if (IS_ERR(handle)) | 1773 | if (IS_ERR(handle)) |
1780 | return PTR_ERR(handle); | 1774 | return PTR_ERR(handle); |
1781 | 1775 | ||
@@ -1809,7 +1803,7 @@ static int ext4_mknod(struct inode *dir, struct dentry *dentry, | |||
1809 | retry: | 1803 | retry: |
1810 | handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + | 1804 | handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + |
1811 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + | 1805 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + |
1812 | 2*EXT4_QUOTA_INIT_BLOCKS(dir->i_sb)); | 1806 | EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb)); |
1813 | if (IS_ERR(handle)) | 1807 | if (IS_ERR(handle)) |
1814 | return PTR_ERR(handle); | 1808 | return PTR_ERR(handle); |
1815 | 1809 | ||
@@ -1846,7 +1840,7 @@ static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
1846 | retry: | 1840 | retry: |
1847 | handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + | 1841 | handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + |
1848 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + | 1842 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + |
1849 | 2*EXT4_QUOTA_INIT_BLOCKS(dir->i_sb)); | 1843 | EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb)); |
1850 | if (IS_ERR(handle)) | 1844 | if (IS_ERR(handle)) |
1851 | return PTR_ERR(handle); | 1845 | return PTR_ERR(handle); |
1852 | 1846 | ||
@@ -2259,7 +2253,7 @@ static int ext4_symlink(struct inode *dir, | |||
2259 | retry: | 2253 | retry: |
2260 | handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + | 2254 | handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + |
2261 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 5 + | 2255 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 5 + |
2262 | 2*EXT4_QUOTA_INIT_BLOCKS(dir->i_sb)); | 2256 | EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb)); |
2263 | if (IS_ERR(handle)) | 2257 | if (IS_ERR(handle)) |
2264 | return PTR_ERR(handle); | 2258 | return PTR_ERR(handle); |
2265 | 2259 | ||