[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6jdhsvt6c77z7ta22okumhs7hzcwchrlsbg3xax2umgo4m3pyf@nte2kcbmbb7b>
Date: Wed, 30 Apr 2025 09:54:14 +0200
From: Jan Kara <jack@...e.cz>
To: Zhang Yi <yi.zhang@...weicloud.com>
Cc: linux-ext4@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org, tytso@....edu, adilger.kernel@...ger.ca, jack@...e.cz,
wanghaichi0403@...il.com, yi.zhang@...wei.com, libaokun1@...wei.com, yukuai3@...wei.com,
yangerkun@...wei.com
Subject: Re: [PATCH 2/4] ext4: fix incorrect punch max_end
On Wed 30-04-25 09:12:59, Zhang Yi wrote:
> From: Zhang Yi <yi.zhang@...wei.com>
>
> For the extents inodes, the maxbytes should be sb->s_maxbytes instead of
> sbi->s_bitmap_maxbytes. Correct the maxbytes value to correct the
> behavior of punch hole.
>
> Fixes: 2da376228a24 ("ext4: limit length to bitmap_maxbytes - blocksize in punch_hole")
> Signed-off-by: Zhang Yi <yi.zhang@...wei.com>
Looks good. Thanks! Feel free to add:
Reviewed-by: Jan Kara <jack@...e.cz>
Honza
> ---
> fs/ext4/inode.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 4ec4a80b6879..f9725e6347c7 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -4006,7 +4006,7 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
> struct inode *inode = file_inode(file);
> struct super_block *sb = inode->i_sb;
> ext4_lblk_t start_lblk, end_lblk;
> - loff_t max_end = EXT4_SB(sb)->s_bitmap_maxbytes - sb->s_blocksize;
> + loff_t max_end;
> loff_t end = offset + length;
> handle_t *handle;
> unsigned int credits;
> @@ -4015,6 +4015,12 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
> trace_ext4_punch_hole(inode, offset, length, 0);
> WARN_ON_ONCE(!inode_is_locked(inode));
>
> + if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
> + max_end = sb->s_maxbytes;
> + else
> + max_end = EXT4_SB(sb)->s_bitmap_maxbytes;
> + max_end -= sb->s_blocksize;
> +
> /* No need to punch hole beyond i_size */
> if (offset >= inode->i_size || offset >= max_end)
> return 0;
> --
> 2.46.1
>
--
Jan Kara <jack@...e.com>
SUSE Labs, CR
Powered by blists - more mailing lists