diff options
Diffstat (limited to 'fs/ext4/ialloc.c')
-rw-r--r-- | fs/ext4/ialloc.c | 64 |
1 files changed, 26 insertions, 38 deletions
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index f3624ead4f6c..1a0e183a2f04 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; |
@@ -985,16 +979,12 @@ got: | |||
985 | atomic_dec(&sbi->s_flex_groups[flex_group].free_inodes); | 979 | atomic_dec(&sbi->s_flex_groups[flex_group].free_inodes); |
986 | } | 980 | } |
987 | 981 | ||
988 | inode->i_uid = current_fsuid(); | 982 | if (test_opt(sb, GRPID)) { |
989 | if (test_opt(sb, GRPID)) | 983 | inode->i_mode = mode; |
984 | inode->i_uid = current_fsuid(); | ||
990 | inode->i_gid = dir->i_gid; | 985 | inode->i_gid = dir->i_gid; |
991 | else if (dir->i_mode & S_ISGID) { | ||
992 | inode->i_gid = dir->i_gid; | ||
993 | if (S_ISDIR(mode)) | ||
994 | mode |= S_ISGID; | ||
995 | } else | 986 | } else |
996 | inode->i_gid = current_fsgid(); | 987 | inode_init_owner(inode, dir, mode); |
997 | inode->i_mode = mode; | ||
998 | 988 | ||
999 | inode->i_ino = ino + group * EXT4_INODES_PER_GROUP(sb); | 989 | inode->i_ino = ino + group * EXT4_INODES_PER_GROUP(sb); |
1000 | /* This is the optimal IO size (for stat), not the fs block size */ | 990 | /* This is the optimal IO size (for stat), not the fs block size */ |
@@ -1029,15 +1019,16 @@ got: | |||
1029 | inode->i_generation = sbi->s_next_generation++; | 1019 | inode->i_generation = sbi->s_next_generation++; |
1030 | spin_unlock(&sbi->s_next_gen_lock); | 1020 | spin_unlock(&sbi->s_next_gen_lock); |
1031 | 1021 | ||
1032 | ei->i_state = EXT4_STATE_NEW; | 1022 | ei->i_state_flags = 0; |
1023 | ext4_set_inode_state(inode, EXT4_STATE_NEW); | ||
1033 | 1024 | ||
1034 | ei->i_extra_isize = EXT4_SB(sb)->s_want_extra_isize; | 1025 | ei->i_extra_isize = EXT4_SB(sb)->s_want_extra_isize; |
1035 | 1026 | ||
1036 | ret = inode; | 1027 | ret = inode; |
1037 | if (vfs_dq_alloc_inode(inode)) { | 1028 | dquot_initialize(inode); |
1038 | err = -EDQUOT; | 1029 | err = dquot_alloc_inode(inode); |
1030 | if (err) | ||
1039 | goto fail_drop; | 1031 | goto fail_drop; |
1040 | } | ||
1041 | 1032 | ||
1042 | err = ext4_init_acl(handle, inode, dir); | 1033 | err = ext4_init_acl(handle, inode, dir); |
1043 | if (err) | 1034 | if (err) |
@@ -1074,10 +1065,10 @@ really_out: | |||
1074 | return ret; | 1065 | return ret; |
1075 | 1066 | ||
1076 | fail_free_drop: | 1067 | fail_free_drop: |
1077 | vfs_dq_free_inode(inode); | 1068 | dquot_free_inode(inode); |
1078 | 1069 | ||
1079 | fail_drop: | 1070 | fail_drop: |
1080 | vfs_dq_drop(inode); | 1071 | dquot_drop(inode); |
1081 | inode->i_flags |= S_NOQUOTA; | 1072 | inode->i_flags |= S_NOQUOTA; |
1082 | inode->i_nlink = 0; | 1073 | inode->i_nlink = 0; |
1083 | unlock_new_inode(inode); | 1074 | unlock_new_inode(inode); |
@@ -1098,8 +1089,7 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino) | |||
1098 | 1089 | ||
1099 | /* Error cases - e2fsck has already cleaned up for us */ | 1090 | /* Error cases - e2fsck has already cleaned up for us */ |
1100 | if (ino > max_ino) { | 1091 | if (ino > max_ino) { |
1101 | ext4_warning(sb, __func__, | 1092 | ext4_warning(sb, "bad orphan ino %lu! e2fsck was run?", ino); |
1102 | "bad orphan ino %lu! e2fsck was run?", ino); | ||
1103 | goto error; | 1093 | goto error; |
1104 | } | 1094 | } |
1105 | 1095 | ||
@@ -1107,8 +1097,7 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino) | |||
1107 | bit = (ino - 1) % EXT4_INODES_PER_GROUP(sb); | 1097 | bit = (ino - 1) % EXT4_INODES_PER_GROUP(sb); |
1108 | bitmap_bh = ext4_read_inode_bitmap(sb, block_group); | 1098 | bitmap_bh = ext4_read_inode_bitmap(sb, block_group); |
1109 | if (!bitmap_bh) { | 1099 | if (!bitmap_bh) { |
1110 | ext4_warning(sb, __func__, | 1100 | ext4_warning(sb, "inode bitmap error for orphan %lu", ino); |
1111 | "inode bitmap error for orphan %lu", ino); | ||
1112 | goto error; | 1101 | goto error; |
1113 | } | 1102 | } |
1114 | 1103 | ||
@@ -1140,8 +1129,7 @@ iget_failed: | |||
1140 | err = PTR_ERR(inode); | 1129 | err = PTR_ERR(inode); |
1141 | inode = NULL; | 1130 | inode = NULL; |
1142 | bad_orphan: | 1131 | bad_orphan: |
1143 | ext4_warning(sb, __func__, | 1132 | 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", | 1133 | printk(KERN_NOTICE "ext4_test_bit(bit=%d, block=%llu) = %d\n", |
1146 | bit, (unsigned long long)bitmap_bh->b_blocknr, | 1134 | bit, (unsigned long long)bitmap_bh->b_blocknr, |
1147 | ext4_test_bit(bit, bitmap_bh->b_data)); | 1135 | ext4_test_bit(bit, bitmap_bh->b_data)); |