Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10423337ybi; Wed, 24 Jul 2019 22:58:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqy85k8umzJmt+oonS4dFq6r5zVH2CVLg9F49e7FooUzyGtXVrY9mUeSxWvssRMQLc5iatJD X-Received: by 2002:a63:607:: with SMTP id 7mr7713857pgg.240.1564034299676; Wed, 24 Jul 2019 22:58:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564034299; cv=none; d=google.com; s=arc-20160816; b=ssKD7rU2lAHwlcd8nxBp7l4Cne64M1saCw+Krx+QIs7e5fpioPi11dQa0YVXIdBdW+ 6vSHrn/XWIHbPc+fyS1YmzRC/9kFz2S/Ee1eamHEdAedecuoKzecIDt0ze3F4T/7hIZ8 DUA6MNrmQnabkjQwL56jupxZMF7AVSV4OSvoKFXKOlWOTZGYjjCqWhf91NwvYVaMHozT xfW8jcD8Tm11fCSmdIt2Wz+vSdzzaZQRvW4wVyWMLuLiElgsCgeRt46dhVIftWeQddQ0 pX4LRlgv160UaFxoJr3SuV8/d87+yTwGxYtA4zqP7E0z5bdvFJSMxUqnbFxCzXiVAk7p R8Ww== 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=EoDvBcOcrsKqyRIyv3CFC56YVpj4EMMkgPhN7Mi3dko=; b=gBCRZ6pcKR/BySxjGE5Bgsp2VTqT15B3v+BlW8yIM83/otjvoDMMw24DFBBRaDZ8Zg h28aiZWA6SlQSQ8u2hC9LR1o32KD2/68+ZndLkZv/FjMLmVg5qbtCihQpMZ5emnxNA8z qg6auDWq3rOWFOF+/tdjyG7FfcmT2o33HqGKHleRkeYLf/cxt9/iU+prQkcay2W4JGml Gk5LTFBCOowivKn4JEh87mDVPLGDwuV1frB29TOYuuO7eARy/Lj8bnh8ql4PsNtkgIvn lezTeJIul3P11GO3rHWG5HXazw46wMT4/kZL8Ob3qyIFuUw6Qrs2548u4lKG4E62cc+V HXgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YkObk3HU; 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 x3si15922250pgr.22.2019.07.24.22.58.05; Wed, 24 Jul 2019 22:58:19 -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=YkObk3HU; 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 S2390756AbfGYFlr (ORCPT + 99 others); Thu, 25 Jul 2019 01:41:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:56572 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404736AbfGYFlo (ORCPT ); Thu, 25 Jul 2019 01:41:44 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 9C02622C7D; Thu, 25 Jul 2019 05:41:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033304; bh=n0MQC/8XsC7homZ2nSmclkxOg6rP27Bzh8F2sa/T2tI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YkObk3HUyyw+AS8cK5o41rINz6BgyHFVBVcNfhJbiucKtCgP68CnPacd9EHa0GotE EfNWhkhyVOPqY89iqynLkKYZiCxMvZDcaW1txEcajqUUsLPzhTHuH8DSzX4B8FbSfs KssShOBIMrVEJ+La9ZNxYuE/CMgcGMSObfLZiLjU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Coly Li , Jens Axboe , Sasha Levin Subject: [PATCH 4.19 125/271] bcache: check CACHE_SET_IO_DISABLE bit in bch_journal() Date: Wed, 24 Jul 2019 21:19:54 +0200 Message-Id: <20190724191705.986718330@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@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 383ff2183ad16a8842d1fbd9dd3e1cbd66813e64 ] When too many I/O errors happen on cache set and CACHE_SET_IO_DISABLE bit is set, bch_journal() may continue to work because the journaling bkey might be still in write set yet. The caller of bch_journal() may believe the journal still work but the truth is in-memory journal write set won't be written into cache device any more. This behavior may introduce potential inconsistent metadata status. This patch checks CACHE_SET_IO_DISABLE bit at the head of bch_journal(), if the bit is set, bch_journal() returns NULL immediately to notice caller to know journal does not work. Signed-off-by: Coly Li Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/md/bcache/journal.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c index f880e5eba8dd..8d4d63b51553 100644 --- a/drivers/md/bcache/journal.c +++ b/drivers/md/bcache/journal.c @@ -810,6 +810,10 @@ atomic_t *bch_journal(struct cache_set *c, struct journal_write *w; atomic_t *ret; + /* No journaling if CACHE_SET_IO_DISABLE set already */ + if (unlikely(test_bit(CACHE_SET_IO_DISABLE, &c->flags))) + return NULL; + if (!CACHE_SYNC(&c->sb)) return NULL; -- 2.20.1