Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp239628ybi; Wed, 29 May 2019 20:25:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqwb9LnKVtqUW92+eRZQ46J453BPwFM1Q2JXpXiINBG67dfDHrEHfD6FLlKXhBPw2VR8RTsX X-Received: by 2002:aa7:82d7:: with SMTP id f23mr1476710pfn.138.1559186754915; Wed, 29 May 2019 20:25:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559186754; cv=none; d=google.com; s=arc-20160816; b=YiikOiidarcPioEKU8xC0M2W4qbrvKeUhx6CyOhbL2MUcXaIk8BOS4smayoY/KKBR/ F5aEvLAX7gP+S4yJGfQV1KF66Wyv3XaX79qOFqvcxQFvpNz5EgmXeJzn29ts6lBwOrDw kcQ2SHmMDcwX18qec/JnH4VjJ0ANqKXj15TLIO2npi3U4DjOj3SeysK4TRzsZ/313T/g 0Z3Ga1uA7fcTOqbGtJzFFX8CiV0vpCILszr9Aj3ONM1R9t34o25Kzv3WpqxZH3yugwwl mVoSzpNpCBDhdnBDjhdOvp9xvPfg4QQ1htvhZ5ZHUm3SM/xM8gosebHpndPD4Aqko8uX hOWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UgIJFnIM5R4BQnm/pMnSaeA+6RM/mMMr65J14RSPgPU=; b=Set6ATxvRbLRtoV/cP8MLI5GpI1CXuIvpSb/zjROo99JwRXOEpGKjZFR7pG7wv7WtE n8KKcTg9w0DDRwwJ2vj1WRe1len9mTyMRpuzBaw6ur5WR/sUbwGWwvT67PSaprj0NtfS wh+cH25IEbV3qlZ4KWpU4tl0/fdbXsald8in3t7UTwMYU3nJEuqCK4+ukcnakr7Ay6H8 EQT3q2AMm85lOJZeSPyTQRAKa/u2V9znj7h/bHDPZQZUXTEGQ2MWy0UG97PPQGOQCHR1 f9ezkZOhbauRHnvTJl1opm1g8X+u8pcw1hFcAhRZqtrgLTqXYN1LrPK7XcHDG+dxqHV+ q89w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IZ8Etljh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 15si2091547pfh.174.2019.05.29.20.25.38; Wed, 29 May 2019 20:25:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IZ8Etljh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732865AbfE3DWg (ORCPT + 99 others); Wed, 29 May 2019 23:22:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:44360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730870AbfE3DQ5 (ORCPT ); Wed, 29 May 2019 23:16:57 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7C04C24643; Thu, 30 May 2019 03:16:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186216; bh=Doz9nPlWGUNpWvla7mOSYN9TlcKDSLcUbeMO3iDwmz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IZ8Etljh9QvaE7jgvC6YPnjLmtluHPtbgMupQlEPLethbihCv5TgQ46pZKR4RfFuL RKqkBNb439mLGW8p3n6V4OjReAD/qlzMVySzTZWlONs2+J0Hfg5grShj+3xFizNxfu c0+aBHnC04bPTygIT6cyRGeSwoIyMmuDHBR15ZYs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tang Junhui , Dennis Schridde , Coly Li , Jens Axboe , Sasha Levin Subject: [PATCH 4.19 104/276] bcache: fix failure in journal relplay Date: Wed, 29 May 2019 20:04:22 -0700 Message-Id: <20190530030532.557672049@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030523.133519668@linuxfoundation.org> References: <20190530030523.133519668@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ 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 Tested-by: Dennis Schridde Signed-off-by: Coly Li Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- 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 07da39ac2d110..f880e5eba8dd9 100644 --- a/drivers/md/bcache/journal.c +++ b/drivers/md/bcache/journal.c @@ -317,6 +317,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; @@ -331,10 +343,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