forked from vitalif/vitastor
Fix #36 - Fix old version data sometimes overriding new version data
Reproduction case: - v3 = (offset 4kb, length 16kb) - v2 = (offset 24kb, length 16kb) - v1 = (offset 16kb, length 16kb) - At the third step it was inserting 16..24kb instead of 20..24kbmaster
parent
fea451b4db
commit
8398ad0117
|
@ -743,12 +743,15 @@ bool journal_flusher_co::scan_dirty(int wait_base)
|
|||
offset = dirty_it->second.offset;
|
||||
end_offset = dirty_it->second.offset + dirty_it->second.len;
|
||||
it = v.begin();
|
||||
while (1)
|
||||
while (end_offset > offset)
|
||||
{
|
||||
for (; it != v.end(); it++)
|
||||
if (it->offset >= offset)
|
||||
if (it->offset+it->len > offset)
|
||||
break;
|
||||
if (it == v.end() || it->offset > offset && it->len > 0)
|
||||
// If all items end before offset or if the found item starts after end_offset, just insert the buffer
|
||||
// If (offset < it->offset < end_offset) insert (offset..it->offset) part
|
||||
// If (it->offset <= offset <= it->offset+it->len) then just skip to it->offset+it->len
|
||||
if (it == v.end() || it->offset > offset)
|
||||
{
|
||||
submit_offset = dirty_it->second.location + offset - dirty_it->second.offset;
|
||||
submit_len = it == v.end() || it->offset >= end_offset ? end_offset-offset : it->offset-offset;
|
||||
|
@ -772,7 +775,7 @@ bool journal_flusher_co::scan_dirty(int wait_base)
|
|||
}
|
||||
}
|
||||
offset = it->offset+it->len;
|
||||
if (it == v.end() || offset >= end_offset)
|
||||
if (it == v.end())
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue