Skip to content

Commit

Permalink
os/bluestore: fix bluestore_blob_use_tracker_t::equal()
Browse files Browse the repository at this point in the history
Consider the following case:
bluestore_blob_use_tracker_t<1>(num_au = 1): tracked_use_range[0, 1000]
bluestore_blob_use_tracker_t<2>(num_au = 0): tracked_use_range[1, 1001]

the original coding logical will treat <1> to be equal to <2>, which is actually not.

For now, the only consumer of the method is BlueStore::fsck(),
so we can simply fix the above case by narrowing the condition.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
  • Loading branch information
xiexingguo committed Jun 15, 2017
1 parent 2b4b718 commit fb2f7ea
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/os/bluestore/bluestore_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -504,18 +504,7 @@ bool bluestore_blob_use_tracker_t::equal(
return true;
}

uint32_t n = num_au ? num_au : other.num_au;
uint32_t referenced =
num_au ? other.get_referenced_bytes() : get_referenced_bytes();
auto bytes_per_au_tmp = num_au ? bytes_per_au : other.bytes_per_au;
uint32_t my_referenced = 0;
for (size_t i = 0; i < n; i++) {
my_referenced += bytes_per_au_tmp[i];
if (my_referenced > referenced) {
return false;
}
}
return my_referenced == referenced;
return false;
}

void bluestore_blob_use_tracker_t::dump(Formatter *f) const
Expand Down

0 comments on commit fb2f7ea

Please sign in to comment.