dm writecache: flush metadata in single commit in init_memory
PATCH 1/1 dm writecache: flush metadata in single commit in init_memory
Do not flush sb ->magic in second commit.
Signed-off-by Shenghui Wang <[email protected]>
--- drivers/md/dm-writecache.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/md/dm-writecache.c +2 -3
@@ -1749,6 +1749,8 @@ static int init_memory(struct dm_writecache *wc)for (b =0 ; b <ARRAY_SIZE (sb (wc)->padding); b++)pmem_assign (sb (wc)->padding[b],cpu_to_le64 (0 )); + +pmem_assign (sb (wc)->magic,cpu_to_le32 (MEMORY_SUPERBLOCK_MAGIC ));pmem_assign (sb (wc)->version,cpu_to_le32 (MEMORY_SUPERBLOCK_VERSION ));pmem_assign (sb (wc)->block_size,cpu_to_le32 (wc->block_size));pmem_assign (sb (wc)->n_blocks,cpu_to_le64 (wc->n_blocks));
@@ -1759,9 +1761,6 @@ static int init_memory(struct dm_writecache *wc)writecache_flush_all_metadata (wc);writecache_commit_flushed (wc); -pmem_assign (sb (wc)->magic,cpu_to_le32 (MEMORY_SUPERBLOCK_MAGIC )); -writecache_flush_region (wc, &sb (wc)->magic,sizeof sb (wc)->magic); -writecache_commit_flushed (wc);return 0 ; }
Signature · 1 line
2.18.0
Mikulas Patocka
maintainerQuoted 1 line · Shenghui Wang
Do not flush sb ->magic in second commit.
This is intentional. The magic is written last, so that if the machine crashes while formatting the device, the incomplete superblock won't be misidentified as already formatted.
Mikulas
Quoted 33 lines
Signed-off-by Shenghui Wang <[email protected]>--- drivers/md/dm-writecache.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/md/dm-writecache.c +2
-3@@ -1749,6 +1749,8 @@ static int init_memory(struct dm_writecache *wc)for (b =0 ; b <ARRAY_SIZE (sb (wc)->padding); b++)pmem_assign (sb (wc)->padding[b],cpu_to_le64 (0 )); + +pmem_assign (sb (wc)->magic,cpu_to_le32 (MEMORY_SUPERBLOCK_MAGIC ));pmem_assign (sb (wc)->version,cpu_to_le32 (MEMORY_SUPERBLOCK_VERSION ));pmem_assign (sb (wc)->block_size,cpu_to_le32 (wc->block_size));pmem_assign (sb (wc)->n_blocks,cpu_to_le64 (wc->n_blocks));@@ -1759,9 +1761,6 @@ static int init_memory(struct dm_writecache *wc)writecache_flush_all_metadata (wc);writecache_commit_flushed (wc); -pmem_assign (sb (wc)->magic,cpu_to_le32 (MEMORY_SUPERBLOCK_MAGIC )); -writecache_flush_region (wc, &sb (wc)->magic,sizeof sb (wc)->magic); -writecache_commit_flushed (wc);return 0 ; }Signature · 1 line
2.18.0
Quoted 11 lines · Mikulas Patocka
Quoted 1 line · Shenghui Wang
Do not flush sb ->magic in second commit.
This is intentional. The magic is written last, so that if the machine crashes while formatting the device, the incomplete superblock won't be misidentified as already formatted.
Mikulas
Got it. Thanks,
-
shenghui
Quoted 36 lines
Quoted 34 lines
Signed-off-by Shenghui Wang <[email protected]>--- drivers/md/dm-writecache.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/md/dm-writecache.c +2
-3@@ -1749,6 +1749,8 @@ static int init_memory(struct dm_writecache *wc)for (b =0 ; b <ARRAY_SIZE (sb (wc)->padding); b++)pmem_assign (sb (wc)->padding[b],cpu_to_le64 (0 )); + +pmem_assign (sb (wc)->magic,cpu_to_le32 (MEMORY_SUPERBLOCK_MAGIC ));pmem_assign (sb (wc)->version,cpu_to_le32 (MEMORY_SUPERBLOCK_VERSION ));pmem_assign (sb (wc)->block_size,cpu_to_le32 (wc->block_size));pmem_assign (sb (wc)->n_blocks,cpu_to_le64 (wc->n_blocks));@@ -1759,9 +1761,6 @@ static int init_memory(struct dm_writecache *wc)writecache_flush_all_metadata (wc);writecache_commit_flushed (wc); -pmem_assign (sb (wc)->magic,cpu_to_le32 (MEMORY_SUPERBLOCK_MAGIC )); -writecache_flush_region (wc, &sb (wc)->magic,sizeof sb (wc)->magic); -writecache_commit_flushed (wc);return 0 ; }Signature · 1 line
2.18.0