Lines Matching refs:fs
38 static blk64_t flexbg_offset(ext2_filsys fs, dgrp_t group, blk64_t start_blk, in flexbg_offset() argument
46 flexbg_size = 1 << fs->super->s_log_groups_per_flex; in flexbg_offset()
50 if (size > (int) (fs->super->s_blocks_per_group / 4)) in flexbg_offset()
51 size = (int) fs->super->s_blocks_per_group / 4; in flexbg_offset()
57 if (start_blk && start_blk < ext2fs_blocks_count(fs->super) && in flexbg_offset()
58 ext2fs_get_free_blocks2(fs, start_blk, start_blk + size, elem_size, in flexbg_offset()
62 start_blk = ext2fs_group_first_block2(fs, flexbg_size * flexbg); in flexbg_offset()
64 if (last_grp > fs->group_desc_count-1) in flexbg_offset()
65 last_grp = fs->group_desc_count-1; in flexbg_offset()
66 last_blk = ext2fs_group_last_block2(fs, last_grp); in flexbg_offset()
69 if (ext2fs_get_free_blocks2(fs, start_blk, last_blk, size, in flexbg_offset()
73 if (ext2fs_get_free_blocks2(fs, start_blk, last_blk, elem_size, in flexbg_offset()
77 if (ext2fs_get_free_blocks2(fs, 0, last_blk, elem_size, bmap, in flexbg_offset()
84 errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group, in ext2fs_allocate_group_table() argument
92 group_blk = ext2fs_group_first_block2(fs, group); in ext2fs_allocate_group_table()
93 last_blk = ext2fs_group_last_block2(fs, group); in ext2fs_allocate_group_table()
96 bmap = fs->block_map; in ext2fs_allocate_group_table()
98 if (ext2fs_has_feature_flex_bg(fs->super) && in ext2fs_allocate_group_table()
99 fs->super->s_log_groups_per_flex) { in ext2fs_allocate_group_table()
100 flexbg_size = 1 << fs->super->s_log_groups_per_flex; in ext2fs_allocate_group_table()
102 if (last_grp > fs->group_desc_count-1) in ext2fs_allocate_group_table()
103 last_grp = fs->group_desc_count-1; in ext2fs_allocate_group_table()
110 if (fs->stride && !flexbg_size) { in ext2fs_allocate_group_table()
111 retval = ext2fs_get_free_blocks2(fs, group_blk, last_blk, in ext2fs_allocate_group_table()
115 start_blk += fs->inode_blocks_per_group; in ext2fs_allocate_group_table()
116 start_blk += ((fs->stride * group) % in ext2fs_allocate_group_table()
128 prev_block = ext2fs_block_bitmap_loc(fs, group - 1) + 1; in ext2fs_allocate_group_table()
129 else if (last_grp == fs->group_desc_count-1) { in ext2fs_allocate_group_table()
142 start_blk = flexbg_offset(fs, group, prev_block, bmap, in ext2fs_allocate_group_table()
144 last_blk = ext2fs_group_last_block2(fs, last_grp); in ext2fs_allocate_group_table()
147 if (!ext2fs_block_bitmap_loc(fs, group)) { in ext2fs_allocate_group_table()
148 retval = ext2fs_get_free_blocks2(fs, start_blk, last_blk, in ext2fs_allocate_group_table()
151 retval = ext2fs_get_free_blocks2(fs, group_blk, in ext2fs_allocate_group_table()
156 ext2fs_block_bitmap_loc_set(fs, group, new_blk); in ext2fs_allocate_group_table()
158 dgrp_t gr = ext2fs_group_of_blk2(fs, new_blk); in ext2fs_allocate_group_table()
159 ext2fs_bg_free_blocks_count_set(fs, gr, ext2fs_bg_free_blocks_count(fs, gr) - 1); in ext2fs_allocate_group_table()
160 ext2fs_free_blocks_count_add(fs->super, -1); in ext2fs_allocate_group_table()
161 ext2fs_bg_flags_clear(fs, gr, EXT2_BG_BLOCK_UNINIT); in ext2fs_allocate_group_table()
162 ext2fs_group_desc_csum_set(fs, gr); in ext2fs_allocate_group_table()
169 prev_block = ext2fs_inode_bitmap_loc(fs, group - 1) + 1; in ext2fs_allocate_group_table()
171 prev_block = ext2fs_block_bitmap_loc(fs, group) + in ext2fs_allocate_group_table()
175 start_blk = flexbg_offset(fs, group, prev_block, bmap, in ext2fs_allocate_group_table()
177 last_blk = ext2fs_group_last_block2(fs, last_grp); in ext2fs_allocate_group_table()
180 if (!ext2fs_inode_bitmap_loc(fs, group)) { in ext2fs_allocate_group_table()
181 retval = ext2fs_get_free_blocks2(fs, start_blk, last_blk, in ext2fs_allocate_group_table()
184 retval = ext2fs_get_free_blocks2(fs, group_blk, in ext2fs_allocate_group_table()
189 ext2fs_inode_bitmap_loc_set(fs, group, new_blk); in ext2fs_allocate_group_table()
191 dgrp_t gr = ext2fs_group_of_blk2(fs, new_blk); in ext2fs_allocate_group_table()
192 ext2fs_bg_free_blocks_count_set(fs, gr, ext2fs_bg_free_blocks_count(fs, gr) - 1); in ext2fs_allocate_group_table()
193 ext2fs_free_blocks_count_add(fs->super, -1); in ext2fs_allocate_group_table()
194 ext2fs_bg_flags_clear(fs, gr, EXT2_BG_BLOCK_UNINIT); in ext2fs_allocate_group_table()
195 ext2fs_group_desc_csum_set(fs, gr); in ext2fs_allocate_group_table()
206 prev_block = ext2fs_inode_table_loc(fs, group - 1) + in ext2fs_allocate_group_table()
207 fs->inode_blocks_per_group; in ext2fs_allocate_group_table()
209 prev_block = ext2fs_inode_bitmap_loc(fs, group) + in ext2fs_allocate_group_table()
214 group_blk = flexbg_offset(fs, group, prev_block, bmap, in ext2fs_allocate_group_table()
215 rem_grps, fs->inode_blocks_per_group); in ext2fs_allocate_group_table()
216 last_blk = ext2fs_group_last_block2(fs, last_grp); in ext2fs_allocate_group_table()
219 if (!ext2fs_inode_table_loc(fs, group)) { in ext2fs_allocate_group_table()
220 retval = ext2fs_get_free_blocks2(fs, group_blk, last_blk, in ext2fs_allocate_group_table()
221 fs->inode_blocks_per_group, in ext2fs_allocate_group_table()
227 new_blk, fs->inode_blocks_per_group); in ext2fs_allocate_group_table()
230 num = fs->inode_blocks_per_group; in ext2fs_allocate_group_table()
233 int gr = ext2fs_group_of_blk2(fs, blk); in ext2fs_allocate_group_table()
234 last_blk = ext2fs_group_last_block2(fs, gr); in ext2fs_allocate_group_table()
240 ext2fs_bg_free_blocks_count_set(fs, gr, in ext2fs_allocate_group_table()
241 ext2fs_bg_free_blocks_count(fs, gr) - in ext2fs_allocate_group_table()
242 n/EXT2FS_CLUSTER_RATIO(fs)); in ext2fs_allocate_group_table()
243 ext2fs_bg_flags_clear(fs, gr, in ext2fs_allocate_group_table()
245 ext2fs_group_desc_csum_set(fs, gr); in ext2fs_allocate_group_table()
246 ext2fs_free_blocks_count_add(fs->super, -n); in ext2fs_allocate_group_table()
251 ext2fs_inode_table_loc_set(fs, group, new_blk); in ext2fs_allocate_group_table()
253 ext2fs_group_desc_csum_set(fs, group); in ext2fs_allocate_group_table()
257 errcode_t ext2fs_allocate_tables(ext2_filsys fs) in ext2fs_allocate_tables() argument
263 if (fs->progress_ops && fs->progress_ops->init) in ext2fs_allocate_tables()
264 (fs->progress_ops->init)(fs, &progress, NULL, in ext2fs_allocate_tables()
265 fs->group_desc_count); in ext2fs_allocate_tables()
267 for (i = 0; i < fs->group_desc_count; i++) { in ext2fs_allocate_tables()
268 if (fs->progress_ops && fs->progress_ops->update) in ext2fs_allocate_tables()
269 (fs->progress_ops->update)(fs, &progress, i); in ext2fs_allocate_tables()
270 retval = ext2fs_allocate_group_table(fs, i, fs->block_map); in ext2fs_allocate_tables()
274 if (fs->progress_ops && fs->progress_ops->close) in ext2fs_allocate_tables()
275 (fs->progress_ops->close)(fs, &progress, NULL); in ext2fs_allocate_tables()