OSDN Git Service

md/r5cache: flush data only stripes in r5l_recovery_log()
authorSong Liu <songliubraving@fb.com>
Tue, 24 Jan 2017 01:12:57 +0000 (17:12 -0800)
committerShaohua Li <shli@fb.com>
Tue, 24 Jan 2017 19:20:15 +0000 (11:20 -0800)
commita85dd7b8df52e35d8ee3794c65cac5c39128fd80
tree3d69f1c7c7ce9c9a85c806763c12c774cd95643f
parentba02684daf7fb4a827580f909b7c7db61c05ae7d
md/r5cache: flush data only stripes in r5l_recovery_log()

For safer operation, all arrays start in write-through mode, which has been
better tested and is more mature. And actually the write-through/write-mode
isn't persistent after array restarted, so we always start array in
write-through mode. However, if recovery found data-only stripes before the
shutdown (from previous write-back mode), it is not safe to start the array in
write-through mode, as write-through mode can not handle stripes with data in
write-back cache. To solve this problem, we flush all data-only stripes in
r5l_recovery_log(). When r5l_recovery_log() returns, the array starts with
empty cache in write-through mode.

This logic is implemented in r5c_recovery_flush_data_only_stripes():

1. enable write back cache
2. flush all stripes
3. wake up conf->mddev->thread
4. wait for all stripes get flushed (reuse wait_for_quiescent)
5. disable write back cache

The wait in 4 will be waked up in release_inactive_stripe_list()
when conf->active_stripes reaches 0.

It is safe to wake up mddev->thread here because all the resource
required for the thread has been initialized.

Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Shaohua Li <shli@fb.com>
drivers/md/md.c
drivers/md/raid5-cache.c