Changeset cd1cc4e6 in mainline for uspace/lib/ext4/libext4_ialloc.c
- Timestamp:
- 2012-01-24T16:32:32Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 02aad10
- Parents:
- 786bd56
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_ialloc.c
r786bd56 rcd1cc4e6 47 47 } 48 48 49 static uint32_t ext4_ialloc_index_in_group2inode(ext4_superblock_t *sb, 50 uint32_t index, uint32_t bgid) 51 { 52 uint32_t inodes_per_group = ext4_superblock_get_inodes_per_group(sb); 53 return bgid * inodes_per_group + (index + 1); 54 } 55 49 56 static uint32_t ext4_ialloc_get_bgid_of_inode(ext4_superblock_t *sb, 50 57 uint32_t inode) … … 127 134 uint32_t bgid = 0; 128 135 uint32_t bg_count = ext4_superblock_get_block_group_count(sb); 136 uint32_t sb_free_inodes = ext4_superblock_get_free_inodes_count(sb); 137 uint32_t avg_free_inodes = sb_free_inodes / bg_count; 129 138 130 139 while (bgid < bg_count) { 140 141 EXT4FS_DBG("testing bg \%u", bgid); 131 142 132 143 ext4_block_group_ref_t *bg_ref; … … 141 152 uint32_t used_dirs = ext4_block_group_get_used_dirs_count(bg, sb); 142 153 143 if ((free_inodes > 0) && (free_blocks > 0)) {144 145 uint32_t bitmap_block_addr = ext4_block_group_get_ block_bitmap(154 if ((free_inodes >= avg_free_inodes) && (free_blocks > 0)) { 155 156 uint32_t bitmap_block_addr = ext4_block_group_get_inode_bitmap( 146 157 bg_ref->block_group, sb); 147 158 … … 155 166 // Alloc bit 156 167 uint32_t inodes_in_group = ext4_superblock_get_inodes_in_group(sb, bgid); 157 rc = ext4_bitmap_find_free_bit_and_set(bitmap_block->data, 0, index, inodes_in_group); 158 if (rc == ENOSPC) { 159 block_put(bitmap_block); 160 ext4_filesystem_put_block_group_ref(bg_ref); 161 continue; 162 } 168 uint32_t index_in_group; 169 rc = ext4_bitmap_find_free_bit_and_set( 170 bitmap_block->data, 0, &index_in_group, inodes_in_group); 171 // if (rc == ENOSPC) { 172 // block_put(bitmap_block); 173 // ext4_filesystem_put_block_group_ref(bg_ref); 174 // continue; 175 // } 163 176 164 177 bitmap_block->dirty = true; … … 174 187 175 188 if (is_dir) { 176 used_dirs --;189 used_dirs++; 177 190 ext4_block_group_set_used_dirs_count(bg, sb, used_dirs); 178 191 } … … 183 196 if (rc != EOK) { 184 197 // TODO 185 }186 187 uint32_t sb_free_inodes = ext4_superblock_get_free_inodes_count(sb); 198 EXT4FS_DBG("ERRRRR"); 199 } 200 188 201 sb_free_inodes--; 189 202 ext4_superblock_set_free_inodes_count(sb, sb_free_inodes); 190 203 204 *index = ext4_ialloc_index_in_group2inode(sb, index_in_group, bgid); 205 191 206 return EOK; 192 207 193 } else {194 // Not modified195 ext4_filesystem_put_block_group_ref(bg_ref);196 208 } 197 209 210 // Not modified 211 ext4_filesystem_put_block_group_ref(bg_ref); 212 ++bgid; 198 213 } 199 214
Note:
See TracChangeset
for help on using the changeset viewer.