Changes in uspace/lib/ext4/libext4_ialloc.c [38542dc:8a45707d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_ialloc.c
r38542dc r8a45707d 195 195 uint32_t used_dirs = ext4_block_group_get_used_dirs_count(bg, sb); 196 196 197 /* Check if this block group is good candidate for allocation */ 198 if ((free_inodes >= avg_free_inodes) && (free_blocks > 0)) { 197 /* 198 * Check if this block group is a good candidate 199 * for allocation. 200 * 201 * The criterion is based on the average number 202 * of free inodes, unless we examine the last block 203 * group. In that case the last block group might 204 * have less than the average number of free inodes, 205 * but it still needs to be taken as a candidate 206 * because the previous block groups have zero free 207 * blocks. 208 */ 209 if (((free_inodes >= avg_free_inodes) || (bgid == bg_count - 1)) && 210 (free_blocks > 0)) { 199 211 /* Load block with bitmap */ 200 212 uint32_t bitmap_block_addr = ext4_block_group_get_inode_bitmap( … … 204 216 rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 205 217 BLOCK_FLAGS_NONE); 206 if (rc != EOK) 218 if (rc != EOK) { 219 ext4_filesystem_put_block_group_ref(bg_ref); 207 220 return rc; 221 } 208 222 209 223 /* Try to allocate i-node in the bitmap */ … … 215 229 /* Block group has not any free i-node */ 216 230 if (rc == ENOSPC) { 217 block_put(bitmap_block); 218 ext4_filesystem_put_block_group_ref(bg_ref); 231 rc = block_put(bitmap_block); 232 if (rc != EOK) { 233 ext4_filesystem_put_block_group_ref(bg_ref); 234 return rc; 235 } 236 237 rc = ext4_filesystem_put_block_group_ref(bg_ref); 238 if (rc != EOK) 239 return rc; 240 241 bgid++; 219 242 continue; 220 243 } … … 224 247 225 248 rc = block_put(bitmap_block); 226 if (rc != EOK) 249 if (rc != EOK) { 250 ext4_filesystem_put_block_group_ref(bg_ref); 227 251 return rc; 252 } 228 253 229 254 /* Modify filesystem counters */ … … 272 297 273 298 /* Block group not modified, put it and jump to the next block group */ 274 ext4_filesystem_put_block_group_ref(bg_ref); 299 rc = ext4_filesystem_put_block_group_ref(bg_ref); 300 if (rc != EOK) 301 return rc; 302 275 303 ++bgid; 276 304 }
Note:
See TracChangeset
for help on using the changeset viewer.