Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fix bug with sparse files: do not try to move unallocated blocks

  • Loading branch information...
commit 8d0c8f857d588822e76ead7284ef6d0e64387893 1 parent a625095
Rinat Ibragimov authored

Showing 2 changed files with 12 additions and 0 deletions. Show diff stats Hide diff stats

  1. +2 0  defrag.cpp
  2. +10 0 reiserfs.cpp
2  defrag.cpp
@@ -124,6 +124,8 @@ Defrag::createMovemapFromListOfLeaves(movemap_t &movemap, const std::vector<uint
124 124 continue;
125 125 for (uint32_t idx = 0; idx < ih.length / 4; idx ++) {
126 126 uint32_t child_idx = block_obj->indirectItemRef(ih.offset, idx);
  127 + if (0 == child_idx) // sparse file
  128 + continue;
127 129 if (child_idx != free_idx)
128 130 movemap[child_idx] = free_idx;
129 131 free_idx = this->nextTargetBlock(free_idx);
10 reiserfs.cpp
@@ -175,6 +175,8 @@ ReiserFs::cleanupRegionMoveDataDown(uint32_t from, uint32_t to)
175 175 bool use_key = false;
176 176 for (uint32_t idx = 0; idx < ih.length/4; idx ++) {
177 177 uint32_t child_idx = block_obj->indirectItemRef(ih.offset, idx);
  178 + if (0 == child_idx) // sparse file
  179 + continue;
178 180 if (from <= child_idx && child_idx <= to) {
179 181 movemap[child_idx] = free_idx;
180 182 free_idx = this->findFreeBlockAfter(free_idx);
@@ -227,6 +229,8 @@ ReiserFs::createLeafIndex()
227 229 continue;
228 230 for (int idx = 0; idx < ih.length/4; idx ++) {
229 231 uint32_t child_idx = block_obj->indirectItemRef(ih.offset, idx);
  232 + if (0 == child_idx) // sparse file
  233 + continue;
230 234 uint32_t basket_id = child_idx / this->leaf_index_granularity;
231 235 this->leaf_index[basket_id].leaves.insert(it->idx);
232 236 }
@@ -255,6 +259,8 @@ ReiserFs::updateLeafIndex()
255 259 continue;
256 260 for (int idx = 0; idx < ih.length/4; idx ++) {
257 261 uint32_t target_idx = block_obj->indirectItemRef(ih.offset, idx);
  262 + if (0 == target_idx) // sparse file
  263 + continue;
258 264 uint32_t target_basket = target_idx / this->leaf_index_granularity;
259 265 if (target_basket == basket_id) {
260 266 leaf_has_link = true;
@@ -492,6 +498,8 @@ ReiserFs::recursivelyMoveUnformatted(uint32_t block_idx, movemap_t &movemap)
492 498 continue;
493 499 for (int idx = 0; idx < ih.length/4; idx ++) {
494 500 uint32_t child_idx = block_obj->indirectItemRef(ih.offset, idx);
  501 + if (0 == child_idx) // sparse file
  502 + continue;
495 503 if (movemap.count(child_idx) == 0) continue;
496 504 // update pointers in indirect item
497 505 block_obj->setIndirectItemRef(ih.offset, idx, movemap[child_idx]);
@@ -539,6 +547,8 @@ ReiserFs::leafContentMoveUnformatted(uint32_t block_idx, movemap_t &movemap,
539 547 continue;
540 548 for (int idx = 0; idx < ih.length/4; idx ++) {
541 549 uint32_t child_idx = block_obj->indirectItemRef(ih.offset, idx);
  550 + if (0 == child_idx) // sparse file
  551 + continue;
542 552 if (movemap.count(child_idx) == 0) continue;
543 553 uint32_t target_idx = movemap.find(child_idx)->second;
544 554 // update pointers in indirect item

0 comments on commit 8d0c8f8

Please sign in to comment.
Something went wrong with that request. Please try again.