Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1233787pxb; Fri, 10 Sep 2021 00:53:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxs5rurz7zFMBRl7IaBb3ykLD9RfW3XWd6Y95ZPRRzz37C2swqMYxPBsO5HrnLoG7C6TVnY X-Received: by 2002:a6b:e905:: with SMTP id u5mr5858888iof.116.1631260427366; Fri, 10 Sep 2021 00:53:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631260427; cv=none; d=google.com; s=arc-20160816; b=wy0gtunN2fSPaO+t/qLVIZR2u/8VGku33F19JSsBilCp3XGv9c//ejbdTPnHh/plKQ aTjXQ+AothH0eJ24JJU0VlaSS+BjbDWN3bNytB5d5D7EmNu0tENRYBxYL1Dm9oZFxjAL kp7GzJCRA3dCB29/oW/j1laGGMoqvPRHE1yyYtOrolN8LZ6HaehvTAIx8NQd918kNafI 2PZXa7oOs3epC9SSavMc1+25P0SwIL39/HJOszlexMzVI2LoP6/74fHdVpolfn/SSiZj A9uRlItPRYtLPAxv2Hpez03aHri7iWc1T4Njaa62YvdY2+gVDYUPkytsVwPISjWgBv5D RN1g== 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 :message-id:date:subject:cc:to:from; bh=doLUdYKnIYdLOmDvgX+cskykq6UfmZM2lV0vuj02upI=; b=ZxARomgxGSHHwQhNc5G0VAHeSCgNTWlJtVfbiMYz9h2vO/VSesbddjevMzk6EqbsfZ o/IWV4HoAqbDu6zzQHgKCQ/AxlcqRUPzz3+wVYl1Tbtsg5ujdayArRgwJUP/eOZxhfH1 89n8TETJw6zfhtTsyibzT9nvUq72gfqV4VOWA+iLOk3oi1/Af2RgPB8J4diDD9ijA9lP B3Wwh2FAaWQ4NaXyfan96ITqH5PHXAEVa3ePnvxRGbboTM3MoCcAkYbdqdPHUDtqj4DM WSyTMyA+vgfzNNTCQzBRN0AEtGO2NfrvH59XVe5Gwfz7KBTivuHjAzd/iphvLU+dfW8V IPgw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g6si4724308ilq.52.2021.09.10.00.53.28; Fri, 10 Sep 2021 00:53:47 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231561AbhIJHyb (ORCPT + 99 others); Fri, 10 Sep 2021 03:54:31 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:9027 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231502AbhIJHya (ORCPT ); Fri, 10 Sep 2021 03:54:30 -0400 Received: from dggeme752-chm.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4H5SlD5Jb0zVr3y; Fri, 10 Sep 2021 15:52:24 +0800 (CST) Received: from huawei.com (10.175.127.227) by dggeme752-chm.china.huawei.com (10.3.19.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.8; Fri, 10 Sep 2021 15:53:18 +0800 From: Zhang Yi To: CC: , , , , Subject: [PATCH] ext4: recheck buffer uptodate bit under buffer lock Date: Fri, 10 Sep 2021 16:03:16 +0800 Message-ID: <20210910080316.70421-1-yi.zhang@huawei.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggeme752-chm.china.huawei.com (10.3.19.98) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 --- 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