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