dm era: save spacemap metadata root after the pre-commit
authorSomasundaram Krishnasamy <somasundaram.krishnasamy@oracle.com>
Fri, 7 Apr 2017 19:14:55 +0000 (12:14 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 20 May 2017 12:27:00 +0000 (14:27 +0200)
commit 117aceb030307dcd431fdcff87ce988d3016c34a upstream.

When committing era metadata to disk, it doesn't always save the latest
spacemap metadata root in superblock. Due to this, metadata is getting
corrupted sometimes when reopening the device. The correct order of update
should be, pre-commit (shadows spacemap root), save the spacemap root
(newly shadowed block) to in-core superblock and then the final commit.

Signed-off-by: Somasundaram Krishnasamy <somasundaram.krishnasamy@oracle.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/dm-era-target.c

index 665bf32856182e73bb390e3446b8280982bae020..32e76c5ee74172bef19f43a23b8f1cf9e5df20bc 100644 (file)
@@ -961,15 +961,15 @@ static int metadata_commit(struct era_metadata *md)
                }
        }
 
-       r = save_sm_root(md);
+       r = dm_tm_pre_commit(md->tm);
        if (r) {
-               DMERR("%s: save_sm_root failed", __func__);
+               DMERR("%s: pre commit failed", __func__);
                return r;
        }
 
-       r = dm_tm_pre_commit(md->tm);
+       r = save_sm_root(md);
        if (r) {
-               DMERR("%s: pre commit failed", __func__);
+               DMERR("%s: save_sm_root failed", __func__);
                return r;
        }