]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ext4: factor out ext4_get_maxbytes()
authorZhang Yi <yi.zhang@huawei.com>
Tue, 6 May 2025 01:20:08 +0000 (09:20 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Jun 2025 10:05:25 +0000 (11:05 +0100)
commit dbe27f06fa38b9bfc598f8864ae1c5d5831d9992 upstream.

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>
Reviewed-by: Baokun Li <libaokun1@huawei.com>
Link: https://patch.msgid.link/20250506012009.3896990-3-yi.zhang@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ext4/ext4.h
fs/ext4/extents.c
fs/ext4/file.c

index e1a5ec7362ad6ea908c499dddc3502c1baaf8da4..bdf5ff29489824934fb05b0849bba2f015e03fbd 100644 (file)
@@ -3377,6 +3377,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))                                            \
index 6b29c9ee2b1c1f68b041972ad7179c5f66394280..461a698794d2286462ff1f8e951353ac2b1aad49 100644 (file)
@@ -4977,12 +4977,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;
index 818f8d3e3775b34f8f772f9f0200dbd38b3e276f..6465fe1546d9d318ffc578fceef956eaab64911f 100644 (file)
@@ -863,12 +863,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: