lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <v2gmd526vjvrjgc44abhw3jw6pyqqq4ypoo6y24umttkmlbnwf@y6ma2vz4iafb>
Date: Mon, 10 Nov 2025 10:35:29 +0100
From: Jan Kara <jack@...e.cz>
To: libaokun@...weicloud.com
Cc: linux-ext4@...r.kernel.org, tytso@....edu, adilger.kernel@...ger.ca, 
	jack@...e.cz, linux-kernel@...r.kernel.org, kernel@...kajraghav.com, 
	mcgrof@...nel.org, ebiggers@...nel.org, willy@...radead.org, yi.zhang@...wei.com, 
	yangerkun@...wei.com, chengzhihao1@...wei.com, libaokun1@...wei.com
Subject: Re: [PATCH v2 04/24] ext4: make ext4_punch_hole() support large
 block size

On Fri 07-11-25 22:42:29, libaokun@...weicloud.com wrote:
> From: Baokun Li <libaokun1@...wei.com>
> 
> When preparing for bs > ps support, clean up unnecessary PAGE_SIZE
> references in ext4_punch_hole().
> 
> Previously, when a hole extended beyond i_size, we aligned the hole end
> upwards to PAGE_SIZE to handle partial folio invalidation. Now that
> truncate_inode_pages_range() already handles partial folio invalidation
> correctly, this alignment is no longer required.
> 
> However, to save pointless tail block zeroing, we still keep rounding up
> to the block size here.
> 
> In addition, as Honza pointed out, when the hole end equals i_size, it
> should also be rounded up to the block size. This patch fixes that as well.
> 
> Suggested-by: Jan Kara <jack@...e.cz>
> Signed-off-by: Baokun Li <libaokun1@...wei.com>
> Reviewed-by: Zhang Yi <yi.zhang@...wei.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@...e.cz>

								Honza

> ---
>  fs/ext4/inode.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index f7ca48729738..6fec3aa2268a 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -4406,10 +4406,10 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
>  
>  	/*
>  	 * If the hole extends beyond i_size, set the hole to end after
> -	 * the page that contains i_size.
> +	 * the block that contains i_size to save pointless tail block zeroing.
>  	 */
> -	if (end > inode->i_size)
> -		end = round_up(inode->i_size, PAGE_SIZE);
> +	if (end >= inode->i_size)
> +		end = round_up(inode->i_size, sb->s_blocksize);
>  	if (end > max_end)
>  		end = max_end;
>  	length = end - offset;
> -- 
> 2.46.1
> 
-- 
Jan Kara <jack@...e.com>
SUSE Labs, CR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ