Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9984709ybi; Wed, 24 Jul 2019 13:33:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqzyxrsGBAEsX4wD+O+VSsc0/Ozs8zgRPgoPmOZ04OV4sQ80GF/U1ghUpnnnzNNycUsRvnBA X-Received: by 2002:a17:902:2baa:: with SMTP id l39mr88482461plb.280.1564000392553; Wed, 24 Jul 2019 13:33:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564000392; cv=none; d=google.com; s=arc-20160816; b=oQpkwUAUJLJqRwRiJCuUrovoGMFuRuZW2jL/Tn18CR9lhcgBkdIUAawkNTvHDs1sQY qR0DhZ01iVf57DNhq3ZCdYmjHCTtYBYEWKVQzM71lwyH8eyFbQWqC2Co/a7kNM8ciuTp FYws0/sbJJqZzg/JZETMgYXizXsIeYwKwTKW1mWmgF8XWsqSEFkNYBOQ7jHY9uTgdVjv vFkjS6t//ucxbzo1eDUNsgGdgUL6pQ1AMqkJnjxw88oFlSia07M7Oqgzy3jLtn61aMmN HOv4uo6WeQtk2/Ar5bWV7NnLpe3mIwyOccwpxDUwksVo7Wh9+z3czZRoWHVDmqJU/uVl WJgw== 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=4Grun0vWBcJ9i5GS4lZ513M+gK7uhWF5c8HxdbDbrio=; b=n7CmjV32xJjBe4KP6Wu03zhaCNrYZxFTM4gLl21uUY8qQmlCLI+o5JkHOCqSUrZU27 lFOJglAUnDzX1ZSY5KdJNJPIxV6RwyQ/HtQ9n+mgCwEdE86ekGZ/mkM85d7InrCr1uxt xXKji7FWrzy07EZld43XrMKAOOulZWnKnGCDJ2D70PxGSmxzLVMGli7NjnfBZ90Va5fq KfLc3BFgvQqO3OBGYFIr/J03JQKmuwEuvIm0P0xP6kvT7GjzJ2ILCVp5UVsfMvFw0F3x Z0pDneQK6FCeTWKXH6E+wnd+N3VOP4tgsuFK5AHLUYeq0usB8Cgw6/v3PbZQ4iHfujtt 8raQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Zwk80CoA; 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 g22si14492224pfh.219.2019.07.24.13.32.58; Wed, 24 Jul 2019 13:33:12 -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=Zwk80CoA; 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 S2389067AbfGXUag (ORCPT + 99 others); Wed, 24 Jul 2019 16:30:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:52904 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388528AbfGXTbq (ORCPT ); Wed, 24 Jul 2019 15:31:46 -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 DB179229F4; Wed, 24 Jul 2019 19:31:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996705; bh=MdiaGN8UC4Xnttt9famvGIwedDcd4Ji8SrDssBUZnY0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zwk80CoAJ8RGSP1+BVcOr/BHJV8c9R3spC5CZNhPEmZMVw9fIK0bVceFvxVZtLao3 kW2o8gKENujb1o4NG3ekmJUrz9mZ5jPhJYzhMPetHwE8q+F99pkcev7UJDZqwIO8zr wva6IpZncwO+lwsj/FnEZDmFosJyZr94TdIbwAkw= 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 5.2 188/413] bcache: check CACHE_SET_IO_DISABLE bit in bch_journal() Date: Wed, 24 Jul 2019 21:17:59 +0200 Message-Id: <20190724191748.160983049@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@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 4e5fc05720fc..54f8886b6177 100644 --- a/drivers/md/bcache/journal.c +++ b/drivers/md/bcache/journal.c @@ -811,6 +811,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