LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Tang Junhui <tang.junhui.linux@gmail.com>,
	Dennis Schridde <devurandom@gmx.net>, Coly Li <colyli@suse.de>,
	Jens Axboe <axboe@kernel.dk>, Sasha Levin <sashal@kernel.org>,
	linux-bcache@vger.kernel.org
Subject: [PATCH AUTOSEL 4.4 19/92] bcache: fix failure in journal relplay
Date: Wed, 22 May 2019 15:30:14 -0400	[thread overview]
Message-ID: <20190522193127.27079-19-sashal@kernel.org> (raw)
In-Reply-To: <20190522193127.27079-1-sashal@kernel.org>

From: Tang Junhui <tang.junhui.linux@gmail.com>

[ Upstream commit 631207314d88e9091be02fbdd1fdadb1ae2ed79a ]

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(), when discard is enabled, 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.

(Coly Li: rebase the patch with other changes in bch_journal_replay())

Signed-off-by: Tang Junhui <tang.junhui.linux@gmail.com>
Tested-by: Dennis Schridde <devurandom@gmx.net>
Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/md/bcache/journal.c | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
index dfedc2c1f1e15..e12907fef597c 100644
--- a/drivers/md/bcache/journal.c
+++ b/drivers/md/bcache/journal.c
@@ -309,6 +309,18 @@ void bch_journal_mark(struct cache_set *c, struct list_head *list)
 	}
 }
 
+bool is_discard_enabled(struct cache_set *s)
+{
+	struct cache *ca;
+	unsigned int 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;
@@ -323,10 +335,15 @@ int bch_journal_replay(struct cache_set *s, struct list_head *list)
 		BUG_ON(i->pin && atomic_read(i->pin) != 1);
 
 		if (n != i->j.seq) {
-			pr_err("bcache: journal entries %llu-%llu missing! (replaying %llu-%llu)",
-			n, i->j.seq - 1, start, end);
-			ret = -EIO;
-			goto err;
+			if (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 {
+				pr_err("bcache: journal entries %llu-%llu missing! (replaying %llu-%llu)",
+					n, i->j.seq - 1, start, end);
+				ret = -EIO;
+				goto err;
+			}
 		}
 
 		for (k = i->j.start;
-- 
2.20.1


  parent reply	other threads:[~2019-05-22 19:33 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22 19:29 [PATCH AUTOSEL 4.4 01/92] gfs2: Fix lru_count going negative Sasha Levin
2019-05-22 19:29 ` [PATCH AUTOSEL 4.4 02/92] cxgb4: Fix error path in cxgb4_init_module Sasha Levin
2019-05-22 19:29 ` [PATCH AUTOSEL 4.4 03/92] mmc: core: Verify SD bus width Sasha Levin
2019-05-22 19:29 ` [PATCH AUTOSEL 4.4 04/92] powerpc/boot: Fix missing check of lseek() return value Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 05/92] ASoC: imx: fix fiq dependencies Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 06/92] spi: pxa2xx: fix SCR (divisor) calculation Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 07/92] brcm80211: potential NULL dereference in brcmf_cfg80211_vndr_cmds_dcmd_handler() Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 08/92] rtc: 88pm860x: prevent use-after-free on device remove Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 09/92] w1: fix the resume command API Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 10/92] dmaengine: pl330: _stop: clear interrupt status Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 11/92] mac80211/cfg80211: update bss channel on channel switch Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 12/92] driver core: platform: Fix the usage of platform device name(pdev->name) Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 13/92] ASoC: fsl_sai: Update is_slave_mode with correct value Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 14/92] mwifiex: prevent an array overflow Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 15/92] net: cw1200: fix a NULL pointer dereference Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 16/92] at76c50x-usb: Don't register led_trigger if usb_register_driver failed Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 17/92] ssb: Fix possible NULL pointer dereference in ssb_host_pcmcia_exit Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 18/92] bcache: return error immediately in bch_journal_replay() Sasha Levin
2019-05-22 19:30 ` Sasha Levin [this message]
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 20/92] bcache: add failure check to run_cache_set() for journal replay Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 21/92] bcache: avoid clang -Wunintialized warning Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 22/92] RDMA/cma: Consider scope_id while binding to ipv6 ll address Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 23/92] x86/build: Move _etext to actual end of .text Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 24/92] smpboot: Place the __percpu annotation correctly Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 25/92] x86/mm: Remove in_nmi() warning from 64-bit implementation of vmalloc_fault() Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 26/92] mm/uaccess: Use 'unsigned long' to placate UBSAN warnings on older GCC versions Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 27/92] HID: logitech-hidpp: use RAP instead of FAP to get the protocol version Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 28/92] pinctrl: pistachio: fix leaked of_node references Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 29/92] dmaengine: at_xdmac: remove BUG_ON macro in tasklet Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 30/92] media: coda: clear error return value before picture run Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 31/92] media: ov6650: Move v4l2_clk_get() to ov6650_video_probe() helper Sasha Levin
2019-05-22 19:30 ` [PATCH AUTOSEL 4.4 32/92] media: au0828: stop video streaming only when last user stops Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190522193127.27079-19-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=colyli@suse.de \
    --cc=devurandom@gmx.net \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tang.junhui.linux@gmail.com \
    --subject='Re: [PATCH AUTOSEL 4.4 19/92] bcache: fix failure in journal relplay' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).