Re: [PATCH] [v2] bcache: fix failure in journal relplay

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2019/3/25 10:55 上午, Junhui Tang wrote:
> From 6e23ea6fb81df1cfea23ef7a37b8a5732d691caf Mon Sep 17 00:00:00 2001
> From: Tang Junhui <tang.junhui.linux@xxxxxxxxx
> <mailto:tang.junhui.linux@xxxxxxxxx>>
> Date: Wed, 12 Sep 2018 04:42:14 +0800
> Subject: [PATCH] [v2] bcache: fix failure in journal relplay
> 
> journal replay failed with messages:
> Sep 10 19:10:43 ceph kernel: bcache: error on
> bb379a64-e44e-4812-b91d-a5599871a3b1: bcache: journal entries
> 2057493-2057567 missing! (replaying 2057493-2076601), disabling
> caching
> 
> The reason is in journal_reclaim(), we send discard command and
> reclaim those journal buckets whose seq is old than the last_seq_now,
> but before we write a journal with last_seq_now, the machine is
> restarted, so the journal with the last_seq_now is not written to
> the journal bucket, and the last_seq_wrote in the newest journal is
> old than last_seq_now which we expect to be, so when we doing
> replay, journals from last_seq_wrote to last_seq_now are missing.
> 
> It's hard to write a journal immediately after journal_reclaim(),
> and it harmless if those missed journal are caused by discarding
> since those journals are already wrote to btree node. So, if miss
> seqs are started from the beginning journal, we treat it as normal,
> and only print a message to show the miss journal, and point out
> it maybe caused by discarding.
> 
> Patch v2 add a judgement condition to ignore the missed journal
> only when discard enabled as Coly suggested.
> 
> Signed-off-by: Tang Junhui <tang.junhui.linux@xxxxxxxxx
> <mailto:tang.junhui.linux@xxxxxxxxx>>

Hi Junhui,

It is good to me, I will add it into my for-test directory.

Thanks.

Coly Li

> ---
>  drivers/md/bcache/journal.c | 21 +++++++++++++++++++--
>  1 file changed, 19 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
> index 10748c6..59869bb 100644
> --- a/drivers/md/bcache/journal.c
> +++ b/drivers/md/bcache/journal.c
> @@ -315,6 +315,17 @@ void bch_journal_mark(struct cache_set *c, struct
> list_head *list)
>  }
>  }
>  
> +bool is_discard_enabled(struct cache_set *s)
> +{
> +struct cache *ca;
> +unsigned i;
> +
> +for_each_cache(ca, s, i)
> +if (ca->discard)
> +return true;
> +return false;
> +}
> +
>  int bch_journal_replay(struct cache_set *s, struct list_head *list)
>  {
>  int ret = 0, keys = 0, entries = 0;
> @@ -328,9 +339,15 @@ int bch_journal_replay(struct cache_set *s, struct
> list_head *list)
>  list_for_each_entry(i, list, list) {
>  BUG_ON(i->pin && atomic_read(i->pin) != 1);
>  
> -cache_set_err_on(n != i->j.seq, s,
> -"bcache: journal entries %llu-%llu missing! (replaying %llu-%llu)",
> +if (n != i->j.seq &&
> +    n == start &&
> +    is_discard_enabled(s))
> +pr_info("bcache: journal entries %llu-%llu may be discarded! (replaying
> %llu-%llu)",
>  n, i->j.seq - 1, start, end);
> +else
> +cache_set_err_on(n != i->j.seq, s,
> +       "bcache: journal entries %llu-%llu missing! (replaying %llu-%llu)",
> +       n, i->j.seq - 1, start, end);
>  
>  for (k = i->j.start;
>       k < bset_bkey_last(&i->j);
> -- 
> 1.8.3.1
> 


-- 

Coly Li



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux ARM Kernel]     [Linux Filesystem Development]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux