Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp263709ybi; Wed, 29 May 2019 20:56:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqwOdzhPDKjAemXKKg7kPCSbe3lIU8ZU3P3QB/m9ov9L2dEV/eP7cQRg+T9+z8wT2LMWNkCr X-Received: by 2002:a65:4084:: with SMTP id t4mr1822188pgp.224.1559188619645; Wed, 29 May 2019 20:56:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559188619; cv=none; d=google.com; s=arc-20160816; b=rsTxOMCDxIrYmIEfyRn34rkrRYjLO7dVydffypDBE3SORsDsduQbXGPc8/0ZK9tQ3Q wEAENlCHonyTtZBZW4nH82XlSUaFVHHBcBZj1DqWfmS3KmjL2beAA5WJNzdO3yD8lqlC attvjN1gzcVARtqv0O+b4RvmAj/7LP9CS/FNwRo0RcK2gGIBufHmRBmMb7DuHUn5177c XwCA5svmtxJ6slwP+PRb6RE9JMzjEJx05gBUnL3/T6p9nzTlMRu9tZLBZy1dIFHU7KdQ sEBVJBPLYI5AeWB2LBueziikdYPiNHpaG+L2MhRwWpE5Il/UGggDo+ivn/OiZHPezyFj LYCA== 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=l7ASYSS4FN14QMYiIYKr/nUAwiMNIg1b3YTZZHZ3VqA=; b=YU5G3fbEf91N2pIiAukdy+jiTHRDejdvJ7aBtkeO9o2R/ustyJlGdbzWw+UMAEssNf 0O1lhG9+OXObtJTxgyPgCgR016/BglQsU3rOSponaQvc+aWnO/sWc2+pl2eC9Q49tQ1Q F4SU5fIth2xdQs2ZCEIKZCFtcktwo0ZYnJj/lTWV6HDZqCiyBtsiHiHa5G6kLpVlrLll cKP3YRK9odFaU7Mg9Uq7YvCq+lZcEBI2ERSnWQBuCOflHTcgpvvbt/ZhFd9qu8BmDpPF kanUcHvj4uUf8h3ReBeegUsnENY0RmHGab0yZUOG2HETNowfMIDPdJ32ps/Oi/D868+t qQSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pc8+9L5b; 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 v89si1936597pjb.14.2019.05.29.20.56.43; Wed, 29 May 2019 20:56:59 -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=pc8+9L5b; 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 S1733003AbfE3DyS (ORCPT + 99 others); Wed, 29 May 2019 23:54:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:54472 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730882AbfE3DTX (ORCPT ); Wed, 29 May 2019 23:19:23 -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 B1A8D24876; Thu, 30 May 2019 03:19:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186362; bh=Ek8jV78o2UrBifrhLN1u2LqlQotys4OvP9xjyIWRPr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pc8+9L5biqUXTOCTwbdERLHQjy/Pc9vuIldksZvobfhemoqndAA49iXr34Dt3Ml+A vrHbbCCPiUvWfM1yW5hVxwPZsCb7l8v32zxakQM8tZyB92Z5pu4gFiMbuuSCIyLScf 0RcJQXd+fGRK5pW4cKcwJdavb6rOFCXB4OBlj7Dk= 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.14 074/193] bcache: fix failure in journal relplay Date: Wed, 29 May 2019 20:05:28 -0700 Message-Id: <20190530030459.553817921@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030446.953835040@linuxfoundation.org> References: <20190530030446.953835040@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 cd8a82655e647..6394be5ee9a8f 100644 --- a/drivers/md/bcache/journal.c +++ b/drivers/md/bcache/journal.c @@ -310,6 +310,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; @@ -324,10 +336,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