[space-map-disk] fix the number of free blocks (#93)

This commit is contained in:
Ming-Hung Tsai 2018-04-17 21:00:44 +08:00 committed by Joe Thornber
parent e619c6edd0
commit 582e424560
2 changed files with 3 additions and 3 deletions

View File

@ -422,7 +422,7 @@ namespace {
index_entry ie; index_entry ie;
ie.blocknr_ = wr.get_location(); ie.blocknr_ = wr.get_location();
ie.nr_free_ = i == (bitmap_count - 1) ? ie.nr_free_ = i == (bitmap_count - 1) ?
(nr_blocks % ENTRIES_PER_BLOCK) : ENTRIES_PER_BLOCK; (nr_blocks - ENTRIES_PER_BLOCK * i) : ENTRIES_PER_BLOCK;
ie.none_free_before_ = 0; ie.none_free_before_ = 0;
indexes_->save_ie(i, ie); indexes_->save_ie(i, ie);
@ -462,7 +462,7 @@ namespace {
unsigned nr_indexes = div_up<block_address>(nr_blocks_, ENTRIES_PER_BLOCK); unsigned nr_indexes = div_up<block_address>(nr_blocks_, ENTRIES_PER_BLOCK);
for (unsigned i = 0; i < nr_indexes; i++) { for (unsigned i = 0; i < nr_indexes; i++) {
unsigned hi = (i == nr_indexes - 1) ? (nr_blocks_ % ENTRIES_PER_BLOCK) : ENTRIES_PER_BLOCK; unsigned hi = (i == nr_indexes - 1) ? (nr_blocks_ - ENTRIES_PER_BLOCK * i) : ENTRIES_PER_BLOCK;
index_entry ie = indexes_->find_ie(i); index_entry ie = indexes_->find_ie(i);
bitmap bm(tm_, ie, bitmap_validator_); bitmap bm(tm_, ie, bitmap_validator_);
bm.iterate(i * ENTRIES_PER_BLOCK, hi, wrapper); bm.iterate(i * ENTRIES_PER_BLOCK, hi, wrapper);

View File

@ -98,7 +98,7 @@ metadata::metadata(block_manager<>::ptr bm, open_type ot,
sb_.device_details_root_ = details_->get_root(); sb_.device_details_root_ = details_->get_root();
sb_.data_block_size_ = data_block_size; sb_.data_block_size_ = data_block_size;
sb_.metadata_block_size_ = MD_BLOCK_SIZE >> SECTOR_SHIFT; sb_.metadata_block_size_ = MD_BLOCK_SIZE >> SECTOR_SHIFT;
sb_.metadata_nr_blocks_ = tm_->get_bm()->get_nr_blocks(); sb_.metadata_nr_blocks_ = metadata_sm_->get_nr_blocks();
break; break;
} }