Skip to contentSkip to conversation

dm thin: superblock may write succeed before other metadata blocks because of wirting metadata in async mode.

PATCH New Monty Pavel 1 participant 1 message May 22, 2018 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm thin: superblock may write succeed before other metadata blocks because of wirting metadata in async mode.

If dm_bufio_write_dirty_buffers func is called by __commit_transaction func and power loss happens during executing it, coincidencely superblock wrote correctly but some metadata blocks didn't. The reason is we write all metadata in async mode. We can guarantee that we send superblock after other blocks but we cannot guarantee that superblock write completely early than other blocks.
So, We need to commit other metadata blocks before change superblock.

---
 drivers/md/dm-thin-metadata.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
drivers/md/dm-thin-metadata.c +8 -0
index 36ef284..897d7d6 100644
@@ -813,6 +813,14 @@ static int __commit_transaction(struct dm_pool_metadata *pmd)
 	if (r)
 		return r;
 
+	r = dm_tm_commit(pmd->tm, sblock);
+	if (r)
+		return r;
+
+	r = superblock_lock(pmd, &sblock);
+	if (r)
+		return r;
+
 	disk_super = dm_block_data(sblock);
 	disk_super->time = cpu_to_le32(pmd->time);
 	disk_super->data_mapping_root = cpu_to_le64(pmd->root);
Signature · 1 line
1.7.1