Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1172614pxb; Thu, 16 Sep 2021 01:05:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxG1BpgDTtAyhnV+4Uaip3EKKUYL94FFnVl7xguLUXWPS1p6q5nqwALO2243p76vT2bQ8Rh X-Received: by 2002:a92:a801:: with SMTP id o1mr2844515ilh.128.1631779540009; Thu, 16 Sep 2021 01:05:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631779540; cv=none; d=google.com; s=arc-20160816; b=NV/csgX6bglF1Fo3kaoHBlp/Al7JHymEyrRTS341UGt/IWsfp0bvZlBRCKgcJKEqCC jbI/KHN3P4H7ldly53k4F3cY+pFFD4buKbrbtruW/693gc/58ovwU5MZkprsCm0WEXGY BmzGYHJjRC+syZru4tF7PK7pPIOWmKgynljhoYmV+3WUBr7SBSlTdydl9CLOFeOnqqZg 4djBloGTsVy+jPmJ0j/+tplwYomfkDxc03czB3ha8t1fTDRI5Nhm+S/R9yIpmFdQETx4 I1RnNoNlbOmGERTbJeX7d0XnrVOYE4nm+qgEGRHPO0z7ObAWqjDz71sk8R2t0umVk8tO ivUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=hVENeIY7NAsYPQTSoq53oPlwiVkAb+aTeVYsy6Rj4jk=; b=Q+fnPtwdNfyHRglWfJjqnEXLSTlikidU0IA+/Qyrw7Fbqrbwa8ujOhE/2oamr/dCJi PV16vE4Aqb/93pGCXrmoxrWW47ePE8xwQ1eixgi9xYBnL74/fj6lKGdqqV/bbzSbaQXc Sh3ZcmbtvMN39R5mBuN+RGOXO7IWdR5P6saNuROAYcoyOSI0gMyN6TYffB/WxnO1FOby l3WNybfmU0vtzFypoyTcK43pPpi9iTV88J+At7pCGe9FC4vvNn8RgLLf8s5/8olIqwR0 cQA1Xw1THoKwjfvE9sDz5Lvdl2HplHgvfr71LfZo0NBRUED4HCeeuE1FvhYEl5xEDUIX PRDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=hUIfCoU9; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b3si1887672iot.102.2021.09.16.01.05.24; Thu, 16 Sep 2021 01:05:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=hUIfCoU9; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234893AbhIPIG0 (ORCPT + 99 others); Thu, 16 Sep 2021 04:06:26 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:34454 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234878AbhIPIG0 (ORCPT ); Thu, 16 Sep 2021 04:06:26 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id B408E22335; Thu, 16 Sep 2021 08:05:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1631779505; 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=hVENeIY7NAsYPQTSoq53oPlwiVkAb+aTeVYsy6Rj4jk=; b=hUIfCoU9/AQVinfQgawSW+mRfMbzkKX9hNX4z6p/GF1tX0g7mup4qf8TXkqY5zToUwNaS/ VKi50h9E6JgDu9jmUro4+W5y9qvHst8ux9aeMzf2IcV2EJBn3sdcHDg3i7QfyPGvdOo7sb rDGs9TCE7eVmOz/fbXEoxkdZvu/mgSs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1631779505; 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=hVENeIY7NAsYPQTSoq53oPlwiVkAb+aTeVYsy6Rj4jk=; b=V6KtDAS0/v3G1tkrbqRgqSzFfh0ylkDq499Gb38wRbAC4JM8fc1LCVLr/ukMCOukp236Tp p47kUTu3XmfA94CA== Received: from quack2.suse.cz (unknown [10.100.224.230]) by relay2.suse.de (Postfix) with ESMTP id 9B140A3BA2; Thu, 16 Sep 2021 08:05:05 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 009F51E0C04; Thu, 16 Sep 2021 10:05:04 +0200 (CEST) Date: Thu, 16 Sep 2021 10:05:04 +0200 From: Jan Kara To: Zhang Yi Cc: linux-ext4@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, yukuai3@huawei.com Subject: Re: [PATCH] ext4: recheck buffer uptodate bit under buffer lock Message-ID: <20210916080504.GA10610@quack2.suse.cz> References: <20210910080316.70421-1-yi.zhang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210910080316.70421-1-yi.zhang@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Fri 10-09-21 16:03:16, Zhang Yi wrote: > Commit 8e33fadf945a ("ext4: remove an unnecessary if statement in > __ext4_get_inode_loc()") forget to recheck buffer's uptodate bit again > under buffer lock, which may overwrite the buffer if someone else have > already brought it uptodate and changed it. > > Fixes: 8e33fadf945a ("ext4: remove an unnecessary if statement in __ext4_get_inode_loc()") > Signed-off-by: Zhang Yi Oh, right. Thanks for fixing this. Feel free to add: Reviewed-by: Jan Kara Honza > --- > fs/ext4/inode.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index d18852d6029c..236adc647eb0 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -4340,6 +4340,12 @@ static int __ext4_get_inode_loc(struct super_block *sb, unsigned long ino, > goto has_buffer; > > lock_buffer(bh); > + if (ext4_buffer_uptodate(bh)) { > + /* Someone brought it uptodate while we waited */ > + unlock_buffer(bh); > + goto has_buffer; > + } > + > /* > * If we have all information of the inode in memory and this > * is the only valid inode in the block, we need not read the > -- > 2.31.1 > -- Jan Kara SUSE Labs, CR