lkml.org 
[lkml]   [2023]   [Sep]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/3] ext4: Skip unwritten buffers in __ext4_block_zero_page_range()
Date
If the buffer is unwritten then the underlying block should already return zero
for reads. Further, if it is not dirty then we can be sure that there is no data
on the folio that might get written back later. Hence we skip zeroing out the
folio and underlying block in this case.

Suggested-by: Jan Kara <jack@suse.cz>
Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
---
fs/ext4/inode.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index de8ea8430d30..75a951ffa3cb 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3659,6 +3659,10 @@ static int __ext4_block_zero_page_range(handle_t *handle,
BUFFER_TRACE(bh, "freed: skip");
goto unlock;
}
+ if (buffer_unwritten(bh) && !buffer_dirty(bh)) {
+ BUFFER_TRACE(bh, "unwritten and non-dirty: skip");
+ goto unlock;
+ }
if (!buffer_mapped(bh)) {
BUFFER_TRACE(bh, "unmapped");
ext4_get_block(inode, iblock, bh, 0);
--
2.39.3
\
 
 \ /
  Last update: 2023-09-29 16:11    [W:0.079 / U:0.976 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site