Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp3374035pxy; Sun, 25 Apr 2021 23:31:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpcjiK5aR1al9MOj8CiJUolLu0/6tCaEexsbAbAq1Ex5lJtSKnSJsW5/9jJworsbLiMajy X-Received: by 2002:aa7:d9cf:: with SMTP id v15mr19144862eds.358.1619418666522; Sun, 25 Apr 2021 23:31:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619418666; cv=none; d=google.com; s=arc-20160816; b=iWaqFgTpCC23k8rWldVqkpVJ3Ltt1u6iElt4SekSn5n1kFAXh50bAy0k8rDd6RV7zF vt3F0G+FspArn99BBEjrSJ0CRk7QejN6PVahS/+WbALlnKSsMr+rHSGkXBdG2BskePUK CZH5g56WsYqqzsqFUxU30+b7f9Iuqjw5dxc1kiA/gIMfDklkgWN2LhGbb4T1Q2f13xlp XCFDM3dEoj14eZeAwEWOcZXWFdkLyln4wlJ4cOK5d6frH4Eu3+w3brE3zIK6gB2YGPWj ffO8x0/eWAe2Hex0ltMUhtulVl74P/TT0fWxXEqAmQ/ob50lqqxfJsppZsq3KpgLyq4a jhLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=L38BGbqSduOwNoCj1u8DLZC3eGL5/+AMb/bgQD44WNo=; b=y16jRpid1Yrivg4FT2clhsrfQesVnQ19mQIyD8K5g/YtZTMWETM+MQRyPYmYFNPo72 kYk133y4FSbSJgFYu17ANdSPNs7VIkZ8M6WBHyIhp9FA0zyCyK9/A1noFQJ9OgCbsJVG C7QzTOo6F1KzrsHE1zrZztqEk8lzxB/K1ReKYsw1OfXTdEHujPeYjqylPXy/zKRlrsHs 2m3+oTqXyeDvaiMUx/BydV+rvuhCMXLV3uqZlvC/bzPwsxZX3VU01asMqLbCe4olj1cH Gs1jGIRtGmUPf9yo2VYTUjo+vSyvDNXpQy6NEm+P4iiXNB4YxnGv5kTc26T5VtHq9mGi NtHg== 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=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c9si1001828edv.186.2021.04.25.23.30.38; Sun, 25 Apr 2021 23:31:06 -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=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231816AbhDZGa3 (ORCPT + 99 others); Mon, 26 Apr 2021 02:30:29 -0400 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:42661 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231616AbhDZGa3 (ORCPT ); Mon, 26 Apr 2021 02:30:29 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04420;MF=joseph.qi@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0UWlCGB._1619418587; Received: from localhost(mailfrom:joseph.qi@linux.alibaba.com fp:SMTPD_---0UWlCGB._1619418587) by smtp.aliyun-inc.com(127.0.0.1); Mon, 26 Apr 2021 14:29:47 +0800 From: Joseph Qi To: tytso@mit.edu, adilger.kernel@dilger.ca Cc: riteshh@linux.ibm.com, linux-ext4@vger.kernel.org Subject: [PATCH v2] ext4: remove redundant check buffer_uptodate() Date: Mon, 26 Apr 2021 14:29:47 +0800 Message-Id: <1619418587-5580-1-git-send-email-joseph.qi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Now set_buffer_uptodate() will test first and then set, so we don't have to check buffer_uptodate() first, remove it to simplify code. Reviewed-by: Ritesh Harjani Signed-off-by: Joseph Qi --- v2: change ext4_buffer_uptodate() as well suggested by Ritesh. fs/ext4/ext4.h | 2 +- fs/ext4/inode.c | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 826a56e..92b06c7 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -3727,7 +3727,7 @@ static inline int ext4_buffer_uptodate(struct buffer_head *bh) * have to read the block because we may read the old data * successfully. */ - if (!buffer_uptodate(bh) && buffer_write_io_error(bh)) + if (buffer_write_io_error(bh)) set_buffer_uptodate(bh); return buffer_uptodate(bh); } diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 0948a43..9e02538 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -1065,10 +1065,8 @@ static int ext4_block_write_begin(struct page *page, loff_t pos, unsigned len, block++, block_start = block_end, bh = bh->b_this_page) { block_end = block_start + blocksize; if (block_end <= from || block_start >= to) { - if (PageUptodate(page)) { - if (!buffer_uptodate(bh)) - set_buffer_uptodate(bh); - } + if (PageUptodate(page)) + set_buffer_uptodate(bh); continue; } if (buffer_new(bh)) @@ -1092,8 +1090,7 @@ static int ext4_block_write_begin(struct page *page, loff_t pos, unsigned len, } } if (PageUptodate(page)) { - if (!buffer_uptodate(bh)) - set_buffer_uptodate(bh); + set_buffer_uptodate(bh); continue; } if (!buffer_uptodate(bh) && !buffer_delay(bh) && -- 1.8.3.1