Skip to content

Commit 56056c2

Browse files
Zhengyuan Liushligit
authored andcommitted
md/raid5: write an empty meta-block when creating log super-block
If superblock points to an invalid meta block, r5l_load_log will set create_super with true and create an new superblock, this runtime path would always happen if we do no writing I/O to this array since it was created. Writing an empty meta block could avoid this unnecessary action at the first time we created log superblock. Another reason is for the corretness of log recovery. Currently we have bellow code to guarantee log revocery to be correct. if (ctx.seq > log->last_cp_seq + 1) { int ret; ret = r5l_log_write_empty_meta_block(log, ctx.pos, ctx.seq + 10); if (ret) return ret; log->seq = ctx.seq + 11; log->log_start = r5l_ring_add(log, ctx.pos, BLOCK_SECTORS); r5l_write_super(log, ctx.pos); } else { log->log_start = ctx.pos; log->seq = ctx.seq; } If we just created a array with a journal device, log->log_start and log->last_checkpoint should all be 0, then we write three meta block which are valid except mid one and supposed crash happened. The ctx.seq would equal to log->last_cp_seq + 1 and log->log_start would be set to position of mid invalid meta block after we did a recovery, this will lead to problems which could be avoided with this patch. Signed-off-by: Zhengyuan Liu <liuzhengyuan@kylinos.cn> Signed-off-by: Shaohua Li <shli@fb.com>
1 parent 28cd88e commit 56056c2

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/md/raid5-cache.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,7 @@ static int r5l_load_log(struct r5l_log *log)
11561156
if (create_super) {
11571157
log->last_cp_seq = prandom_u32();
11581158
cp = 0;
1159+
r5l_log_write_empty_meta_block(log, cp, log->last_cp_seq);
11591160
/*
11601161
* Make sure super points to correct address. Log might have
11611162
* data very soon. If super hasn't correct log tail address,

0 commit comments

Comments
 (0)