Changeset 24df0de6 in mainline
- Timestamp:
- 2015-04-26T21:46:56Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b9f2ba8
- Parents:
- 5cc1853
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_balloc.c
r5cc1853 r24df0de6 291 291 *goal = 0; 292 292 ext4_superblock_t *sb = inode_ref->fs->superblock; 293 293 294 294 uint64_t inode_size = ext4_inode_get_size(sb, inode_ref->inode); 295 295 uint32_t block_size = ext4_superblock_get_block_size(sb); 296 296 uint32_t inode_block_count = inode_size / block_size; 297 297 298 298 if (inode_size % block_size != 0) 299 299 inode_block_count++; 300 300 301 301 /* If inode has some blocks, get last block address + 1 */ 302 302 if (inode_block_count > 0) { … … 305 305 if (rc != EOK) 306 306 return rc; 307 307 308 308 if (goal != 0) { 309 309 (*goal)++; 310 310 return EOK; 311 311 } 312 313 312 /* If goal == 0, sparse file -> continue */ 314 313 } 315 314 316 315 /* Identify block group of inode */ 317 316 uint32_t inodes_per_group = ext4_superblock_get_inodes_per_group(sb); 318 317 uint32_t block_group = (inode_ref->index - 1) / inodes_per_group; 319 block_size = ext4_superblock_get_block_size(sb); 320 318 321 319 /* Load block group reference */ 322 320 ext4_block_group_ref_t *bg_ref; … … 325 323 if (rc != EOK) 326 324 return rc; 327 328 /* Compute indexes */ 329 uint32_t block_group_count = ext4_superblock_get_block_group_count(sb); 330 uint32_t inode_table_first_block = 331 ext4_block_group_get_inode_table_first_block(bg_ref->block_group, sb); 332 uint16_t inode_table_item_size = ext4_superblock_get_inode_size(sb); 333 uint32_t inode_table_bytes; 334 335 /* Check for last block group */ 336 if (block_group < block_group_count - 1) { 337 inode_table_bytes = inodes_per_group * inode_table_item_size; 338 } else { 339 /* Last block group could be smaller */ 340 uint32_t inodes_count_total = ext4_superblock_get_inodes_count(sb); 341 inode_table_bytes = 342 (inodes_count_total - ((block_group_count - 1) * inodes_per_group)) * 343 inode_table_item_size; 344 } 345 346 uint32_t inode_table_blocks = inode_table_bytes / block_size; 347 348 if (inode_table_bytes % block_size) 349 inode_table_blocks++; 350 351 *goal = inode_table_first_block + inode_table_blocks; 352 325 326 *goal = ext4_balloc_get_first_data_block_in_group(sb, bg_ref); 327 353 328 return ext4_filesystem_put_block_group_ref(bg_ref); 354 329 }
Note:
See TracChangeset
for help on using the changeset viewer.