# Re: \[PATCH 2/2\] md/r5cache: set journal mode according to log content

- From: Song Liu \<hidden\>
- Date: 2016-12-04 20:11:04 
- List: linux-raid
- Page: https://ratatoskr.run/linux-raid/2016/12/6633814
- Thread: https://ratatoskr.run/linux-raid/2016/12/6633814/t.md

```text
I noticed this problem. This patch alone is not enough to fix it. I will send my patch 
for this soon. 

Thanks,
Song


> On Dec 4, 2016, at 12:44 AM, Zhengyuan Liu [ref] wrote:
> 
> Currently, we choice write-through mode as the default journal mode.
> If there is data-only stripes, we'd rewrite it and add it into raid5d
> release list. However, raid5d thread wouldn't put those stripes into
> cache(full/partial) list but inactive list instead since the journal
> mode is write-through. More futher, later read request would get data
> from raid disk directly instead of cache stripe, that's not we want too.
> 
> Signed-off-by: Zhengyuan Liu <redacted>
> ---
> drivers/md/raid5-cache.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c
> index 07bce0e..0473b33 100644
> --- a/drivers/md/raid5-cache.c
> +++ b/drivers/md/raid5-cache.c
> @@ -2606,7 +2606,6 @@ int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev)
> 
> 	INIT_WORK(&log->deferred_io_work, r5l_submit_io_async);
> 
> -	log->r5c_journal_mode = R5C_JOURNAL_MODE_WRITE_THROUGH;
> 	INIT_LIST_HEAD(&log->stripe_in_journal_list);
> 	spin_lock_init(&log->stripe_in_journal_lock);
> 	atomic_set(&log->stripe_in_journal_count, 0);
> @@ -2614,6 +2613,11 @@ int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev)
> 	if (r5l_load_log(log))
> 		goto error;
> 
> +	if (log->last_checkpoint == log->next_checkpoint)
> +		log->r5c_journal_mode = R5C_JOURNAL_MODE_WRITE_THROUGH;
> +	else
> +		log->r5c_journal_mode = R5C_JOURNAL_MODE_WRITE_BACK;
> +
> 	rcu_assign_pointer(conf->log, log);
> 	set_bit(MD_HAS_JOURNAL, &conf->mddev->flags);
> 	return 0;
> -- 
> 2.7.4
> 
> 
> 

```
