From: Baokun Li <libaokun1@huawei.com>
To: Zhang Yi <yi.zhang@huaweicloud.com>
Cc: <linux-ext4@vger.kernel.org>, <linux-fsdevel@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <tytso@mit.edu>,
<adilger.kernel@dilger.ca>, <jack@suse.cz>,
<wanghaichi0403@gmail.com>, <yi.zhang@huawei.com>,
<yukuai3@huawei.com>, <yangerkun@huawei.com>
Subject: Re: [PATCH v2 3/4] ext4: factor out ext4_get_maxbytes()
Date: Tue, 6 May 2025 15:40:57 +0800 [thread overview]
Message-ID: <317c8848-6b66-4f54-b3ce-894e040dad60@huawei.com> (raw)
In-Reply-To: <20250506012009.3896990-3-yi.zhang@huaweicloud.com>
On 2025/5/6 9:20, Zhang Yi wrote:
> From: Zhang Yi <yi.zhang@huawei.com>
>
> There are several locations that get the correct maxbytes value based on
> the inode's block type. It would be beneficial to extract a common
> helper function to make the code more clear.
>
> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
> Reviewed-by: Jan Kara <jack@suse.cz>
Nice cleanup! Looks good to me.
Reviewed-by: Baokun Li <libaokun1@huawei.com>
> ---
> fs/ext4/ext4.h | 7 +++++++
> fs/ext4/extents.c | 7 +------
> fs/ext4/file.c | 7 +------
> 3 files changed, 9 insertions(+), 12 deletions(-)
>
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 5a20e9cd7184..8664bb5367c5 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -3378,6 +3378,13 @@ static inline unsigned int ext4_flex_bg_size(struct ext4_sb_info *sbi)
> return 1 << sbi->s_log_groups_per_flex;
> }
>
> +static inline loff_t ext4_get_maxbytes(struct inode *inode)
> +{
> + if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
> + return inode->i_sb->s_maxbytes;
> + return EXT4_SB(inode->i_sb)->s_bitmap_maxbytes;
> +}
> +
> #define ext4_std_error(sb, errno) \
> do { \
> if ((errno)) \
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index c616a16a9f36..b294d2f35a26 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -4931,12 +4931,7 @@ static const struct iomap_ops ext4_iomap_xattr_ops = {
>
> static int ext4_fiemap_check_ranges(struct inode *inode, u64 start, u64 *len)
> {
> - u64 maxbytes;
> -
> - if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
> - maxbytes = inode->i_sb->s_maxbytes;
> - else
> - maxbytes = EXT4_SB(inode->i_sb)->s_bitmap_maxbytes;
> + u64 maxbytes = ext4_get_maxbytes(inode);
>
> if (*len == 0)
> return -EINVAL;
> diff --git a/fs/ext4/file.c b/fs/ext4/file.c
> index beb078ee4811..b845a25f7932 100644
> --- a/fs/ext4/file.c
> +++ b/fs/ext4/file.c
> @@ -929,12 +929,7 @@ static int ext4_file_open(struct inode *inode, struct file *filp)
> loff_t ext4_llseek(struct file *file, loff_t offset, int whence)
> {
> struct inode *inode = file->f_mapping->host;
> - loff_t maxbytes;
> -
> - if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
> - maxbytes = EXT4_SB(inode->i_sb)->s_bitmap_maxbytes;
> - else
> - maxbytes = inode->i_sb->s_maxbytes;
> + loff_t maxbytes = ext4_get_maxbytes(inode);
>
> switch (whence) {
> default:
next prev parent reply other threads:[~2025-05-06 7:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-06 1:20 [PATCH v2 1/4] ext4: fix out of bounds punch offset Zhang Yi
2025-05-06 1:20 ` [PATCH v2 2/4] ext4: fix incorrect punch max_end Zhang Yi
2025-05-06 7:39 ` Baokun Li
2025-05-06 11:30 ` Jan Kara
2025-05-06 1:20 ` [PATCH v2 3/4] ext4: factor out ext4_get_maxbytes() Zhang Yi
2025-05-06 7:40 ` Baokun Li [this message]
2025-05-06 1:20 ` [PATCH v2 4/4] ext4: ensure i_size is smaller than maxbytes Zhang Yi
2025-05-06 7:42 ` Baokun Li
2025-05-06 7:37 ` [PATCH v2 1/4] ext4: fix out of bounds punch offset Baokun Li
2025-05-20 14:40 ` Theodore Ts'o
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=317c8848-6b66-4f54-b3ce-894e040dad60@huawei.com \
--to=libaokun1@huawei.com \
--cc=adilger.kernel@dilger.ca \
--cc=jack@suse.cz \
--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=yi.zhang@huaweicloud.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®