Skip to content

Commit

Permalink
Merge pull request ceph#15657 from xiexingguo/wip-reshard-allocation
Browse files Browse the repository at this point in the history
os/bluestore: fix potential access violation

Reviewed-by: Igor Fedotov <[email protected]>
  • Loading branch information
liewegas authored Jun 16, 2017
2 parents be0bbe1 + 8bb19f3 commit f7ede9b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/os/bluestore/BlueStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2181,16 +2181,21 @@ void BlueStore::ExtentMap::reshard(
new_shard_info.begin(),
new_shard_info.end());
shards.insert(shards.begin() + si_begin, new_shard_info.size(), Shard());
unsigned n = sv.size();
si_end = si_begin + new_shard_info.size();
for (unsigned i = si_begin; i < si_end; ++i) {

assert(sv.size() == shards.size());

// note that we need to update every shard_info of shards here,
// as sv might have been totally re-allocated above
for (unsigned i = 0; i < shards.size(); i++) {
shards[i].shard_info = &sv[i];
}

// mark newly added shards as dirty
for (unsigned i = si_begin; i < si_end; ++i) {
shards[i].loaded = true;
shards[i].dirty = true;
}
for (unsigned i = si_end; i < n; ++i) {
shards[i].shard_info = &sv[i];
}
}
dout(20) << __func__ << " fin " << sv << dendl;
inline_bl.clear();
Expand Down

0 comments on commit f7ede9b

Please sign in to comment.