ext4: factor out is_special_ino()
authorZhang Yi <yi.zhang@huawei.com>
Wed, 23 Apr 2025 08:52:54 +0000 (16:52 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 14 May 2025 14:42:12 +0000 (10:42 -0400)
Factor out the helper is_special_ino() to facilitate the checking of
special inodes in the subsequent patches.

Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Link: https://patch.msgid.link/20250423085257.122685-7-yi.zhang@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/ext4.h
fs/ext4/inode.c

index 3e724def1b06eba68f75c0481899427fbca3c81e..218a1e61547ad35fcd46a73cd53164f2174d15c7 100644 (file)
@@ -3055,6 +3055,17 @@ extern void ext4_da_update_reserve_space(struct inode *inode,
 extern int ext4_issue_zeroout(struct inode *inode, ext4_lblk_t lblk,
                              ext4_fsblk_t pblk, ext4_lblk_t len);
 
+static inline bool is_special_ino(struct super_block *sb, unsigned long ino)
+{
+       struct ext4_super_block *es = EXT4_SB(sb)->s_es;
+
+       return (ino < EXT4_FIRST_INO(sb) && ino != EXT4_ROOT_INO) ||
+               ino == le32_to_cpu(es->s_usr_quota_inum) ||
+               ino == le32_to_cpu(es->s_grp_quota_inum) ||
+               ino == le32_to_cpu(es->s_prj_quota_inum) ||
+               ino == le32_to_cpu(es->s_orphan_file_inum);
+}
+
 /* indirect.c */
 extern int ext4_ind_map_blocks(handle_t *handle, struct inode *inode,
                                struct ext4_map_blocks *map, int flags);
index 8c0d6fa58f26f00e210aac1ed69398b3d4e56386..64cadc46e4201b839e9abbe204efd01aec8d629b 100644 (file)
@@ -4797,12 +4797,7 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
        gid_t i_gid;
        projid_t i_projid;
 
-       if ((!(flags & EXT4_IGET_SPECIAL) &&
-            ((ino < EXT4_FIRST_INO(sb) && ino != EXT4_ROOT_INO) ||
-             ino == le32_to_cpu(es->s_usr_quota_inum) ||
-             ino == le32_to_cpu(es->s_grp_quota_inum) ||
-             ino == le32_to_cpu(es->s_prj_quota_inum) ||
-             ino == le32_to_cpu(es->s_orphan_file_inum))) ||
+       if ((!(flags & EXT4_IGET_SPECIAL) && is_special_ino(sb, ino)) ||
            (ino < EXT4_ROOT_INO) ||
            (ino > le32_to_cpu(es->s_inodes_count))) {
                if (flags & EXT4_IGET_HANDLE)