Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp264459ybi; Wed, 29 May 2019 20:58:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqw0WTTBSH665InOipFQoR3bfYgJRw1z7FvTtQJHBwmPUOC05xYAVxlIJr2ioMARXiWbzMrL X-Received: by 2002:a17:902:6b03:: with SMTP id o3mr1773762plk.85.1559188681516; Wed, 29 May 2019 20:58:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559188681; cv=none; d=google.com; s=arc-20160816; b=wEFCgWp4qOHJE2d2v6kXiXXQSU5H+RsjFTNR+qcgBSkLBiiSnZz3Lse0HiVHjPOZ++ enkyGeZc0X2iwRaGYKqwSfCUtnRsWdOIMM+FAq1gWekM+gMYjtlOyvdrsWSX8PXUUhWW z/8AoQhttx6lLnTbjlyf5lJx4aknewp3EKWBmWY51Tdw+5jev+ptWYuFRK2EfMwrabl6 IQEinEJpHRaz6rB4cO6SzVSztfpUdQrk37Bpnd5UHzJxecVr85UeOpvJmus9j5MWx0az m5LrIXdlsiIfmdYW74gmWjz+kfKQtv+MS/OhDD7Fh2jWaDVjDHGZMYWh3nxaDLW+k6Dj AjVw== 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=fe79CqQ5ebOubeAXAhTr6YtY/f2rF9qk9cCTFt3uaxU=; b=LO9g0x5qI6fOg7T7rLrjKdUgTfptySCHQY5KErygPyQuLyeNcljhCivQxIdmNsx+oh WrMkcc23uOWo/uawI3coWWMYLS9Y8onjhUdF+ul5W+CbfPnT1IXedpHz8ScxJiQdG16v jiAAL1MFKBw1S75jjPmyutbL0lAZRHW3aRxG728eSRKv23bCxlSEQ3bJRNpXRhomfNxJ YWD35WI0SPLZoLJd5HD5oOJ8fmkoqgTIGja0MccqVg3RrY/jqZACXELbLc/fa2feriqH FiPkYf5VE0oXejaS3oT/pUqGkckQ82eQD+HxvwSp40iCHCOFo4ZA8y4BgBDMu+oMG92q gnAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=v9mrd4F9; 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 i22si2149177pfd.84.2019.05.29.20.57.46; Wed, 29 May 2019 20:58:01 -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=v9mrd4F9; 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 S1732244AbfE3Dyv (ORCPT + 99 others); Wed, 29 May 2019 23:54:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:54522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730956AbfE3DTR (ORCPT ); Wed, 29 May 2019 23:19:17 -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 ADE7124863; Thu, 30 May 2019 03:19:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186356; bh=wCQprKQ6UlTQ2cMR+4SA6hv03cc2sg5r/xo00vPGyiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v9mrd4F91lUCCZlApRqZ87fB7xNHtvhIBWxGUCPeV0gHDoySK1q+GYpVB/iKGoyk9 bh/2KJEAjVndc5bmllLUHG4rnn1uAc8jH3AxcJtQ1+4MK7zC8l+th4KwSfFuoI1OkM 80QfzltEPNo8ak0mo7fz6bt9TFzJLZr6P2K52xEQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Coly Li , Hannes Reinecke , Jens Axboe , Sasha Levin Subject: [PATCH 4.14 073/193] bcache: return error immediately in bch_journal_replay() Date: Wed, 29 May 2019 20:05:27 -0700 Message-Id: <20190530030459.393007741@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 68d10e6979a3b59e3cd2e90bfcafed79c4cf180a ] When failure happens inside bch_journal_replay(), calling cache_set_err_on() and handling the failure in async way is not a good idea. Because after bch_journal_replay() returns, registering code will continue to execute following steps, and unregistering code triggered by cache_set_err_on() is running in same time. First it is unnecessary to handle failure and unregister cache set in an async way, second there might be potential race condition to run register and unregister code for same cache set. So in this patch, if failure happens in bch_journal_replay(), we don't call cache_set_err_on(), and just print out the same error message to kernel message buffer, then return -EIO immediately caller. Then caller can detect such failure and handle it in synchrnozied way. Signed-off-by: Coly Li Reviewed-by: Hannes Reinecke Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/md/bcache/journal.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c index c02394c3181f7..cd8a82655e647 100644 --- a/drivers/md/bcache/journal.c +++ b/drivers/md/bcache/journal.c @@ -323,9 +323,12 @@ int bch_journal_replay(struct cache_set *s, struct list_head *list) list_for_each_entry(i, list, list) { BUG_ON(i->pin && atomic_read(i->pin) != 1); - cache_set_err_on(n != i->j.seq, s, -"bcache: journal entries %llu-%llu missing! (replaying %llu-%llu)", - n, i->j.seq - 1, start, end); + 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; + } for (k = i->j.start; k < bset_bkey_last(&i->j); -- 2.20.1