Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp705518rwe; Thu, 1 Sep 2022 06:33:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR5XtDGinHQk05jejCwhw0vnNHPjPnmbezGiwRCTDn0uXHmMePZqQlSSj1rG/m6OiMdDcIQc X-Received: by 2002:a05:6402:1f02:b0:445:f674:eac0 with SMTP id b2-20020a0564021f0200b00445f674eac0mr27994905edb.370.1662039185062; Thu, 01 Sep 2022 06:33:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662039185; cv=none; d=google.com; s=arc-20160816; b=ApSWR22yPVPkKnHnXSVmz76XbavPTzPJkddIpFBZ4BDxvDjg0GRSxHjxmihqfLY/pp cQ87pl09WZc7hHWtmkz+pZWAOwUR0cPnlCkegamKUlFIXSmt+WlWM+0Gk80O+3iezFQg sfMxSxEMADdA+Xaxy+aX3/SJFVVmEbIIx9xvGq7lT6IxYn81LNRKMVJTPQ7+91Gm9Mag DzyU2C8klXVQ5C/hixVdQYwMR82wpoMYkEzpo5MSlNFkJYiz4A0yfBzFnIzaqJifxOhv J8o1HxbNkaHSgTb3U9S3PqKA8aj/1jVLl+UqlmTUs2eQZctdnui6sOuJJ5+Q12JKWmGp X+SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Nn2osFg4zItkTqCRQtHh3A+Nq3B02jAcL4glpaqTPQw=; b=hgwE8jj4vQ/6hBOGkgq6xQqWgaFykCjoRlES0boLh4kg1jeTpp/1t4i0j3X4bXwOGx rOgP2YqrD2oAie1N6G+W+v5VNnx5lDeCauSJqRf9z00sGp77DxF7QwIlsCWaxyclP6Z3 SbbF9eoWWDx+Rlkt1Alkl5pvLgooTli4lnbdKAsWX2JJR7Hbb2K47tFBxFgUvFa5cuZp 5imCjGXYzUprbekYCf/9qOJ0L5bK4ha0KqGVDINK8gBpGZ4P9CpJPYbXW42thyheUINM Szw/5SZVXA6xPL+MzujQYHVyaVJ+KUowiHCAZ/Kv3+bLk29D6C2j68D86o82PWYuUC57 e0kQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x3-20020a170906710300b0073d8e4e8c95si9874026ejj.923.2022.09.01.06.32.28; Thu, 01 Sep 2022 06:33:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234306AbiIAN0s (ORCPT + 99 others); Thu, 1 Sep 2022 09:26:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234349AbiIANYw (ORCPT ); Thu, 1 Sep 2022 09:24:52 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5B2D237D8; Thu, 1 Sep 2022 06:24:05 -0700 (PDT) Received: from canpemm500005.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MJM8V2lB1zYd5V; Thu, 1 Sep 2022 21:19:38 +0800 (CST) Received: from huawei.com (10.175.127.227) by canpemm500005.china.huawei.com (7.192.104.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 1 Sep 2022 21:24:02 +0800 From: Zhang Yi To: , , , , , , , CC: , , , , , , , , , , , , Subject: [PATCH v2 06/14] jbd2: replace ll_rw_block() Date: Thu, 1 Sep 2022 21:34:57 +0800 Message-ID: <20220901133505.2510834-7-yi.zhang@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220901133505.2510834-1-yi.zhang@huawei.com> References: <20220901133505.2510834-1-yi.zhang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500005.china.huawei.com (7.192.104.229) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org ll_rw_block() is not safe for the sync read path because it cannot guarantee that submitting read IO if the buffer has been locked. We could get false positive EIO after wait_on_buffer() if the buffer has been locked by others. So stop using ll_rw_block() in journal_get_superblock(). We also switch to new bh_readahead_batch() for the buffer array readahead path. Signed-off-by: Zhang Yi --- fs/jbd2/journal.c | 15 ++++++--------- fs/jbd2/recovery.c | 16 ++++++++++------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 6350d3857c89..140b070471c0 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -1893,19 +1893,16 @@ static int journal_get_superblock(journal_t *journal) { struct buffer_head *bh; journal_superblock_t *sb; - int err = -EIO; + int err; bh = journal->j_sb_buffer; J_ASSERT(bh != NULL); - if (!buffer_uptodate(bh)) { - ll_rw_block(REQ_OP_READ, 1, &bh); - wait_on_buffer(bh); - if (!buffer_uptodate(bh)) { - printk(KERN_ERR - "JBD2: IO error reading journal superblock\n"); - goto out; - } + err = bh_read(bh, 0); + if (err < 0) { + printk(KERN_ERR + "JBD2: IO error reading journal superblock\n"); + goto out; } if (buffer_verified(bh)) diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c index f548479615c6..1f878c315b03 100644 --- a/fs/jbd2/recovery.c +++ b/fs/jbd2/recovery.c @@ -100,7 +100,7 @@ static int do_readahead(journal_t *journal, unsigned int start) if (!buffer_uptodate(bh) && !buffer_locked(bh)) { bufs[nbufs++] = bh; if (nbufs == MAXBUF) { - ll_rw_block(REQ_OP_READ, nbufs, bufs); + bh_readahead_batch(nbufs, bufs, 0); journal_brelse_array(bufs, nbufs); nbufs = 0; } @@ -109,7 +109,7 @@ static int do_readahead(journal_t *journal, unsigned int start) } if (nbufs) - ll_rw_block(REQ_OP_READ, nbufs, bufs); + bh_readahead_batch(nbufs, bufs, 0); err = 0; failed: @@ -152,9 +152,14 @@ static int jread(struct buffer_head **bhp, journal_t *journal, return -ENOMEM; if (!buffer_uptodate(bh)) { - /* If this is a brand new buffer, start readahead. - Otherwise, we assume we are already reading it. */ - if (!buffer_req(bh)) + /* + * If this is a brand new buffer, start readahead. + * Otherwise, we assume we are already reading it. + */ + bool need_readahead = !buffer_req(bh); + + bh_read_nowait(bh, 0); + if (need_readahead) do_readahead(journal, offset); wait_on_buffer(bh); } @@ -687,7 +692,6 @@ static int do_one_pass(journal_t *journal, mark_buffer_dirty(nbh); BUFFER_TRACE(nbh, "marking uptodate"); ++info->nr_replays; - /* ll_rw_block(WRITE, 1, &nbh); */ unlock_buffer(nbh); brelse(obh); brelse(nbh); -- 2.31.1