[thin_restore (rust)] Apply several fixes

- Fix reading queued blocks
- Fix unnecessary block shadowing when there's no remaining values
- Prevent superblock from overwritten
- Flush queued writes before updating superblock
This commit is contained in:
Ming-Hung Tsai
2021-05-02 23:51:56 +08:00
parent e9899ac610
commit 4b4584c830
3 changed files with 24 additions and 9 deletions

View File

@@ -98,6 +98,7 @@ impl<'a> Pass1<'a> {
impl<'a> MetadataVisitor for Pass1<'a> {
fn superblock_b(&mut self, sb: &xml::Superblock) -> Result<Visit> {
self.result.sb = Some(sb.clone());
self.w.alloc()?;
Ok(Visit::Continue)
}
@@ -277,6 +278,8 @@ pub fn restore(opts: ThinRestoreOptions) -> Result<()> {
// FIXME: I think we need to decrement the shared leaves
// Build metadata space map
w.flush()?;
// Write the superblock
if let Some(xml_sb) = pass.sb {
let sb = superblock::Superblock {