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: <273dc469-cc25-479c-8cdf-b21253873354@huaweicloud.com>
Date: Sat, 25 Oct 2025 11:20:43 +0800
From: Zhang Yi <yi.zhang@...weicloud.com>
To: "Matthew Wilcox (Oracle)" <willy@...radead.org>,
 linux-fsdevel@...r.kernel.org, Christian Brauner <brauner@...nel.org>
Cc: Theodore Ts'o <tytso@....edu>, Andreas Dilger <adilger.kernel@...ger.ca>,
 linux-ext4@...r.kernel.org
Subject: Re: [PATCH 04/10] ext4: Use folio_next_pos()

On 10/25/2025 1:08 AM, Matthew Wilcox (Oracle) wrote:
> This is one instruction more efficient than open-coding folio_pos() +
> folio_size().  It's the equivalent of (x + y) << z rather than
> x << z + y << z.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@...radead.org>
> Cc: Theodore Ts'o <tytso@....edu>
> Cc: Andreas Dilger <adilger.kernel@...ger.ca>
> Cc: linux-ext4@...r.kernel.org

A nice cleanup!

Reviewed-by: Zhang Yi <yi.zhang@...wei.com>

> ---
>  fs/ext4/inode.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index e99306a8f47c..1b22e9516db4 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -1319,8 +1319,8 @@ static int ext4_write_begin(const struct kiocb *iocb,
>  	if (IS_ERR(folio))
>  		return PTR_ERR(folio);
>  
> -	if (pos + len > folio_pos(folio) + folio_size(folio))
> -		len = folio_pos(folio) + folio_size(folio) - pos;
> +	if (len > folio_next_pos(folio) - pos)
> +		len = folio_next_pos(folio) - pos;
>  
>  	from = offset_in_folio(folio, pos);
>  	to = from + len;
> @@ -2704,7 +2704,7 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)
>  
>  			if (mpd->map.m_len == 0)
>  				mpd->start_pos = folio_pos(folio);
> -			mpd->next_pos = folio_pos(folio) + folio_size(folio);
> +			mpd->next_pos = folio_next_pos(folio);
>  			/*
>  			 * Writeout when we cannot modify metadata is simple.
>  			 * Just submit the page. For data=journal mode we
> @@ -3146,8 +3146,8 @@ static int ext4_da_write_begin(const struct kiocb *iocb,
>  	if (IS_ERR(folio))
>  		return PTR_ERR(folio);
>  
> -	if (pos + len > folio_pos(folio) + folio_size(folio))
> -		len = folio_pos(folio) + folio_size(folio) - pos;
> +	if (len > folio_next_pos(folio) - pos)
> +		len = folio_next_pos(folio) - pos;
>  
>  	ret = ext4_block_write_begin(NULL, folio, pos, len,
>  				     ext4_da_get_block_prep);


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ