Merge "libsnapshot: Verify the ordering of COW operations." into main
This commit is contained in:
commit
1db90d0aac
|
@ -310,9 +310,34 @@ bool CowReader::PrepMergeOps() {
|
||||||
bool CowReader::VerifyMergeOps() {
|
bool CowReader::VerifyMergeOps() {
|
||||||
auto itr = GetMergeOpIter(true);
|
auto itr = GetMergeOpIter(true);
|
||||||
std::unordered_map<uint64_t, const CowOperation*> overwritten_blocks;
|
std::unordered_map<uint64_t, const CowOperation*> overwritten_blocks;
|
||||||
|
bool non_ordered_op_found = false;
|
||||||
|
|
||||||
while (!itr->AtEnd()) {
|
while (!itr->AtEnd()) {
|
||||||
const auto& op = itr->Get();
|
const auto& op = itr->Get();
|
||||||
uint64_t offset;
|
uint64_t offset;
|
||||||
|
|
||||||
|
// Op should not be a metadata
|
||||||
|
if (IsMetadataOp(*op)) {
|
||||||
|
LOG(ERROR) << "Metadata op: " << op << " found during merge sequence";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sequence ops should contain all the ordered ops followed
|
||||||
|
// by Replace and Zero ops. If we find the first op which
|
||||||
|
// is not ordered, that means all ordered ops processing
|
||||||
|
// has been completed.
|
||||||
|
if (!IsOrderedOp(*op)) {
|
||||||
|
non_ordered_op_found = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Since, all ordered ops processing has been completed,
|
||||||
|
// check that the subsequent ops are not ordered.
|
||||||
|
if (non_ordered_op_found && IsOrderedOp(*op)) {
|
||||||
|
LOG(ERROR) << "Invalid sequence - non-ordered and ordered ops"
|
||||||
|
<< " cannot be mixed during sequence generation";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!GetSourceOffset(op, &offset)) {
|
if (!GetSourceOffset(op, &offset)) {
|
||||||
itr->Next();
|
itr->Next();
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue