On 10/24/2018 10:38 PM, Mikulas Patocka wrote: > > > On Wed, 24 Oct 2018, Shenghui Wang wrote: > >> 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 > >> Signed-off-by: Shenghui Wang <shhuiw@xxxxxxxxxxx> >> --- >> drivers/md/dm-writecache.c | 5 ++--- >> 1 file changed, 2 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c >> index d656bd1799ae..8e9e96a22f68 100644 >> --- a/drivers/md/dm-writecache.c >> +++ b/drivers/md/dm-writecache.c >> @@ -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; >> } >> -- >> 2.18.0 >> >> >> > > -- dm-devel mailing list dm-devel@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/dm-devel