[cache-restore] Fix crash with --override-metadata-version flag.

If the actual metadata version is 1, then the dirty bitset will not be
present.  But the superblock was trying to write it because of the
overridden md version.
This commit is contained in:
Joe Thornber 2017-08-29 13:17:45 +01:00
parent 4da8d19f29
commit 88b0c2ebae

View File

@ -253,7 +253,9 @@ superblock_traits::pack(superblock const &sb, superblock_disk &disk)
disk.write_hits = to_disk<le32>(core.write_hits);
disk.write_misses = to_disk<le32>(core.write_misses);
if (core.version >= 2)
// The version may be overridden, meaning the dirty root may not
// actually be present.
if (core.version >= 2 && core.dirty_root)
disk.dirty_root = to_disk<le64>(*core.dirty_root);
}