mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhang Yi <yi.zhang@huaweicloud.com>
To: Jan Kara <jack@suse.cz>
Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, tytso@mit.edu,
	adilger.kernel@dilger.ca, wanghaichi0403@gmail.com,
	yi.zhang@huawei.com, libaokun1@huawei.com, yukuai3@huawei.com,
	yangerkun@huawei.com
Subject: Re: [PATCH 2/4] ext4: fix incorrect punch max_end
Date: Wed, 30 Apr 2025 16:44:25 +0800	[thread overview]
Message-ID: <8c1f9230-a475-4fc3-9b2d-5f11f5122bb3@huaweicloud.com> (raw)
In-Reply-To: <ykm27jvrnmhgd4spslhn4mano452c6z34fab7r3776dmjkgo7q@cv2lvsiteufa>

On 2025/4/30 16:18, Jan Kara wrote:
> On Wed 30-04-25 09:12:59, Zhang Yi wrote:
>> From: Zhang Yi <yi.zhang@huawei.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@huawei.com>
> 
> Thinking about this some more...
> 
>> @@ -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;
> 
> I think the -= sb->s_blocksize is needed only for indirect-block based
> scheme (due to an implementation quirk in ext4_ind_remove_space()). But
> ext4_ext_remove_space() should be fine with punch hole ending right at
> sb->s_maxbytes. And since I find it somewhat odd that you can create file
> upto s_maxbytes but cannot punch hole to the end, it'd limit that behavior
> as much as possible. Ideally we'd fix ext4_ind_remove_space() but I can't
> be really bothered for the ancient format...
> 

Yes, I share your feelings. Currently, we do not seem to have any
practical issues. To maintain consistent behavior between the two inode
types and to keep the code simple, I retained the -= sb->s_blocksize
operation. Would you suggest that we should at least address the extents
inodes by removing the -=sb->s_blocksize now?

Thanks,
Yi.


  reply	other threads:[~2025-04-30  8:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-30  1:12 [PATCH 1/4] ext4: fix out of bounds punch offset Zhang Yi
2025-04-30  1:12 ` [PATCH 2/4] ext4: fix incorrect punch max_end Zhang Yi
2025-04-30  7:54   ` Jan Kara
2025-04-30  8:18   ` Jan Kara
2025-04-30  8:44     ` Zhang Yi [this message]
2025-04-30 10:09       ` Jan Kara
2025-04-30 10:54         ` Zhang Yi
2025-04-30  1:13 ` [PATCH 3/4] ext4: factor out ext4_get_maxbytes() Zhang Yi
2025-04-30  7:55   ` Jan Kara
2025-04-30  1:13 ` [PATCH 4/4] ext4: ensure i_size is smaller than maxbytes Zhang Yi
2025-04-30  3:20   ` Matthew Wilcox
2025-04-30  3:32     ` Zhang Yi
2025-04-30  8:01   ` Jan Kara
2025-04-30  7:51 ` [PATCH 1/4] ext4: fix out of bounds punch offset Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8c1f9230-a475-4fc3-9b2d-5f11f5122bb3@huaweicloud.com \
    --to=yi.zhang@huaweicloud.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=jack@suse.cz \
    --cc=libaokun1@huawei.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=wanghaichi0403@gmail.com \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®