Changeset 6915335 in mainline
- Timestamp:
- 2018-12-12T18:11:17Z (6 years ago)
- Children:
- ee23f85
- Parents:
- be912f53
- git-author:
- Maurizio Lombardi <mlombard@…> (2018-12-12 17:31:56)
- git-committer:
- Maurizio Lombardi <mlombard@…> (2018-12-12 18:11:17)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/src/ialloc.c
rbe912f53 r6915335 176 176 errno_t ext4_ialloc_alloc_inode(ext4_filesystem_t *fs, uint32_t *index, bool is_dir) 177 177 { 178 int pick_first_free = 0; 178 179 ext4_superblock_t *sb = fs->superblock; 179 180 uint32_t bgid = 0; 181 uint32_t bg_count = ext4_superblock_get_block_group_count(sb); 182 uint32_t sb_free_inodes = ext4_superblock_get_free_inodes_count(sb); 183 uint32_t avg_free_inodes = sb_free_inodes / bg_count; 180 uint32_t bgid; 181 uint32_t sb_free_inodes; 182 uint32_t avg_free_inodes; 183 uint32_t const bg_count = ext4_superblock_get_block_group_count(sb); 184 185 retry: 186 187 bgid = 0; 188 sb_free_inodes = ext4_superblock_get_free_inodes_count(sb); 189 avg_free_inodes = sb_free_inodes / bg_count; 184 190 185 191 /* Try to find free i-node in all block groups */ … … 210 216 * blocks. 211 217 */ 212 if (((free_inodes >= avg_free_inodes) || (bgid == bg_count - 1) ) &&213 (free_blocks > 0)) {218 if (((free_inodes >= avg_free_inodes) || (bgid == bg_count - 1) 219 || pick_first_free) && (free_blocks > 0)) { 214 220 /* Load block with bitmap */ 215 221 uint32_t bitmap_block_addr = ext4_block_group_get_inode_bitmap( … … 307 313 } 308 314 315 /* Try again with less strict conditions */ 316 if (pick_first_free == 0) { 317 pick_first_free = 1; 318 goto retry; 319 } 320 309 321 return ENOSPC; 310 322 }
Note:
See TracChangeset
for help on using the changeset viewer.