diff options
Diffstat (limited to 'fs/ext4/namei.c')
| -rw-r--r-- | fs/ext4/namei.c | 86 |
1 files changed, 52 insertions, 34 deletions
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 17a17e10dd60..0c070fabd108 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c | |||
| @@ -383,8 +383,7 @@ dx_probe(const struct qstr *d_name, struct inode *dir, | |||
| 383 | if (root->info.hash_version != DX_HASH_TEA && | 383 | if (root->info.hash_version != DX_HASH_TEA && |
| 384 | root->info.hash_version != DX_HASH_HALF_MD4 && | 384 | root->info.hash_version != DX_HASH_HALF_MD4 && |
| 385 | root->info.hash_version != DX_HASH_LEGACY) { | 385 | root->info.hash_version != DX_HASH_LEGACY) { |
| 386 | ext4_warning(dir->i_sb, __func__, | 386 | ext4_warning(dir->i_sb, "Unrecognised inode hash code %d", |
| 387 | "Unrecognised inode hash code %d", | ||
| 388 | root->info.hash_version); | 387 | root->info.hash_version); |
| 389 | brelse(bh); | 388 | brelse(bh); |
| 390 | *err = ERR_BAD_DX_DIR; | 389 | *err = ERR_BAD_DX_DIR; |
| @@ -399,8 +398,7 @@ dx_probe(const struct qstr *d_name, struct inode *dir, | |||
| 399 | hash = hinfo->hash; | 398 | hash = hinfo->hash; |
| 400 | 399 | ||
| 401 | if (root->info.unused_flags & 1) { | 400 | if (root->info.unused_flags & 1) { |
| 402 | ext4_warning(dir->i_sb, __func__, | 401 | ext4_warning(dir->i_sb, "Unimplemented inode hash flags: %#06x", |
| 403 | "Unimplemented inode hash flags: %#06x", | ||
| 404 | root->info.unused_flags); | 402 | root->info.unused_flags); |
| 405 | brelse(bh); | 403 | brelse(bh); |
| 406 | *err = ERR_BAD_DX_DIR; | 404 | *err = ERR_BAD_DX_DIR; |
| @@ -408,8 +406,7 @@ dx_probe(const struct qstr *d_name, struct inode *dir, | |||
| 408 | } | 406 | } |
| 409 | 407 | ||
| 410 | if ((indirect = root->info.indirect_levels) > 1) { | 408 | if ((indirect = root->info.indirect_levels) > 1) { |
| 411 | ext4_warning(dir->i_sb, __func__, | 409 | ext4_warning(dir->i_sb, "Unimplemented inode hash depth: %#06x", |
| 412 | "Unimplemented inode hash depth: %#06x", | ||
| 413 | root->info.indirect_levels); | 410 | root->info.indirect_levels); |
| 414 | brelse(bh); | 411 | brelse(bh); |
| 415 | *err = ERR_BAD_DX_DIR; | 412 | *err = ERR_BAD_DX_DIR; |
| @@ -421,8 +418,7 @@ dx_probe(const struct qstr *d_name, struct inode *dir, | |||
| 421 | 418 | ||
| 422 | if (dx_get_limit(entries) != dx_root_limit(dir, | 419 | if (dx_get_limit(entries) != dx_root_limit(dir, |
| 423 | root->info.info_length)) { | 420 | root->info.info_length)) { |
| 424 | ext4_warning(dir->i_sb, __func__, | 421 | ext4_warning(dir->i_sb, "dx entry: limit != root limit"); |
| 425 | "dx entry: limit != root limit"); | ||
| 426 | brelse(bh); | 422 | brelse(bh); |
| 427 | *err = ERR_BAD_DX_DIR; | 423 | *err = ERR_BAD_DX_DIR; |
| 428 | goto fail; | 424 | goto fail; |
| @@ -433,7 +429,7 @@ dx_probe(const struct qstr *d_name, struct inode *dir, | |||
| 433 | { | 429 | { |
| 434 | count = dx_get_count(entries); | 430 | count = dx_get_count(entries); |
| 435 | if (!count || count > dx_get_limit(entries)) { | 431 | if (!count || count > dx_get_limit(entries)) { |
| 436 | ext4_warning(dir->i_sb, __func__, | 432 | ext4_warning(dir->i_sb, |
| 437 | "dx entry: no count or count > limit"); | 433 | "dx entry: no count or count > limit"); |
| 438 | brelse(bh); | 434 | brelse(bh); |
| 439 | *err = ERR_BAD_DX_DIR; | 435 | *err = ERR_BAD_DX_DIR; |
| @@ -478,7 +474,7 @@ dx_probe(const struct qstr *d_name, struct inode *dir, | |||
| 478 | goto fail2; | 474 | goto fail2; |
| 479 | at = entries = ((struct dx_node *) bh->b_data)->entries; | 475 | at = entries = ((struct dx_node *) bh->b_data)->entries; |
| 480 | if (dx_get_limit(entries) != dx_node_limit (dir)) { | 476 | if (dx_get_limit(entries) != dx_node_limit (dir)) { |
| 481 | ext4_warning(dir->i_sb, __func__, | 477 | ext4_warning(dir->i_sb, |
| 482 | "dx entry: limit != node limit"); | 478 | "dx entry: limit != node limit"); |
| 483 | brelse(bh); | 479 | brelse(bh); |
| 484 | *err = ERR_BAD_DX_DIR; | 480 | *err = ERR_BAD_DX_DIR; |
| @@ -494,7 +490,7 @@ fail2: | |||
| 494 | } | 490 | } |
| 495 | fail: | 491 | fail: |
| 496 | if (*err == ERR_BAD_DX_DIR) | 492 | if (*err == ERR_BAD_DX_DIR) |
| 497 | ext4_warning(dir->i_sb, __func__, | 493 | ext4_warning(dir->i_sb, |
| 498 | "Corrupt dir inode %ld, running e2fsck is " | 494 | "Corrupt dir inode %ld, running e2fsck is " |
| 499 | "recommended.", dir->i_ino); | 495 | "recommended.", dir->i_ino); |
| 500 | return NULL; | 496 | return NULL; |
| @@ -947,9 +943,8 @@ restart: | |||
| 947 | wait_on_buffer(bh); | 943 | wait_on_buffer(bh); |
| 948 | if (!buffer_uptodate(bh)) { | 944 | if (!buffer_uptodate(bh)) { |
| 949 | /* read error, skip block & hope for the best */ | 945 | /* read error, skip block & hope for the best */ |
| 950 | ext4_error(sb, __func__, "reading directory #%lu " | 946 | ext4_error(sb, "reading directory #%lu offset %lu", |
| 951 | "offset %lu", dir->i_ino, | 947 | dir->i_ino, (unsigned long)block); |
| 952 | (unsigned long)block); | ||
| 953 | brelse(bh); | 948 | brelse(bh); |
| 954 | goto next; | 949 | goto next; |
| 955 | } | 950 | } |
| @@ -1041,7 +1036,7 @@ static struct buffer_head * ext4_dx_find_entry(struct inode *dir, const struct q | |||
| 1041 | retval = ext4_htree_next_block(dir, hash, frame, | 1036 | retval = ext4_htree_next_block(dir, hash, frame, |
| 1042 | frames, NULL); | 1037 | frames, NULL); |
| 1043 | if (retval < 0) { | 1038 | if (retval < 0) { |
| 1044 | ext4_warning(sb, __func__, | 1039 | ext4_warning(sb, |
| 1045 | "error reading index page in directory #%lu", | 1040 | "error reading index page in directory #%lu", |
| 1046 | dir->i_ino); | 1041 | dir->i_ino); |
| 1047 | *err = retval; | 1042 | *err = retval; |
| @@ -1071,14 +1066,13 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, stru | |||
| 1071 | __u32 ino = le32_to_cpu(de->inode); | 1066 | __u32 ino = le32_to_cpu(de->inode); |
| 1072 | brelse(bh); | 1067 | brelse(bh); |
| 1073 | if (!ext4_valid_inum(dir->i_sb, ino)) { | 1068 | if (!ext4_valid_inum(dir->i_sb, ino)) { |
| 1074 | ext4_error(dir->i_sb, "ext4_lookup", | 1069 | ext4_error(dir->i_sb, "bad inode number: %u", ino); |
| 1075 | "bad inode number: %u", ino); | ||
| 1076 | return ERR_PTR(-EIO); | 1070 | return ERR_PTR(-EIO); |
| 1077 | } | 1071 | } |
| 1078 | inode = ext4_iget(dir->i_sb, ino); | 1072 | inode = ext4_iget(dir->i_sb, ino); |
| 1079 | if (unlikely(IS_ERR(inode))) { | 1073 | if (unlikely(IS_ERR(inode))) { |
| 1080 | if (PTR_ERR(inode) == -ESTALE) { | 1074 | if (PTR_ERR(inode) == -ESTALE) { |
| 1081 | ext4_error(dir->i_sb, __func__, | 1075 | ext4_error(dir->i_sb, |
| 1082 | "deleted inode referenced: %u", | 1076 | "deleted inode referenced: %u", |
| 1083 | ino); | 1077 | ino); |
| 1084 | return ERR_PTR(-EIO); | 1078 | return ERR_PTR(-EIO); |
| @@ -1110,7 +1104,7 @@ struct dentry *ext4_get_parent(struct dentry *child) | |||
| 1110 | brelse(bh); | 1104 | brelse(bh); |
| 1111 | 1105 | ||
| 1112 | if (!ext4_valid_inum(child->d_inode->i_sb, ino)) { | 1106 | if (!ext4_valid_inum(child->d_inode->i_sb, ino)) { |
| 1113 | ext4_error(child->d_inode->i_sb, "ext4_get_parent", | 1107 | ext4_error(child->d_inode->i_sb, |
| 1114 | "bad inode number: %u", ino); | 1108 | "bad inode number: %u", ino); |
| 1115 | return ERR_PTR(-EIO); | 1109 | return ERR_PTR(-EIO); |
| 1116 | } | 1110 | } |
| @@ -1410,7 +1404,7 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry, | |||
| 1410 | de = (struct ext4_dir_entry_2 *)((char *)fde + | 1404 | de = (struct ext4_dir_entry_2 *)((char *)fde + |
| 1411 | ext4_rec_len_from_disk(fde->rec_len, blocksize)); | 1405 | ext4_rec_len_from_disk(fde->rec_len, blocksize)); |
| 1412 | if ((char *) de >= (((char *) root) + blocksize)) { | 1406 | if ((char *) de >= (((char *) root) + blocksize)) { |
| 1413 | ext4_error(dir->i_sb, __func__, | 1407 | ext4_error(dir->i_sb, |
| 1414 | "invalid rec_len for '..' in inode %lu", | 1408 | "invalid rec_len for '..' in inode %lu", |
| 1415 | dir->i_ino); | 1409 | dir->i_ino); |
| 1416 | brelse(bh); | 1410 | brelse(bh); |
| @@ -1575,8 +1569,7 @@ static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, | |||
| 1575 | 1569 | ||
| 1576 | if (levels && (dx_get_count(frames->entries) == | 1570 | if (levels && (dx_get_count(frames->entries) == |
| 1577 | dx_get_limit(frames->entries))) { | 1571 | dx_get_limit(frames->entries))) { |
| 1578 | ext4_warning(sb, __func__, | 1572 | ext4_warning(sb, "Directory index full!"); |
| 1579 | "Directory index full!"); | ||
| 1580 | err = -ENOSPC; | 1573 | err = -ENOSPC; |
| 1581 | goto cleanup; | 1574 | goto cleanup; |
| 1582 | } | 1575 | } |
| @@ -1766,6 +1759,8 @@ static int ext4_create(struct inode *dir, struct dentry *dentry, int mode, | |||
| 1766 | struct inode *inode; | 1759 | struct inode *inode; |
| 1767 | int err, retries = 0; | 1760 | int err, retries = 0; |
| 1768 | 1761 | ||
| 1762 | dquot_initialize(dir); | ||
| 1763 | |||
| 1769 | retry: | 1764 | retry: |
| 1770 | handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + | 1765 | handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + |
| 1771 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + | 1766 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + |
| @@ -1800,6 +1795,8 @@ static int ext4_mknod(struct inode *dir, struct dentry *dentry, | |||
| 1800 | if (!new_valid_dev(rdev)) | 1795 | if (!new_valid_dev(rdev)) |
| 1801 | return -EINVAL; | 1796 | return -EINVAL; |
| 1802 | 1797 | ||
| 1798 | dquot_initialize(dir); | ||
| 1799 | |||
| 1803 | retry: | 1800 | retry: |
| 1804 | handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + | 1801 | handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + |
| 1805 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + | 1802 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + |
| @@ -1837,6 +1834,8 @@ static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
| 1837 | if (EXT4_DIR_LINK_MAX(dir)) | 1834 | if (EXT4_DIR_LINK_MAX(dir)) |
| 1838 | return -EMLINK; | 1835 | return -EMLINK; |
| 1839 | 1836 | ||
| 1837 | dquot_initialize(dir); | ||
| 1838 | |||
| 1840 | retry: | 1839 | retry: |
| 1841 | handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + | 1840 | handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + |
| 1842 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + | 1841 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + |
| @@ -1916,11 +1915,11 @@ static int empty_dir(struct inode *inode) | |||
| 1916 | if (inode->i_size < EXT4_DIR_REC_LEN(1) + EXT4_DIR_REC_LEN(2) || | 1915 | if (inode->i_size < EXT4_DIR_REC_LEN(1) + EXT4_DIR_REC_LEN(2) || |
| 1917 | !(bh = ext4_bread(NULL, inode, 0, 0, &err))) { | 1916 | !(bh = ext4_bread(NULL, inode, 0, 0, &err))) { |
| 1918 | if (err) | 1917 | if (err) |
| 1919 | ext4_error(inode->i_sb, __func__, | 1918 | ext4_error(inode->i_sb, |
| 1920 | "error %d reading directory #%lu offset 0", | 1919 | "error %d reading directory #%lu offset 0", |
| 1921 | err, inode->i_ino); | 1920 | err, inode->i_ino); |
| 1922 | else | 1921 | else |
| 1923 | ext4_warning(inode->i_sb, __func__, | 1922 | ext4_warning(inode->i_sb, |
| 1924 | "bad directory (dir #%lu) - no data block", | 1923 | "bad directory (dir #%lu) - no data block", |
| 1925 | inode->i_ino); | 1924 | inode->i_ino); |
| 1926 | return 1; | 1925 | return 1; |
| @@ -1931,7 +1930,7 @@ static int empty_dir(struct inode *inode) | |||
| 1931 | !le32_to_cpu(de1->inode) || | 1930 | !le32_to_cpu(de1->inode) || |
| 1932 | strcmp(".", de->name) || | 1931 | strcmp(".", de->name) || |
| 1933 | strcmp("..", de1->name)) { | 1932 | strcmp("..", de1->name)) { |
| 1934 | ext4_warning(inode->i_sb, "empty_dir", | 1933 | ext4_warning(inode->i_sb, |
| 1935 | "bad directory (dir #%lu) - no `.' or `..'", | 1934 | "bad directory (dir #%lu) - no `.' or `..'", |
| 1936 | inode->i_ino); | 1935 | inode->i_ino); |
| 1937 | brelse(bh); | 1936 | brelse(bh); |
| @@ -1949,7 +1948,7 @@ static int empty_dir(struct inode *inode) | |||
| 1949 | offset >> EXT4_BLOCK_SIZE_BITS(sb), 0, &err); | 1948 | offset >> EXT4_BLOCK_SIZE_BITS(sb), 0, &err); |
| 1950 | if (!bh) { | 1949 | if (!bh) { |
| 1951 | if (err) | 1950 | if (err) |
| 1952 | ext4_error(sb, __func__, | 1951 | ext4_error(sb, |
| 1953 | "error %d reading directory" | 1952 | "error %d reading directory" |
| 1954 | " #%lu offset %u", | 1953 | " #%lu offset %u", |
| 1955 | err, inode->i_ino, offset); | 1954 | err, inode->i_ino, offset); |
| @@ -2020,11 +2019,18 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode) | |||
| 2020 | err = ext4_reserve_inode_write(handle, inode, &iloc); | 2019 | err = ext4_reserve_inode_write(handle, inode, &iloc); |
| 2021 | if (err) | 2020 | if (err) |
| 2022 | goto out_unlock; | 2021 | goto out_unlock; |
| 2022 | /* | ||
| 2023 | * Due to previous errors inode may be already a part of on-disk | ||
| 2024 | * orphan list. If so skip on-disk list modification. | ||
| 2025 | */ | ||
| 2026 | if (NEXT_ORPHAN(inode) && NEXT_ORPHAN(inode) <= | ||
| 2027 | (le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count))) | ||
| 2028 | goto mem_insert; | ||
| 2023 | 2029 | ||
| 2024 | /* Insert this inode at the head of the on-disk orphan list... */ | 2030 | /* Insert this inode at the head of the on-disk orphan list... */ |
| 2025 | NEXT_ORPHAN(inode) = le32_to_cpu(EXT4_SB(sb)->s_es->s_last_orphan); | 2031 | NEXT_ORPHAN(inode) = le32_to_cpu(EXT4_SB(sb)->s_es->s_last_orphan); |
| 2026 | EXT4_SB(sb)->s_es->s_last_orphan = cpu_to_le32(inode->i_ino); | 2032 | EXT4_SB(sb)->s_es->s_last_orphan = cpu_to_le32(inode->i_ino); |
| 2027 | err = ext4_handle_dirty_metadata(handle, inode, EXT4_SB(sb)->s_sbh); | 2033 | err = ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh); |
| 2028 | rc = ext4_mark_iloc_dirty(handle, inode, &iloc); | 2034 | rc = ext4_mark_iloc_dirty(handle, inode, &iloc); |
| 2029 | if (!err) | 2035 | if (!err) |
| 2030 | err = rc; | 2036 | err = rc; |
| @@ -2037,6 +2043,7 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode) | |||
| 2037 | * | 2043 | * |
| 2038 | * This is safe: on error we're going to ignore the orphan list | 2044 | * This is safe: on error we're going to ignore the orphan list |
| 2039 | * anyway on the next recovery. */ | 2045 | * anyway on the next recovery. */ |
| 2046 | mem_insert: | ||
| 2040 | if (!err) | 2047 | if (!err) |
| 2041 | list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan); | 2048 | list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan); |
| 2042 | 2049 | ||
| @@ -2096,7 +2103,7 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode) | |||
| 2096 | if (err) | 2103 | if (err) |
| 2097 | goto out_brelse; | 2104 | goto out_brelse; |
| 2098 | sbi->s_es->s_last_orphan = cpu_to_le32(ino_next); | 2105 | sbi->s_es->s_last_orphan = cpu_to_le32(ino_next); |
| 2099 | err = ext4_handle_dirty_metadata(handle, inode, sbi->s_sbh); | 2106 | err = ext4_handle_dirty_metadata(handle, NULL, sbi->s_sbh); |
| 2100 | } else { | 2107 | } else { |
| 2101 | struct ext4_iloc iloc2; | 2108 | struct ext4_iloc iloc2; |
| 2102 | struct inode *i_prev = | 2109 | struct inode *i_prev = |
| @@ -2136,7 +2143,9 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry) | |||
| 2136 | 2143 | ||
| 2137 | /* Initialize quotas before so that eventual writes go in | 2144 | /* Initialize quotas before so that eventual writes go in |
| 2138 | * separate transaction */ | 2145 | * separate transaction */ |
| 2139 | vfs_dq_init(dentry->d_inode); | 2146 | dquot_initialize(dir); |
| 2147 | dquot_initialize(dentry->d_inode); | ||
| 2148 | |||
| 2140 | handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb)); | 2149 | handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb)); |
| 2141 | if (IS_ERR(handle)) | 2150 | if (IS_ERR(handle)) |
| 2142 | return PTR_ERR(handle); | 2151 | return PTR_ERR(handle); |
| @@ -2163,7 +2172,7 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry) | |||
| 2163 | if (retval) | 2172 | if (retval) |
| 2164 | goto end_rmdir; | 2173 | goto end_rmdir; |
| 2165 | if (!EXT4_DIR_LINK_EMPTY(inode)) | 2174 | if (!EXT4_DIR_LINK_EMPTY(inode)) |
| 2166 | ext4_warning(inode->i_sb, "ext4_rmdir", | 2175 | ext4_warning(inode->i_sb, |
| 2167 | "empty directory has too many links (%d)", | 2176 | "empty directory has too many links (%d)", |
| 2168 | inode->i_nlink); | 2177 | inode->i_nlink); |
| 2169 | inode->i_version++; | 2178 | inode->i_version++; |
| @@ -2195,7 +2204,9 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry) | |||
| 2195 | 2204 | ||
| 2196 | /* Initialize quotas before so that eventual writes go | 2205 | /* Initialize quotas before so that eventual writes go |
| 2197 | * in separate transaction */ | 2206 | * in separate transaction */ |
| 2198 | vfs_dq_init(dentry->d_inode); | 2207 | dquot_initialize(dir); |
| 2208 | dquot_initialize(dentry->d_inode); | ||
| 2209 | |||
| 2199 | handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb)); | 2210 | handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb)); |
| 2200 | if (IS_ERR(handle)) | 2211 | if (IS_ERR(handle)) |
| 2201 | return PTR_ERR(handle); | 2212 | return PTR_ERR(handle); |
| @@ -2215,7 +2226,7 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry) | |||
| 2215 | goto end_unlink; | 2226 | goto end_unlink; |
| 2216 | 2227 | ||
| 2217 | if (!inode->i_nlink) { | 2228 | if (!inode->i_nlink) { |
| 2218 | ext4_warning(inode->i_sb, "ext4_unlink", | 2229 | ext4_warning(inode->i_sb, |
| 2219 | "Deleting nonexistent file (%lu), %d", | 2230 | "Deleting nonexistent file (%lu), %d", |
| 2220 | inode->i_ino, inode->i_nlink); | 2231 | inode->i_ino, inode->i_nlink); |
| 2221 | inode->i_nlink = 1; | 2232 | inode->i_nlink = 1; |
| @@ -2250,6 +2261,8 @@ static int ext4_symlink(struct inode *dir, | |||
| 2250 | if (l > dir->i_sb->s_blocksize) | 2261 | if (l > dir->i_sb->s_blocksize) |
| 2251 | return -ENAMETOOLONG; | 2262 | return -ENAMETOOLONG; |
| 2252 | 2263 | ||
| 2264 | dquot_initialize(dir); | ||
| 2265 | |||
| 2253 | retry: | 2266 | retry: |
| 2254 | handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + | 2267 | handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + |
| 2255 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 5 + | 2268 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 5 + |
| @@ -2308,6 +2321,8 @@ static int ext4_link(struct dentry *old_dentry, | |||
| 2308 | if (inode->i_nlink >= EXT4_LINK_MAX) | 2321 | if (inode->i_nlink >= EXT4_LINK_MAX) |
| 2309 | return -EMLINK; | 2322 | return -EMLINK; |
| 2310 | 2323 | ||
| 2324 | dquot_initialize(dir); | ||
| 2325 | |||
| 2311 | /* | 2326 | /* |
| 2312 | * Return -ENOENT if we've raced with unlink and i_nlink is 0. Doing | 2327 | * Return -ENOENT if we've raced with unlink and i_nlink is 0. Doing |
| 2313 | * otherwise has the potential to corrupt the orphan inode list. | 2328 | * otherwise has the potential to corrupt the orphan inode list. |
| @@ -2358,12 +2373,15 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
| 2358 | struct ext4_dir_entry_2 *old_de, *new_de; | 2373 | struct ext4_dir_entry_2 *old_de, *new_de; |
| 2359 | int retval, force_da_alloc = 0; | 2374 | int retval, force_da_alloc = 0; |
| 2360 | 2375 | ||
| 2376 | dquot_initialize(old_dir); | ||
| 2377 | dquot_initialize(new_dir); | ||
| 2378 | |||
| 2361 | old_bh = new_bh = dir_bh = NULL; | 2379 | old_bh = new_bh = dir_bh = NULL; |
| 2362 | 2380 | ||
| 2363 | /* Initialize quotas before so that eventual writes go | 2381 | /* Initialize quotas before so that eventual writes go |
| 2364 | * in separate transaction */ | 2382 | * in separate transaction */ |
| 2365 | if (new_dentry->d_inode) | 2383 | if (new_dentry->d_inode) |
| 2366 | vfs_dq_init(new_dentry->d_inode); | 2384 | dquot_initialize(new_dentry->d_inode); |
| 2367 | handle = ext4_journal_start(old_dir, 2 * | 2385 | handle = ext4_journal_start(old_dir, 2 * |
| 2368 | EXT4_DATA_TRANS_BLOCKS(old_dir->i_sb) + | 2386 | EXT4_DATA_TRANS_BLOCKS(old_dir->i_sb) + |
| 2369 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2); | 2387 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 2); |
| @@ -2462,7 +2480,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
| 2462 | } | 2480 | } |
| 2463 | } | 2481 | } |
| 2464 | if (retval) { | 2482 | if (retval) { |
| 2465 | ext4_warning(old_dir->i_sb, "ext4_rename", | 2483 | ext4_warning(old_dir->i_sb, |
| 2466 | "Deleting old file (%lu), %d, error=%d", | 2484 | "Deleting old file (%lu), %d, error=%d", |
| 2467 | old_dir->i_ino, old_dir->i_nlink, retval); | 2485 | old_dir->i_ino, old_dir->i_nlink, retval); |
| 2468 | } | 2486 | } |
