Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp277429ybi; Wed, 29 May 2019 21:13:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyO6KTih41pxU8t5STz9PFOrE0Go1qKBTtHw8VrDTsHkNwesRF9DMFv76ZdGv6QvY736cuU X-Received: by 2002:a17:90a:fa09:: with SMTP id cm9mr1565763pjb.137.1559189598530; Wed, 29 May 2019 21:13:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559189598; cv=none; d=google.com; s=arc-20160816; b=LmWU52F2TZYpi2sAe6WBnLpYkOdYMSpAlMRTwsShFNwSuwKZEZv5hQ9j/WqTgwXNWr FDox6x0dYs7SejE9h3sYBevzBdxSeIK8AVVDVCsrDu7EIyK7VuVgVwIHAXO2Azgg/IC2 +nQm0uDaHL0IT5iUhV2766H3D4GEDp0x6IcsXFpd63HyXvUFUZgb3mqYMmyZWHbp64mQ p5mb5x8vtdmkGBl8Up5FDxxUIXoTazeoLpS5UQ6QOSlEdbHs9Hr9h/cs2ZQarYaUZPG6 ADLpho/+lNcqzqU/+wg4YE/VjaMOhIfzT1L6XeTV5z3VtpA88ScxISTI7ZbuQcUHotSQ ly2Q== 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=2YjYSg5zrVbD3F6rr+MWs6CmyyOfq+Yri+/Gkb1jDuQ=; b=Bt33ygHHItUq2O61fe3hHijN1zjHWHVXwpDSNVxyCWQ3sVzgfmk0Uc9YnNBt8TAMPr b6UoiWovaclI6p8LJ7B3+eE8yXaNQXheDXCdH6BswX2+20iv8PRZMx/wJ08tGCJtgxfe Wbu/bpmiFkj1HfYkbpyA2/eIvZYwFruIh32r1Fe3izrRjw4p5s6swjuk+5VM6vOYzHDB G9upZ6qwoYhBdijJ8YQTSLhBf+GL/nd7EM6K0fEXEAEpilK/od0Vfu/w0XkJ3RNyWxqy dpHR4yK4qXRWTJsv0BMGzGJCIxmiSz0I0rg1CAgncA1LdFi2QgXOXPsXVOT+kz+preyN kpBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=K+X23mkU; 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 j23si2213016pgj.85.2019.05.29.21.13.02; Wed, 29 May 2019 21:13:18 -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=K+X23mkU; 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 S1726842AbfE3ELA (ORCPT + 99 others); Thu, 30 May 2019 00:11:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:44330 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730866AbfE3DQ4 (ORCPT ); Wed, 29 May 2019 23:16:56 -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 E5D742463F; Thu, 30 May 2019 03:16:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186216; bh=51h9W7jm+N2K/Rbbz/PlPliMaIU8cxTjg5mDJa6/Bno=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K+X23mkUoy8tF5IPVnyVxy4+ReZJDtDQOHInjYLGLVEkTz+YBSOeVk2u/z34eVt3+ Co9FfifWJMT3xbgUwl0y1zfC2mYVhmMRe+CBhSGnViKMlZb+nfM12g4vCEoEPDzXUY 3O+Vp9M4XRVjxxXh31BSDdtC8D0vWU5Kxkh7Gjb4= 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.19 103/276] bcache: return error immediately in bch_journal_replay() Date: Wed, 29 May 2019 20:04:21 -0700 Message-Id: <20190530030532.508804458@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 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 772258ee1f517..07da39ac2d110 100644 --- a/drivers/md/bcache/journal.c +++ b/drivers/md/bcache/journal.c @@ -330,9 +330,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