Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp880921rwe; Thu, 1 Sep 2022 09:00:46 -0700 (PDT) X-Google-Smtp-Source: AA6agR41K8Y+uUrdPwKUo0Y8wxbaO0zb2+y2q/VYEEuE0i4y4Qfs2BuntItWBIgzYWomviLb3ruz X-Received: by 2002:a17:907:75e4:b0:741:56b2:af3d with SMTP id jz4-20020a17090775e400b0074156b2af3dmr16618162ejc.367.1662048045230; Thu, 01 Sep 2022 09:00:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662048045; cv=none; d=google.com; s=arc-20160816; b=vNNCrysgLd0v2qwQ1fE4UZVU+ZeW1xlfGUxVcSaMCmFfxfcMkSmyj3TE/3YxCaL04D QcBUeLF7brLRoLS4g2yF/QixG+vKmv8vk9OZMQ16L3lnYi9bDTnKKr4M3nQsTrdh7A/U rtJq2rCnFtDeMrxskrbRcvkXyopRbE6NqftH5D4Droo6LA/ZEeOz2K0zurKL7gpeGj4K DLagDguxgtF/KtyLBeCo8H68iPCSEVcMADq7EBF0Ew+FYcVrcHqxWbqOlrWFsNYwewSy L1+uw+/gyYEkw9yec+me2l6gMFFN2e4R7tnE8qA4cxyyoCoD92x7cVbnmSwsd79g+Pvj oJtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=bXMDzUM1+Lt+ZSThjbm8wHTNDhe4lR0BR+Ul6jNDnQY=; b=b8MrPfSAlESOxpRtlceJf9UrHx9xiK7QPriKvrd09VVjhT5X7cGhAkGt/QR75WecnG HOdUJ1tqH/+anG4DNPhUzVpmeLtj67m/46Ks7CWPnhQVgw3nkzUohzXAIMS90PSykqJI 1oEskV5RydECD0ewEue/qhEvn1axS1zGf9LtKc4kFphRHOqCVznhZg2RPQZk9docvoJL PIHPS4944KzfFULPrMmPyNrWZwTK2FW5cz5jRQHBzSLhZD7jtFw/KI8xARjsrKm4C8IG S259li5/fFQaqGu6cw72MXg/79ICHJm3aiNL32+XevqzNdKnE8orxbO37Nrvh2iRUhYs hNuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=r2VkLAGY; dkim=neutral (no key) header.i=@suse.cz header.b=9e+lUWyX; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y14-20020a50bb0e000000b00447913261d8si2100240ede.98.2022.09.01.09.00.15; Thu, 01 Sep 2022 09:00:45 -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; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=r2VkLAGY; dkim=neutral (no key) header.i=@suse.cz header.b=9e+lUWyX; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234694AbiIAPuY (ORCPT + 99 others); Thu, 1 Sep 2022 11:50:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234467AbiIAPuV (ORCPT ); Thu, 1 Sep 2022 11:50:21 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2A2926AF4; Thu, 1 Sep 2022 08:50:09 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D37DE2292E; Thu, 1 Sep 2022 15:50:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1662047407; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=bXMDzUM1+Lt+ZSThjbm8wHTNDhe4lR0BR+Ul6jNDnQY=; b=r2VkLAGYBaA3EXSjbYzVFWa0a3q9G3jNT1VA5Q5q+PLMIplLvHZYU+J/o0bDa6fTlrv/4E kPIsESDfM8PcjgIFbTcUev0LSzfC73s2/3CVX0KwWrtKBCitp4Fua7WdH5LeQxrH6dGF9x s2DuS2A42c0kFwgmPfLC9xQ5x0uEShQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1662047407; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=bXMDzUM1+Lt+ZSThjbm8wHTNDhe4lR0BR+Ul6jNDnQY=; b=9e+lUWyXfrhZq9IsidiFG7B+edpO4waAl3VP49sIY2S+GyZpK13iobmYheYlScUM9tNFam S3fvNh+6dnywIXCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C402813A89; Thu, 1 Sep 2022 15:50:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Q/LUL6/UEGPwAwAAMHmgww (envelope-from ); Thu, 01 Sep 2022 15:50:07 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 41E74A067C; Thu, 1 Sep 2022 17:50:07 +0200 (CEST) Date: Thu, 1 Sep 2022 17:50:07 +0200 From: Jan Kara To: Zhang Yi Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, cluster-devel@redhat.com, ntfs3@lists.linux.dev, ocfs2-devel@oss.oracle.com, reiserfs-devel@vger.kernel.org, jack@suse.cz, tytso@mit.edu, akpm@linux-foundation.org, axboe@kernel.dk, viro@zeniv.linux.org.uk, rpeterso@redhat.com, agruenba@redhat.com, almaz.alexandrovich@paragon-software.com, mark@fasheh.com, dushistov@mail.ru, hch@infradead.org, chengzhihao1@huawei.com, yukuai3@huawei.com Subject: Re: [PATCH v2 06/14] jbd2: replace ll_rw_block() Message-ID: <20220901155007.nelecqohvd4plqqy@quack3> References: <20220901133505.2510834-1-yi.zhang@huawei.com> <20220901133505.2510834-7-yi.zhang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220901133505.2510834-7-yi.zhang@huawei.com> X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_SOFTFAIL, T_SCC_BODY_TEXT_LINE autolearn=no 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 On Thu 01-09-22 21:34:57, Zhang Yi wrote: > 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 Looks good to me. Feel free to add: Reviewed-by: Jan Kara Honza > --- > 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 > -- Jan Kara SUSE Labs, CR