• Home
  • Raw
  • Download

Lines Matching +full:- +full:fs

2  * alloc.c --- allocate new inodes, blocks for ext2fs
6 * %Begin-Header%
9 * %End-Header%
42 void ext2fs_clear_block_uninit(ext2_filsys fs, dgrp_t group) in ext2fs_clear_block_uninit() argument
44 if (group >= fs->group_desc_count || in ext2fs_clear_block_uninit()
45 !ext2fs_has_group_desc_csum(fs) || in ext2fs_clear_block_uninit()
46 !(ext2fs_bg_flags_test(fs, group, EXT2_BG_BLOCK_UNINIT))) in ext2fs_clear_block_uninit()
51 ext2fs_bg_flags_clear(fs, group, EXT2_BG_BLOCK_UNINIT); in ext2fs_clear_block_uninit()
52 ext2fs_group_desc_csum_set(fs, group); in ext2fs_clear_block_uninit()
53 ext2fs_mark_super_dirty(fs); in ext2fs_clear_block_uninit()
54 ext2fs_mark_bb_dirty(fs); in ext2fs_clear_block_uninit()
60 static void check_inode_uninit(ext2_filsys fs, ext2fs_inode_bitmap map, in check_inode_uninit() argument
65 if (group >= fs->group_desc_count || in check_inode_uninit()
66 !ext2fs_has_group_desc_csum(fs) || in check_inode_uninit()
67 !(ext2fs_bg_flags_test(fs, group, EXT2_BG_INODE_UNINIT))) in check_inode_uninit()
70 ino = (group * fs->super->s_inodes_per_group) + 1; in check_inode_uninit()
71 for (i=0; i < fs->super->s_inodes_per_group; i++, ino++) in check_inode_uninit()
74 ext2fs_bg_flags_clear(fs, group, EXT2_BG_INODE_UNINIT); in check_inode_uninit()
76 ext2fs_bg_flags_clear(fs, group, EXT2_BG_BLOCK_UNINIT); in check_inode_uninit()
77 ext2fs_group_desc_csum_set(fs, group); in check_inode_uninit()
78 ext2fs_mark_ib_dirty(fs); in check_inode_uninit()
79 ext2fs_mark_super_dirty(fs); in check_inode_uninit()
88 errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir, in ext2fs_new_inode() argument
97 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); in ext2fs_new_inode()
100 map = fs->inode_map; in ext2fs_new_inode()
105 group = (dir - 1) / EXT2_INODES_PER_GROUP(fs->super); in ext2fs_new_inode()
106 start_inode = (group * EXT2_INODES_PER_GROUP(fs->super)) + 1; in ext2fs_new_inode()
108 if (start_inode < EXT2_FIRST_INODE(fs->super)) in ext2fs_new_inode()
109 start_inode = EXT2_FIRST_INODE(fs->super); in ext2fs_new_inode()
110 if (start_inode > fs->super->s_inodes_count) in ext2fs_new_inode()
114 ino_in_group = (i - 1) % EXT2_INODES_PER_GROUP(fs->super); in ext2fs_new_inode()
115 group = (i - 1) / EXT2_INODES_PER_GROUP(fs->super); in ext2fs_new_inode()
117 check_inode_uninit(fs, map, group); in ext2fs_new_inode()
118 upto = i + (EXT2_INODES_PER_GROUP(fs->super) - ino_in_group); in ext2fs_new_inode()
120 upto = start_inode - 1; in ext2fs_new_inode()
121 if (upto > fs->super->s_inodes_count) in ext2fs_new_inode()
122 upto = fs->super->s_inodes_count; in ext2fs_new_inode()
133 if (i > fs->super->s_inodes_count) in ext2fs_new_inode()
134 i = EXT2_FIRST_INODE(fs->super); in ext2fs_new_inode()
144 * Stupid algorithm --- we now just search forward starting from the
147 errcode_t ext2fs_new_block3(ext2_filsys fs, blk64_t goal, in ext2fs_new_block3() argument
153 errcode_t (*gab)(ext2_filsys fs, blk64_t goal, blk64_t *ret); in ext2fs_new_block3()
157 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); in ext2fs_new_block3()
166 if (fs->get_alloc_block2) { in ext2fs_new_block3()
167 gab2 = fs->get_alloc_block2; in ext2fs_new_block3()
168 fs->get_alloc_block2 = NULL; in ext2fs_new_block3()
169 retval = gab2(fs, goal, &b, ctx); in ext2fs_new_block3()
170 fs->get_alloc_block2 = gab2; in ext2fs_new_block3()
172 } else if (fs->get_alloc_block) { in ext2fs_new_block3()
173 gab = fs->get_alloc_block; in ext2fs_new_block3()
174 fs->get_alloc_block = NULL; in ext2fs_new_block3()
175 retval = gab(fs, goal, &b); in ext2fs_new_block3()
176 fs->get_alloc_block = gab; in ext2fs_new_block3()
181 map = fs->block_map; in ext2fs_new_block3()
184 if (!goal || (goal >= ext2fs_blocks_count(fs->super))) in ext2fs_new_block3()
185 goal = fs->super->s_first_data_block; in ext2fs_new_block3()
186 goal &= ~EXT2FS_CLUSTER_MASK(fs); in ext2fs_new_block3()
189 goal, ext2fs_blocks_count(fs->super) - 1, &b); in ext2fs_new_block3()
190 if ((retval == ENOENT) && (goal != fs->super->s_first_data_block)) in ext2fs_new_block3()
192 fs->super->s_first_data_block, goal - 1, &b); in ext2fs_new_block3()
199 ext2fs_clear_block_uninit(fs, ext2fs_group_of_blk2(fs, b)); in ext2fs_new_block3()
204 errcode_t ext2fs_new_block2(ext2_filsys fs, blk64_t goal, in ext2fs_new_block2() argument
207 return ext2fs_new_block3(fs, goal, map, ret, NULL); in ext2fs_new_block2()
210 errcode_t ext2fs_new_block(ext2_filsys fs, blk_t goal, in ext2fs_new_block() argument
215 retval = ext2fs_new_block2(fs, goal, map, &val); in ext2fs_new_block()
225 errcode_t ext2fs_alloc_block3(ext2_filsys fs, blk64_t goal, char *block_buf, in ext2fs_alloc_block3() argument
231 if (fs->get_alloc_block2) { in ext2fs_alloc_block3()
232 retval = (fs->get_alloc_block2)(fs, goal, &block, ctx); in ext2fs_alloc_block3()
235 } else if (fs->get_alloc_block) { in ext2fs_alloc_block3()
236 retval = (fs->get_alloc_block)(fs, goal, &block); in ext2fs_alloc_block3()
240 if (!fs->block_map) { in ext2fs_alloc_block3()
241 retval = ext2fs_read_block_bitmap(fs); in ext2fs_alloc_block3()
246 retval = ext2fs_new_block3(fs, goal, 0, &block, ctx); in ext2fs_alloc_block3()
252 memset(block_buf, 0, fs->blocksize); in ext2fs_alloc_block3()
253 retval = io_channel_write_blk64(fs->io, block, 1, block_buf); in ext2fs_alloc_block3()
255 retval = ext2fs_zero_blocks2(fs, block, 1, NULL, NULL); in ext2fs_alloc_block3()
259 ext2fs_block_alloc_stats2(fs, block, +1); in ext2fs_alloc_block3()
266 errcode_t ext2fs_alloc_block2(ext2_filsys fs, blk64_t goal, in ext2fs_alloc_block2() argument
269 return ext2fs_alloc_block3(fs, goal, block_buf, ret, NULL); in ext2fs_alloc_block2()
272 errcode_t ext2fs_alloc_block(ext2_filsys fs, blk_t goal, in ext2fs_alloc_block() argument
277 retval = ext2fs_alloc_block3(fs, goal64, block_buf, &ret64, NULL); in ext2fs_alloc_block()
283 errcode_t ext2fs_get_free_blocks2(ext2_filsys fs, blk64_t start, blk64_t finish, in ext2fs_get_free_blocks2() argument
289 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); in ext2fs_get_free_blocks2()
292 map = fs->block_map; in ext2fs_get_free_blocks2()
296 b = fs->super->s_first_data_block; in ext2fs_get_free_blocks2()
302 b &= ~(c_ratio - 1); in ext2fs_get_free_blocks2()
303 finish &= ~(c_ratio -1); in ext2fs_get_free_blocks2()
305 if (b + num - 1 >= ext2fs_blocks_count(fs->super)) { in ext2fs_get_free_blocks2()
308 b = fs->super->s_first_data_block; in ext2fs_get_free_blocks2()
319 errcode_t ext2fs_get_free_blocks(ext2_filsys fs, blk_t start, blk_t finish, in ext2fs_get_free_blocks() argument
324 retval = ext2fs_get_free_blocks2(fs, start, finish, num, map, &val); in ext2fs_get_free_blocks()
330 void ext2fs_set_alloc_block_callback(ext2_filsys fs, in ext2fs_set_alloc_block_callback() argument
331 errcode_t (*func)(ext2_filsys fs, in ext2fs_set_alloc_block_callback() argument
334 errcode_t (**old)(ext2_filsys fs, in ext2fs_set_alloc_block_callback() argument
338 if (!fs || fs->magic != EXT2_ET_MAGIC_EXT2FS_FILSYS) in ext2fs_set_alloc_block_callback()
342 *old = fs->get_alloc_block; in ext2fs_set_alloc_block_callback()
344 fs->get_alloc_block = func; in ext2fs_set_alloc_block_callback()
347 blk64_t ext2fs_find_inode_goal(ext2_filsys fs, ext2_ino_t ino, in ext2fs_find_inode_goal() argument
356 /* Make sure data stored in inode->i_block is neither fast symlink nor in ext2fs_find_inode_goal()
360 inode->i_flags & EXT4_INLINE_DATA_FL) in ext2fs_find_inode_goal()
363 if (inode->i_flags & EXT4_EXTENTS_FL) { in ext2fs_find_inode_goal()
364 err = ext2fs_extent_open2(fs, ino, inode, &handle); in ext2fs_find_inode_goal()
374 return extent.e_pblk + (lblk - extent.e_lblk); in ext2fs_find_inode_goal()
378 if (inode->i_block[0]) in ext2fs_find_inode_goal()
379 return inode->i_block[0]; in ext2fs_find_inode_goal()
383 log_flex = fs->super->s_log_groups_per_flex; in ext2fs_find_inode_goal()
384 group = ext2fs_group_of_ino(fs, ino); in ext2fs_find_inode_goal()
386 group = group & ~((1 << (log_flex)) - 1); in ext2fs_find_inode_goal()
387 return ext2fs_group_first_block2(fs, group); in ext2fs_find_inode_goal()
393 * - EXT2_NEWRANGE_EXACT_GOAL: The range of blocks must start at _goal_.
394 * - EXT2_NEWRANGE_MIN_LENGTH: do not return a allocation shorter than _len_.
395 * - EXT2_NEWRANGE_ZERO_BLOCKS: Zero blocks pblk to pblk+plen before returning.
404 errcode_t ext2fs_new_range(ext2_filsys fs, int flags, blk64_t goal, in ext2fs_new_range() argument
411 blk64_t max_blocks = ext2fs_blocks_count(fs->super); in ext2fs_new_range()
412 errcode_t (*nrf)(ext2_filsys fs, int flags, blk64_t goal, in ext2fs_new_range()
417 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); in ext2fs_new_range()
421 if (!map && fs->new_range) { in ext2fs_new_range()
428 nrf = fs->new_range; in ext2fs_new_range()
429 fs->new_range = NULL; in ext2fs_new_range()
430 retval = nrf(fs, flags, goal, len, pblk, plen); in ext2fs_new_range()
431 fs->new_range = nrf; in ext2fs_new_range()
439 map = fs->block_map; in ext2fs_new_range()
442 if (!goal || goal >= ext2fs_blocks_count(fs->super)) in ext2fs_new_range()
443 goal = fs->super->s_first_data_block; in ext2fs_new_range()
448 max_blocks - 1, in ext2fs_new_range()
458 start == fs->super->s_first_data_block) in ext2fs_new_range()
460 start = fs->super->s_first_data_block; in ext2fs_new_range()
468 b = min(start + len - 1, max_blocks - 1); in ext2fs_new_range()
477 (end - start) >= len) { in ext2fs_new_range()
480 *plen = end - start; in ext2fs_new_range()
481 dbg_printf("%s: new_range goal=%llu--%llu " in ext2fs_new_range()
482 "blk=%llu--%llu %llu\n", in ext2fs_new_range()
483 __func__, goal, goal + len - 1, in ext2fs_new_range()
484 *pblk, *pblk + *plen - 1, *plen); in ext2fs_new_range()
487 b += fs->super->s_blocks_per_group) in ext2fs_new_range()
488 ext2fs_clear_block_uninit(fs, in ext2fs_new_range()
489 ext2fs_group_of_blk2(fs, b)); in ext2fs_new_range()
500 start = fs->super->s_first_data_block; in ext2fs_new_range()
510 void ext2fs_set_new_range_callback(ext2_filsys fs, in ext2fs_set_new_range_callback() argument
511 errcode_t (*func)(ext2_filsys fs, int flags, blk64_t goal, in ext2fs_set_new_range_callback() argument
513 errcode_t (**old)(ext2_filsys fs, int flags, blk64_t goal, in ext2fs_set_new_range_callback() argument
516 if (!fs || fs->magic != EXT2_ET_MAGIC_EXT2FS_FILSYS) in ext2fs_set_new_range_callback()
520 *old = fs->new_range; in ext2fs_set_new_range_callback()
522 fs->new_range = func; in ext2fs_set_new_range_callback()
525 errcode_t ext2fs_alloc_range(ext2_filsys fs, int flags, blk64_t goal, in ext2fs_alloc_range() argument
532 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); in ext2fs_alloc_range()
539 retval = ext2fs_new_range(fs, newr_flags, goal, len, NULL, ret, &plen); in ext2fs_alloc_range()
547 retval = ext2fs_zero_blocks2(fs, *ret, len, NULL, NULL); in ext2fs_alloc_range()
552 ext2fs_block_alloc_stats_range(fs, *ret, len, +1); in ext2fs_alloc_range()