Changeset 6088193 in mainline for uspace/lib/ext4/libext4_bitmap.c
- Timestamp:
- 2011-11-10T19:59:51Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 27ca3a3
- Parents:
- b3d7277
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_bitmap.c
rb3d7277 r6088193 95 95 } 96 96 97 int ext4_bitmap_free_block(ext4_filesystem_t *fs, uint32_t block_index)97 int ext4_bitmap_free_block(ext4_filesystem_t *fs, ext4_inode_ref_t *inode_ref, uint32_t block_index) 98 98 { 99 99 int rc; … … 102 102 uint32_t index_in_group; 103 103 uint32_t bitmap_block; 104 uint32_t block_size; 104 105 ext4_block_group_ref_t *bg_ref; 105 106 block_t *block; 107 108 block_size = ext4_superblock_get_block_size(fs->superblock); 106 109 107 110 blocks_per_group = ext4_superblock_get_blocks_per_group(fs->superblock); … … 128 131 return rc; 129 132 } 133 134 uint64_t ino_blocks = ext4_inode_get_blocks_count(fs->superblock, inode_ref->inode); 135 ino_blocks -= block_size / EXT4_INODE_BLOCK_SIZE; 136 ext4_inode_set_blocks_count(fs->superblock, inode_ref->inode, ino_blocks); 137 inode_ref->dirty = true; 130 138 131 139 uint32_t free_blocks = ext4_block_group_get_free_blocks_count(bg_ref->block_group); … … 138 146 rc = ext4_filesystem_put_block_group_ref(bg_ref); 139 147 if (rc != EOK) { 148 EXT4FS_DBG("error in saving bg_ref \%d", rc); 140 149 // TODO error 141 150 return rc; 142 151 } 143 152 144 EXT4FS_DBG("block \%u released", block_index);153 // EXT4FS_DBG("block \%u released", block_index); 145 154 146 155 return EOK; … … 177 186 rc = ext4_bitmap_find_free_bit_and_set(block->data, &rel_block_idx, block_size); 178 187 if (rc != EOK) { 179 EXT4FS_DBG("no block found");180 // TODO if ENOSPC - try next block group - try next block groups188 EXT4FS_DBG("no free block found"); 189 // TODO if ENOSPC - try next block groups 181 190 } 182 191 183 192 block->dirty = true; 184 193 185 // TODO check retval 186 block_put(block); 194 rc = block_put(block); 195 if (rc != EOK) { 196 // TODO error 197 EXT4FS_DBG("error in saving bitmap \%d", rc); 198 } 187 199 188 200 // TODO decrement superblock free blocks count … … 191 203 //ext4_superblock_set_free_blocks_count(sb, sb_free_blocks); 192 204 205 uint64_t ino_blocks = ext4_inode_get_blocks_count(fs->superblock, inode_ref->inode); 206 ino_blocks += block_size / EXT4_INODE_BLOCK_SIZE; 207 ext4_inode_set_blocks_count(fs->superblock, inode_ref->inode, ino_blocks); 208 inode_ref->dirty = true; 209 193 210 uint32_t bg_free_blocks = ext4_block_group_get_free_blocks_count(bg_ref->block_group); 194 211 bg_free_blocks--; … … 200 217 blocks_per_group = ext4_superblock_get_blocks_per_group(fs->superblock); 201 218 202 EXT4FS_DBG("block \%u allocated", blocks_per_group * block_group + rel_block_idx + 1);219 // EXT4FS_DBG("block \%u allocated", blocks_per_group * block_group + rel_block_idx + 1); 203 220 204 221 *fblock = blocks_per_group * block_group + rel_block_idx + 1;
Note:
See TracChangeset
for help on using the changeset viewer.