[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260203062523.3869120-3-yi.zhang@huawei.com>
Date: Tue, 3 Feb 2026 14:25:02 +0800
From: Zhang Yi <yi.zhang@...wei.com>
To: linux-ext4@...r.kernel.org
Cc: linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org,
tytso@....edu,
adilger.kernel@...ger.ca,
jack@...e.cz,
ojaswin@...ux.ibm.com,
ritesh.list@...il.com,
hch@...radead.org,
djwong@...nel.org,
yi.zhang@...wei.com,
yi.zhang@...weicloud.com,
yizhang089@...il.com,
libaokun1@...wei.com,
yangerkun@...wei.com,
yukuai@...as.com
Subject: [PATCH -next v2 02/22] ext4: make ext4_block_truncate_page() return zeroed length
Modify ext4_block_truncate_page() to return the zeroed length. This is
prepared for the move out of ordered data handling in
__ext4_block_zero_page_range(), which is prepared for the conversion of
block zero range to the iomap infrastructure.
Signed-off-by: Zhang Yi <yi.zhang@...wei.com>
---
fs/ext4/inode.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 759a2a031a9d..f856ea015263 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4163,6 +4163,7 @@ static int ext4_block_zero_page_range(handle_t *handle,
* up to the end of the block which corresponds to `from'.
* This required during truncate. We need to physically zero the tail end
* of that block so it doesn't yield old data if the file is later grown.
+ * Return the zeroed length on success.
*/
static int ext4_block_truncate_page(handle_t *handle,
struct address_space *mapping, loff_t from)
@@ -4170,6 +4171,8 @@ static int ext4_block_truncate_page(handle_t *handle,
unsigned length;
unsigned blocksize;
struct inode *inode = mapping->host;
+ bool did_zero = false;
+ int err;
/* If we are processing an encrypted inode during orphan list handling */
if (IS_ENCRYPTED(inode) && !fscrypt_has_encryption_key(inode))
@@ -4178,7 +4181,12 @@ static int ext4_block_truncate_page(handle_t *handle,
blocksize = i_blocksize(inode);
length = blocksize - (from & (blocksize - 1));
- return ext4_block_zero_page_range(handle, mapping, from, length, NULL);
+ err = ext4_block_zero_page_range(handle, mapping, from, length,
+ &did_zero);
+ if (err)
+ return err;
+
+ return did_zero ? length : 0;
}
int ext4_zero_partial_blocks(handle_t *handle, struct inode *inode,
--
2.52.0
Powered by blists - more mailing lists