diff mbox series

[v2] ext4: remove redundant check buffer_uptodate()

Message ID 1619418587-5580-1-git-send-email-joseph.qi@linux.alibaba.com
State Awaiting Upstream
Headers show
Series [v2] ext4: remove redundant check buffer_uptodate() | expand

Commit Message

Joseph Qi April 26, 2021, 6:29 a.m. UTC
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 <riteshh@linux.ibm.com>
Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
---
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(-)

Comments

Theodore Ts'o June 16, 2021, 11:26 p.m. UTC | #1
On Mon, Apr 26, 2021 at 02:29:47PM +0800, Joseph Qi wrote:
> 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 <riteshh@linux.ibm.com>
> Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>

Part of this change was already submitted by Yang Guo from Huawei;
I've applied the portion of this patch which is still applicable
(which was for ext4_buffer_uptodate function)

Thanks,

					- Ted
diff mbox series

Patch

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) &&