Changes in uspace/srv/fs/mfs/mfs_balloc.c [7a46bfe:c2e50d7] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/mfs/mfs_balloc.c
r7a46bfe rc2e50d7 36 36 static int 37 37 find_free_bit_and_set(bitchunk_t *b, const int bsize, 38 38 const bool native, unsigned start_bit); 39 39 40 40 static int … … 122 122 block_t *b; 123 123 124 assert(inst != NULL);125 124 sbi = inst->sbi; 126 assert(sbi != NULL);127 125 128 126 if (bid == BMAP_ZONE) { … … 131 129 if (idx > sbi->nzones) { 132 130 printf(NAME ": Error! Trying to free beyond the" \ 133 131 "bitmap max size\n"); 134 132 return -1; 135 133 } 136 134 } else { 137 /* bid == BMAP_INODE*/135 /* bid == BMAP_INODE */ 138 136 search = &sbi->isearch; 139 137 start_block = 2; 140 138 if (idx > sbi->ninodes) { 141 139 printf(NAME ": Error! Trying to free beyond the" \ 142 140 "bitmap max size\n"); 143 141 return -1; 144 142 } 145 143 } 146 144 147 /* Compute the bitmap block*/145 /* Compute the bitmap block */ 148 146 uint32_t block = idx / (sbi->block_size * 8) + start_block; 149 147 … … 152 150 goto out_err; 153 151 154 /* Compute the bit index in the block*/152 /* Compute the bit index in the block */ 155 153 idx %= (sbi->block_size * 8); 156 154 bitchunk_t *ptr = b->data; … … 192 190 int r, freebit; 193 191 194 assert(inst != NULL);195 192 sbi = inst->sbi; 196 assert(sbi != NULL);197 193 198 194 if (bid == BMAP_ZONE) { … … 202 198 limit = sbi->nzones - sbi->firstdatazone - 1; 203 199 } else { 204 /* bid == BMAP_INODE*/200 /* bid == BMAP_INODE */ 205 201 search = &sbi->isearch; 206 202 start_block = 2; … … 216 212 for (i = *search / bits_per_block; i < nblocks; ++i) { 217 213 r = block_get(&b, inst->service_id, i + start_block, 218 214 BLOCK_FLAGS_NONE); 219 215 220 216 if (r != EOK) … … 224 220 225 221 freebit = find_free_bit_and_set(b->data, sbi->block_size, 226 222 sbi->native, tmp); 227 223 if (freebit == -1) { 228 /* No free bit in this block*/224 /* No free bit in this block */ 229 225 r = block_put(b); 230 226 if (r != EOK) … … 233 229 } 234 230 235 /* Free bit found in this block, compute the real index*/231 /* Free bit found in this block, compute the real index */ 236 232 *idx = freebit + bits_per_block * i; 237 233 if (*idx > limit) { 238 /* Index is beyond the limit, it is invalid*/234 /* Index is beyond the limit, it is invalid */ 239 235 r = block_put(b); 240 236 if (r != EOK) … … 250 246 251 247 if (*search > 0) { 252 /* Repeat the search from the first bitmap block*/248 /* Repeat the search from the first bitmap block */ 253 249 *search = 0; 254 250 goto retry; 255 251 } 256 252 257 /* Free bit not found, return error*/253 /* Free bit not found, return error */ 258 254 return ENOSPC; 259 255 … … 264 260 static int 265 261 find_free_bit_and_set(bitchunk_t *b, const int bsize, 266 262 const bool native, unsigned start_bit) 267 263 { 268 264 int r = -1; … … 272 268 273 269 for (i = start_bit / chunk_bits; 274 i < bsize / sizeof(bitchunk_t); ++i) { 270 i < bsize / sizeof(bitchunk_t); ++i) { 271 275 272 if (!(~b[i])) { 276 /* No free bit in this chunk*/273 /* No free bit in this chunk */ 277 274 continue; 278 275 }
Note:
See TracChangeset
for help on using the changeset viewer.