Skip to contentSkip to conversation

remove redundant check buffer_uptodate()

PATCH New Hao Xu 1 participant 3 messages Apr 26, 2021

Subsystems (2)
lore
Share & tools
lore

Hao Xu

author
#0 lore raw

cover remove redundant check buffer_uptodate()

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.

Hao Xu (2):
fs: remove redundant check buffer_uptodate()
ntfs: remove redundant check buffer_uptodate()

 fs/buffer.c       | 9 +++------
 fs/ntfs/file.c    | 9 +++------
 fs/ntfs/logfile.c | 3 +--
 3 files changed, 7 insertions(+), 14 deletions(-)
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH 1/2 fs: remove redundant check buffer_uptodate()

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.

---
 fs/buffer.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
fs/buffer.c +3 -6
index 0cb7ffd4977c..195f224edd8e 100644
@@ -1997,10 +1997,8 @@ int __block_write_begin_int(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))
@@ -2031,8 +2029,7 @@ int __block_write_begin_int(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) &&
Signature · 1 line
1.8.3.1
author
#2 lore raw

PATCH 2/2 ntfs: remove redundant check buffer_uptodate()

In reply to Hao Xu

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.

---
 fs/ntfs/file.c    | 9 +++------
 fs/ntfs/logfile.c | 3 +--
 2 files changed, 4 insertions(+), 8 deletions(-)
fs/ntfs/file.c +3 -6
index e5aab265dff1..08b6bdf2cc2f 100644
@@ -719,8 +719,7 @@ static int ntfs_prepare_pages_for_non_resident_write(struct page **pages,
 			 * error recovery.
 			 */
 			if (PageUptodate(page)) {
-				if (!buffer_uptodate(bh))
-					set_buffer_uptodate(bh);
+				set_buffer_uptodate(bh);
 				if (unlikely(was_hole)) {
 					/* We allocated the buffer. */
 					clean_bdev_bh_alias(bh);
@@ -814,8 +813,7 @@ static int ntfs_prepare_pages_for_non_resident_write(struct page **pages,
 		read_unlock_irqrestore(&ni->size_lock, flags);
 		if (bh_pos > initialized_size) {
 			if (PageUptodate(page)) {
-				if (!buffer_uptodate(bh))
-					set_buffer_uptodate(bh);
+				set_buffer_uptodate(bh);
 			} else if (!buffer_uptodate(bh)) {
 				zero_user(page, bh_offset(bh), blocksize);
 				set_buffer_uptodate(bh);
@@ -938,8 +936,7 @@ static int ntfs_prepare_pages_for_non_resident_write(struct page **pages,
 				 * debatable and this could be removed.
 				 */
 				if (PageUptodate(page)) {
-					if (!buffer_uptodate(bh))
-						set_buffer_uptodate(bh);
+					set_buffer_uptodate(bh);
 				} else if (!buffer_uptodate(bh)) {
 					zero_user(page, bh_offset(bh),
 						blocksize);
fs/ntfs/logfile.c +1 -2
index bc1bf217b38e..9695540ce581 100644
@@ -796,8 +796,7 @@ bool ntfs_empty_logfile(struct inode *log_vi)
 			get_bh(bh);
 			/* Set the entire contents of the buffer to 0xff. */
 			memset(bh->b_data, -1, block_size);
-			if (!buffer_uptodate(bh))
-				set_buffer_uptodate(bh);
+			set_buffer_uptodate(bh);
 			if (buffer_dirty(bh))
 				clear_buffer_dirty(bh);
 			/*
Signature · 1 line
1.8.3.1