md/r5cache: do r5c_update_log_state after log recovery
authorZhengyuan Liu <liuzhengyuan@kylinos.cn>
Sun, 4 Dec 2016 08:49:44 +0000 (16:49 +0800)
committerShaohua Li <shli@fb.com>
Tue, 6 Dec 2016 01:11:02 +0000 (17:11 -0800)
We should update log state after we did a log recovery, current completion
may get wrong log state since log->log_start wasn't initalized until we
called r5l_recovery_log.

At log recovery stage, no lock needed as there is no race conditon.
next_checkpoint field will be initialized in r5l_recovery_log too.

Signed-off-by: Zhengyuan Liu <liuzhengyuan@kylinos.cn>
Signed-off-by: Shaohua Li <shli@fb.com>
drivers/md/raid5-cache.c

index 5efb876..c3b3124 100644 (file)
@@ -2542,14 +2542,12 @@ create:
        if (log->max_free_space > RECLAIM_MAX_FREE_SPACE)
                log->max_free_space = RECLAIM_MAX_FREE_SPACE;
        log->last_checkpoint = cp;
-       log->next_checkpoint = cp;
-       mutex_lock(&log->io_mutex);
-       r5c_update_log_state(log);
-       mutex_unlock(&log->io_mutex);
 
        __free_page(page);
 
-       return r5l_recovery_log(log);
+       ret = r5l_recovery_log(log);
+       r5c_update_log_state(log);
+       return ret;
 ioerr:
        __free_page(page);
        return ret;