Changeset 1878386 in mainline
- Timestamp:
- 2011-06-20T19:17:37Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 01accb7
- Parents:
- 1affcdf3
- Location:
- uspace/srv/fs/minixfs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/minixfs/mfs.h
r1affcdf3 r1878386 199 199 free_zone(struct mfs_node *mnode, const uint32_t zone); 200 200 201 extern int 202 prune_ind_zones(struct mfs_node *mnode, size_t new_size); 203 201 204 /*mfs_dentry.c*/ 202 205 extern int -
uspace/srv/fs/minixfs/mfs_inode.c
r1affcdf3 r1878386 343 343 344 344 ino_i->i_size = new_size; 345 return EOK; 345 346 return prune_ind_zones(mnode, new_size); 346 347 347 348 exit_error: -
uspace/srv/fs/minixfs/mfs_rw.c
r1affcdf3 r1878386 97 97 98 98 r = rw_map_ondisk(&old_zone, mnode, zone, true, 0); 99 if (r != EOK) 100 return r; 99 on_error(r, return r); 101 100 102 101 if (old_zone > 0) … … 163 162 164 163 r = read_ind_zone(inst, ino_i->i_izone[0], &ind_zone); 165 if (r != EOK) 166 return r; 164 on_error(r, return r); 167 165 168 166 *b = ind_zone[rblock]; … … 184 182 uint32_t zone; 185 183 r = alloc_zone_and_clear(inst, &zone); 186 if (r != EOK) 187 return r; 184 on_error(r, return r); 188 185 189 186 ino_i->i_izone[1] = zone; … … 194 191 195 192 r = read_ind_zone(inst, ino_i->i_izone[1], &ind_zone); 196 if (r != EOK) 197 return r; 193 on_error(r, return r); 198 194 199 195 /* … … 208 204 uint32_t zone; 209 205 r = alloc_zone_and_clear(inst, &zone); 210 if(r != EOK)211 goto out_free_ind1; 206 on_error(r, goto out_free_ind1); 207 212 208 ind_zone[ind2_off] = zone; 213 209 write_ind_zone(inst, ino_i->i_izone[1], ind_zone); … … 219 215 220 216 r = read_ind_zone(inst, ind_zone[ind2_off], &ind2_zone); 221 if (r != EOK) 222 goto out_free_ind1; 217 on_error(r, goto out_free_ind1); 223 218 224 219 *b = ind2_zone[ind2_off % ptrs_per_block]; … … 236 231 } 237 232 233 /*Free unused indirect zones*/ 234 int 235 prune_ind_zones(struct mfs_node *mnode, size_t new_size) 236 { 237 struct mfs_instance *inst = mnode->instance; 238 struct mfs_sb_info *sbi = inst->sbi; 239 struct mfs_ino_info *ino_i = mnode->ino_i; 240 int nr_direct, ptrs_per_block, rblock, r; 241 int i; 242 243 mfs_version_t fs_version = sbi->fs_version; 244 245 if (fs_version == MFS_VERSION_V1) { 246 nr_direct = V1_NR_DIRECT_ZONES; 247 ptrs_per_block = MFS_BLOCKSIZE / sizeof(uint16_t); 248 } else { 249 nr_direct = V2_NR_DIRECT_ZONES; 250 ptrs_per_block = sbi->block_size / sizeof(uint32_t); 251 } 252 253 rblock = new_size / sbi->block_size; 254 255 if (rblock < nr_direct) { 256 /*free the single indirect zone*/ 257 if (ino_i->i_izone[0]) { 258 r = mfs_free_bit(inst, ino_i->i_izone[0], BMAP_ZONE); 259 on_error(r, return r); 260 261 ino_i->i_izone[0] = 0; 262 ino_i->dirty = true; 263 } 264 } 265 266 rblock -= nr_direct + ptrs_per_block; 267 268 int fzone_to_free = (rblock < 0 ? 0 : rblock) / ptrs_per_block; 269 270 /*free the entire double indirect zone*/ 271 uint32_t *dbl_zone; 272 273 r = read_ind_zone(inst, ino_i->i_izone[1], &dbl_zone); 274 on_error(r, return r); 275 276 for (i = fzone_to_free; i < ptrs_per_block; ++i) { 277 if (dbl_zone[i] == 0) 278 continue; 279 280 r = mfs_free_bit(inst, dbl_zone[i], BMAP_ZONE); 281 on_error(r, return r); 282 } 283 284 if (fzone_to_free) { 285 r = mfs_free_bit(inst, ino_i->i_izone[1], BMAP_ZONE); 286 ino_i->i_izone[1] = 0; 287 ino_i->dirty = true; 288 } 289 free(dbl_zone); 290 291 return r; 292 } 238 293 239 294 static int … … 244 299 245 300 r = block_get(&b, inst->handle, zone, BLOCK_FLAGS_NOREAD); 246 if (r != EOK) 247 return r; 301 on_error(r, return r); 248 302 249 303 memset(b->data, 0, b->size); … … 260 314 261 315 r = mfs_alloc_bit(inst, zone, BMAP_ZONE); 262 if (r != EOK) 263 goto out; 316 on_error(r, return r); 264 317 265 318 r = reset_zone_content(inst, *zone); 266 out:267 319 return r; 268 320 } … … 314 366 315 367 r = block_get(&b, inst->handle, zone, BLOCK_FLAGS_NONE); 316 if (r != EOK) 317 return r; 368 on_error(r, return r); 318 369 319 370 if (sbi->fs_version == MFS_VERSION_V1) {
Note:
See TracChangeset
for help on using the changeset viewer.