From patchwork Tue Apr 19 16:04:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Coly Li X-Patchwork-Id: 12818754 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6B59C433EF for ; Tue, 19 Apr 2022 16:05:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354299AbiDSQHo (ORCPT ); Tue, 19 Apr 2022 12:07:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354393AbiDSQHg (ORCPT ); Tue, 19 Apr 2022 12:07:36 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF695BC2B; Tue, 19 Apr 2022 09:04:53 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 65D721F752; Tue, 19 Apr 2022 16:04:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1650384292; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=suTXyimM3RuxwOZfem+9Jfn70HGUAVc4SO+4D+kIats=; b=J/LX8G/qDy/5h3cXNDfs9Gschcz2BnO1TsLtkROYh4Mg7VohBkbSeEhNOKTr1duOWtHWSY UXQYcTingvUUXBVL0+97Jc7AKfjXPNvsczfpq2blekW6kakTZNwCnp4+RKPinQu9I5qR1X YtfjK//iUZehkHWKlK+QK7Sl1ijIHks= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1650384292; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=suTXyimM3RuxwOZfem+9Jfn70HGUAVc4SO+4D+kIats=; b=WWJN2bUMzSjIcxgKXWhoR0fjcaNTw2m2/axUgL81gtM4TjM30HRjsJzt+7vWOyvjzosm+N 6vvWQRbvWmjMpBDQ== Received: from localhost.localdomain (unknown [10.163.16.22]) by relay2.suse.de (Postfix) with ESMTP id 8BC6A2C142; Tue, 19 Apr 2022 16:04:43 +0000 (UTC) From: Coly Li To: axboe@kernel.dk Cc: hch@lst.de, kch@nvidia.com, snitzer@redhat.com, linux-bcache@vger.kernel.org, linux-block@vger.kernel.org, Coly Li Subject: [PATCH 1/2] bcache: put bch_bio_map() back to correct location in journal_write_unlocked() Date: Wed, 20 Apr 2022 00:04:24 +0800 Message-Id: <20220419160425.4148-2-colyli@suse.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220419160425.4148-1-colyli@suse.de> References: <20220419160425.4148-1-colyli@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Commit a7c50c940477 ("block: pass a block_device and opf to bio_reset") moves bch_bio_map() inside journal_write_unlocked() next to the location where the modified bio_reset() was called. This change is wrong because calling bch_bio_map() immediately after bio_reset(), a BUG_ON(!bio->bi_iter.bi_size) inside bch_bio_map() will be triggered and panic the kernel. This patch puts bch_bio_map() back to its original correct location in journal_write_unlocked() and avoid the BUG_ON(). Fixes: a7c50c940477 ("block: pass a block_device and opf to bio_reset") Signed-off-by: Coly Li Cc: Christoph Hellwig Cc: Chaitanya Kulkarni --- drivers/md/bcache/journal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c index 7c2ca52ca3e4..df5347ea450b 100644 --- a/drivers/md/bcache/journal.c +++ b/drivers/md/bcache/journal.c @@ -771,12 +771,12 @@ static void journal_write_unlocked(struct closure *cl) bio_reset(bio, ca->bdev, REQ_OP_WRITE | REQ_SYNC | REQ_META | REQ_PREFLUSH | REQ_FUA); - bch_bio_map(bio, w->data); bio->bi_iter.bi_sector = PTR_OFFSET(k, i); bio->bi_iter.bi_size = sectors << 9; bio->bi_end_io = journal_write_endio; bio->bi_private = w; + bch_bio_map(bio, w->data); trace_bcache_journal_write(bio, w->data->keys); bio_list_add(&list, bio);