From 88b0c2ebae63e6b869a15bcf7e4795341a20e9e3 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Tue, 29 Aug 2017 13:17:45 +0100 Subject: [PATCH] [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. --- caching/superblock.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/caching/superblock.cc b/caching/superblock.cc index 5281afb..a76d8b0 100644 --- a/caching/superblock.cc +++ b/caching/superblock.cc @@ -253,7 +253,9 @@ superblock_traits::pack(superblock const &sb, superblock_disk &disk) disk.write_hits = to_disk(core.write_hits); disk.write_misses = to_disk(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(*core.dirty_root); }