From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84F756AA9 for ; Thu, 1 Sep 2022 15:50:09 +0000 (UTC) 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> Precedence: bulk X-Mailing-List: ntfs3@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220901133505.2510834-7-yi.zhang@huawei.com> 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