diff options
Diffstat (limited to 'fs/ext4/ialloc.c')
| -rw-r--r-- | fs/ext4/ialloc.c | 52 |
1 files changed, 22 insertions, 30 deletions
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index f3624ead4f6c..57f6eef6ccd6 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c | |||
| @@ -76,8 +76,7 @@ unsigned ext4_init_inode_bitmap(struct super_block *sb, struct buffer_head *bh, | |||
| 76 | /* If checksum is bad mark all blocks and inodes use to prevent | 76 | /* If checksum is bad mark all blocks and inodes use to prevent |
| 77 | * allocation, essentially implementing a per-group read-only flag. */ | 77 | * allocation, essentially implementing a per-group read-only flag. */ |
| 78 | if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) { | 78 | if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) { |
| 79 | ext4_error(sb, __func__, "Checksum bad for group %u", | 79 | ext4_error(sb, "Checksum bad for group %u", block_group); |
| 80 | block_group); | ||
| 81 | ext4_free_blks_set(sb, gdp, 0); | 80 | ext4_free_blks_set(sb, gdp, 0); |
| 82 | ext4_free_inodes_set(sb, gdp, 0); | 81 | ext4_free_inodes_set(sb, gdp, 0); |
| 83 | ext4_itable_unused_set(sb, gdp, 0); | 82 | ext4_itable_unused_set(sb, gdp, 0); |
| @@ -111,8 +110,7 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group) | |||
| 111 | bitmap_blk = ext4_inode_bitmap(sb, desc); | 110 | bitmap_blk = ext4_inode_bitmap(sb, desc); |
| 112 | bh = sb_getblk(sb, bitmap_blk); | 111 | bh = sb_getblk(sb, bitmap_blk); |
| 113 | if (unlikely(!bh)) { | 112 | if (unlikely(!bh)) { |
| 114 | ext4_error(sb, __func__, | 113 | ext4_error(sb, "Cannot read inode bitmap - " |
| 115 | "Cannot read inode bitmap - " | ||
| 116 | "block_group = %u, inode_bitmap = %llu", | 114 | "block_group = %u, inode_bitmap = %llu", |
| 117 | block_group, bitmap_blk); | 115 | block_group, bitmap_blk); |
| 118 | return NULL; | 116 | return NULL; |
| @@ -153,8 +151,7 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group) | |||
| 153 | set_bitmap_uptodate(bh); | 151 | set_bitmap_uptodate(bh); |
| 154 | if (bh_submit_read(bh) < 0) { | 152 | if (bh_submit_read(bh) < 0) { |
| 155 | put_bh(bh); | 153 | put_bh(bh); |
| 156 | ext4_error(sb, __func__, | 154 | ext4_error(sb, "Cannot read inode bitmap - " |
| 157 | "Cannot read inode bitmap - " | ||
| 158 | "block_group = %u, inode_bitmap = %llu", | 155 | "block_group = %u, inode_bitmap = %llu", |
| 159 | block_group, bitmap_blk); | 156 | block_group, bitmap_blk); |
| 160 | return NULL; | 157 | return NULL; |
| @@ -217,10 +214,10 @@ void ext4_free_inode(handle_t *handle, struct inode *inode) | |||
| 217 | * Note: we must free any quota before locking the superblock, | 214 | * Note: we must free any quota before locking the superblock, |
| 218 | * as writing the quota to disk may need the lock as well. | 215 | * as writing the quota to disk may need the lock as well. |
| 219 | */ | 216 | */ |
| 220 | vfs_dq_init(inode); | 217 | dquot_initialize(inode); |
| 221 | ext4_xattr_delete_inode(handle, inode); | 218 | ext4_xattr_delete_inode(handle, inode); |
| 222 | vfs_dq_free_inode(inode); | 219 | dquot_free_inode(inode); |
| 223 | vfs_dq_drop(inode); | 220 | dquot_drop(inode); |
| 224 | 221 | ||
| 225 | is_directory = S_ISDIR(inode->i_mode); | 222 | is_directory = S_ISDIR(inode->i_mode); |
| 226 | 223 | ||
| @@ -229,8 +226,7 @@ void ext4_free_inode(handle_t *handle, struct inode *inode) | |||
| 229 | 226 | ||
| 230 | es = EXT4_SB(sb)->s_es; | 227 | es = EXT4_SB(sb)->s_es; |
| 231 | if (ino < EXT4_FIRST_INO(sb) || ino > le32_to_cpu(es->s_inodes_count)) { | 228 | if (ino < EXT4_FIRST_INO(sb) || ino > le32_to_cpu(es->s_inodes_count)) { |
| 232 | ext4_error(sb, "ext4_free_inode", | 229 | ext4_error(sb, "reserved or nonexistent inode %lu", ino); |
| 233 | "reserved or nonexistent inode %lu", ino); | ||
| 234 | goto error_return; | 230 | goto error_return; |
| 235 | } | 231 | } |
| 236 | block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb); | 232 | block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb); |
| @@ -248,8 +244,7 @@ void ext4_free_inode(handle_t *handle, struct inode *inode) | |||
| 248 | cleared = ext4_clear_bit_atomic(ext4_group_lock_ptr(sb, block_group), | 244 | cleared = ext4_clear_bit_atomic(ext4_group_lock_ptr(sb, block_group), |
| 249 | bit, bitmap_bh->b_data); | 245 | bit, bitmap_bh->b_data); |
| 250 | if (!cleared) | 246 | if (!cleared) |
| 251 | ext4_error(sb, "ext4_free_inode", | 247 | ext4_error(sb, "bit already cleared for inode %lu", ino); |
| 252 | "bit already cleared for inode %lu", ino); | ||
| 253 | else { | 248 | else { |
| 254 | gdp = ext4_get_group_desc(sb, block_group, &bh2); | 249 | gdp = ext4_get_group_desc(sb, block_group, &bh2); |
| 255 | 250 | ||
| @@ -268,7 +263,7 @@ void ext4_free_inode(handle_t *handle, struct inode *inode) | |||
| 268 | ext4_group_t f; | 263 | ext4_group_t f; |
| 269 | 264 | ||
| 270 | f = ext4_flex_group(sbi, block_group); | 265 | f = ext4_flex_group(sbi, block_group); |
| 271 | atomic_dec(&sbi->s_flex_groups[f].free_inodes); | 266 | atomic_dec(&sbi->s_flex_groups[f].used_dirs); |
| 272 | } | 267 | } |
| 273 | 268 | ||
| 274 | } | 269 | } |
| @@ -736,8 +731,7 @@ static int ext4_claim_inode(struct super_block *sb, | |||
| 736 | if ((group == 0 && ino < EXT4_FIRST_INO(sb)) || | 731 | if ((group == 0 && ino < EXT4_FIRST_INO(sb)) || |
| 737 | ino > EXT4_INODES_PER_GROUP(sb)) { | 732 | ino > EXT4_INODES_PER_GROUP(sb)) { |
| 738 | ext4_unlock_group(sb, group); | 733 | ext4_unlock_group(sb, group); |
| 739 | ext4_error(sb, __func__, | 734 | ext4_error(sb, "reserved inode or inode > inodes count - " |
| 740 | "reserved inode or inode > inodes count - " | ||
| 741 | "block_group = %u, inode=%lu", group, | 735 | "block_group = %u, inode=%lu", group, |
| 742 | ino + group * EXT4_INODES_PER_GROUP(sb)); | 736 | ino + group * EXT4_INODES_PER_GROUP(sb)); |
| 743 | return 1; | 737 | return 1; |
| @@ -779,7 +773,7 @@ static int ext4_claim_inode(struct super_block *sb, | |||
| 779 | if (sbi->s_log_groups_per_flex) { | 773 | if (sbi->s_log_groups_per_flex) { |
| 780 | ext4_group_t f = ext4_flex_group(sbi, group); | 774 | ext4_group_t f = ext4_flex_group(sbi, group); |
| 781 | 775 | ||
| 782 | atomic_inc(&sbi->s_flex_groups[f].free_inodes); | 776 | atomic_inc(&sbi->s_flex_groups[f].used_dirs); |
| 783 | } | 777 | } |
| 784 | } | 778 | } |
| 785 | gdp->bg_checksum = ext4_group_desc_csum(sbi, group, gdp); | 779 | gdp->bg_checksum = ext4_group_desc_csum(sbi, group, gdp); |
| @@ -904,7 +898,7 @@ repeat_in_this_group: | |||
| 904 | BUFFER_TRACE(inode_bitmap_bh, | 898 | BUFFER_TRACE(inode_bitmap_bh, |
| 905 | "call ext4_handle_dirty_metadata"); | 899 | "call ext4_handle_dirty_metadata"); |
| 906 | err = ext4_handle_dirty_metadata(handle, | 900 | err = ext4_handle_dirty_metadata(handle, |
| 907 | inode, | 901 | NULL, |
| 908 | inode_bitmap_bh); | 902 | inode_bitmap_bh); |
| 909 | if (err) | 903 | if (err) |
| 910 | goto fail; | 904 | goto fail; |
| @@ -1029,15 +1023,16 @@ got: | |||
| 1029 | inode->i_generation = sbi->s_next_generation++; | 1023 | inode->i_generation = sbi->s_next_generation++; |
| 1030 | spin_unlock(&sbi->s_next_gen_lock); | 1024 | spin_unlock(&sbi->s_next_gen_lock); |
| 1031 | 1025 | ||
| 1032 | ei->i_state = EXT4_STATE_NEW; | 1026 | ei->i_state_flags = 0; |
| 1027 | ext4_set_inode_state(inode, EXT4_STATE_NEW); | ||
| 1033 | 1028 | ||
| 1034 | ei->i_extra_isize = EXT4_SB(sb)->s_want_extra_isize; | 1029 | ei->i_extra_isize = EXT4_SB(sb)->s_want_extra_isize; |
| 1035 | 1030 | ||
| 1036 | ret = inode; | 1031 | ret = inode; |
| 1037 | if (vfs_dq_alloc_inode(inode)) { | 1032 | dquot_initialize(inode); |
| 1038 | err = -EDQUOT; | 1033 | err = dquot_alloc_inode(inode); |
| 1034 | if (err) | ||
| 1039 | goto fail_drop; | 1035 | goto fail_drop; |
| 1040 | } | ||
| 1041 | 1036 | ||
| 1042 | err = ext4_init_acl(handle, inode, dir); | 1037 | err = ext4_init_acl(handle, inode, dir); |
| 1043 | if (err) | 1038 | if (err) |
| @@ -1074,10 +1069,10 @@ really_out: | |||
| 1074 | return ret; | 1069 | return ret; |
| 1075 | 1070 | ||
| 1076 | fail_free_drop: | 1071 | fail_free_drop: |
| 1077 | vfs_dq_free_inode(inode); | 1072 | dquot_free_inode(inode); |
| 1078 | 1073 | ||
| 1079 | fail_drop: | 1074 | fail_drop: |
| 1080 | vfs_dq_drop(inode); | 1075 | dquot_drop(inode); |
| 1081 | inode->i_flags |= S_NOQUOTA; | 1076 | inode->i_flags |= S_NOQUOTA; |
| 1082 | inode->i_nlink = 0; | 1077 | inode->i_nlink = 0; |
| 1083 | unlock_new_inode(inode); | 1078 | unlock_new_inode(inode); |
| @@ -1098,8 +1093,7 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino) | |||
| 1098 | 1093 | ||
| 1099 | /* Error cases - e2fsck has already cleaned up for us */ | 1094 | /* Error cases - e2fsck has already cleaned up for us */ |
| 1100 | if (ino > max_ino) { | 1095 | if (ino > max_ino) { |
| 1101 | ext4_warning(sb, __func__, | 1096 | ext4_warning(sb, "bad orphan ino %lu! e2fsck was run?", ino); |
| 1102 | "bad orphan ino %lu! e2fsck was run?", ino); | ||
| 1103 | goto error; | 1097 | goto error; |
| 1104 | } | 1098 | } |
| 1105 | 1099 | ||
| @@ -1107,8 +1101,7 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino) | |||
| 1107 | bit = (ino - 1) % EXT4_INODES_PER_GROUP(sb); | 1101 | bit = (ino - 1) % EXT4_INODES_PER_GROUP(sb); |
| 1108 | bitmap_bh = ext4_read_inode_bitmap(sb, block_group); | 1102 | bitmap_bh = ext4_read_inode_bitmap(sb, block_group); |
| 1109 | if (!bitmap_bh) { | 1103 | if (!bitmap_bh) { |
| 1110 | ext4_warning(sb, __func__, | 1104 | ext4_warning(sb, "inode bitmap error for orphan %lu", ino); |
| 1111 | "inode bitmap error for orphan %lu", ino); | ||
| 1112 | goto error; | 1105 | goto error; |
| 1113 | } | 1106 | } |
| 1114 | 1107 | ||
| @@ -1140,8 +1133,7 @@ iget_failed: | |||
| 1140 | err = PTR_ERR(inode); | 1133 | err = PTR_ERR(inode); |
| 1141 | inode = NULL; | 1134 | inode = NULL; |
| 1142 | bad_orphan: | 1135 | bad_orphan: |
| 1143 | ext4_warning(sb, __func__, | 1136 | ext4_warning(sb, "bad orphan inode %lu! e2fsck was run?", ino); |
| 1144 | "bad orphan inode %lu! e2fsck was run?", ino); | ||
| 1145 | printk(KERN_NOTICE "ext4_test_bit(bit=%d, block=%llu) = %d\n", | 1137 | printk(KERN_NOTICE "ext4_test_bit(bit=%d, block=%llu) = %d\n", |
| 1146 | bit, (unsigned long long)bitmap_bh->b_blocknr, | 1138 | bit, (unsigned long long)bitmap_bh->b_blocknr, |
| 1147 | ext4_test_bit(bit, bitmap_bh->b_data)); | 1139 | ext4_test_bit(bit, bitmap_bh->b_data)); |
