Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

btrfs: move unlikely checks around btrfs_is_shutdown() into the helper

Instead of surrounding every caller of btrfs_is_shutdown() with unlikely,
move the unlikely into the helper itself, like we do in other places in
btrfs and is common in the kernel outside btrfs too. Also make the fs_info
argument of btrfs_is_shutdown() const.

On a x86_84 box using gcc 14.2.0-19 from Debian, this resulted in a slight
reduction of the module's text size.

Before:

$ size fs/btrfs/btrfs.ko
text data bss dec hex filename
1939044 172568 15592 2127204 207564 fs/btrfs/btrfs.ko

After:

$ size fs/btrfs/btrfs.ko
text data bss dec hex filename
1938876 172568 15592 2127036 2074bc fs/btrfs/btrfs.ko

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Filipe Manana and committed by
David Sterba
7d7608cc 858f3293

+13 -13
+6 -6
fs/btrfs/file.c
··· 1437 1437 struct btrfs_inode *inode = BTRFS_I(file_inode(file)); 1438 1438 ssize_t num_written, num_sync; 1439 1439 1440 - if (unlikely(btrfs_is_shutdown(inode->root->fs_info))) 1440 + if (btrfs_is_shutdown(inode->root->fs_info)) 1441 1441 return -EIO; 1442 1442 /* 1443 1443 * If the fs flips readonly due to some impossible error, although we ··· 2042 2042 struct file *filp = desc->file; 2043 2043 struct address_space *mapping = filp->f_mapping; 2044 2044 2045 - if (unlikely(btrfs_is_shutdown(inode_to_fs_info(file_inode(filp))))) 2045 + if (btrfs_is_shutdown(inode_to_fs_info(file_inode(filp)))) 2046 2046 return -EIO; 2047 2047 if (!mapping->a_ops->read_folio) 2048 2048 return -ENOEXEC; ··· 3113 3113 int blocksize = BTRFS_I(inode)->root->fs_info->sectorsize; 3114 3114 int ret; 3115 3115 3116 - if (unlikely(btrfs_is_shutdown(inode_to_fs_info(inode)))) 3116 + if (btrfs_is_shutdown(inode_to_fs_info(inode))) 3117 3117 return -EIO; 3118 3118 3119 3119 /* Do not allow fallocate in ZONED mode */ ··· 3807 3807 { 3808 3808 int ret; 3809 3809 3810 - if (unlikely(btrfs_is_shutdown(inode_to_fs_info(inode)))) 3810 + if (btrfs_is_shutdown(inode_to_fs_info(inode))) 3811 3811 return -EIO; 3812 3812 3813 3813 filp->f_mode |= FMODE_NOWAIT | FMODE_CAN_ODIRECT; ··· 3822 3822 { 3823 3823 ssize_t ret = 0; 3824 3824 3825 - if (unlikely(btrfs_is_shutdown(inode_to_fs_info(file_inode(iocb->ki_filp))))) 3825 + if (btrfs_is_shutdown(inode_to_fs_info(file_inode(iocb->ki_filp)))) 3826 3826 return -EIO; 3827 3827 3828 3828 if (iocb->ki_flags & IOCB_DIRECT) { ··· 3839 3839 struct pipe_inode_info *pipe, 3840 3840 size_t len, unsigned int flags) 3841 3841 { 3842 - if (unlikely(btrfs_is_shutdown(inode_to_fs_info(file_inode(in))))) 3842 + if (btrfs_is_shutdown(inode_to_fs_info(file_inode(in)))) 3843 3843 return -EIO; 3844 3844 3845 3845 return filemap_splice_read(in, ppos, pipe, len, flags);
+2 -2
fs/btrfs/fs.h
··· 1154 1154 (unlikely(test_bit(BTRFS_FS_STATE_LOG_CLEANUP_ERROR, \ 1155 1155 &(fs_info)->fs_state))) 1156 1156 1157 - static inline bool btrfs_is_shutdown(struct btrfs_fs_info *fs_info) 1157 + static inline bool btrfs_is_shutdown(const struct btrfs_fs_info *fs_info) 1158 1158 { 1159 - return test_bit(BTRFS_FS_STATE_EMERGENCY_SHUTDOWN, &fs_info->fs_state); 1159 + return unlikely(test_bit(BTRFS_FS_STATE_EMERGENCY_SHUTDOWN, &fs_info->fs_state)); 1160 1160 } 1161 1161 1162 1162 static inline void btrfs_force_shutdown(struct btrfs_fs_info *fs_info)
+3 -3
fs/btrfs/inode.c
··· 901 901 int compress_type = fs_info->compress_type; 902 902 int compress_level = fs_info->compress_level; 903 903 904 - if (unlikely(btrfs_is_shutdown(fs_info))) 904 + if (btrfs_is_shutdown(fs_info)) 905 905 goto cleanup_and_bail_uncompressed; 906 906 907 907 inode_should_defrag(inode, start, end, end - start + 1, SZ_16K); ··· 1445 1445 unsigned long page_ops; 1446 1446 int ret = 0; 1447 1447 1448 - if (unlikely(btrfs_is_shutdown(fs_info))) { 1448 + if (btrfs_is_shutdown(fs_info)) { 1449 1449 ret = -EIO; 1450 1450 goto out_unlock; 1451 1451 } ··· 2111 2111 */ 2112 2112 ASSERT(!btrfs_is_zoned(fs_info) || btrfs_is_data_reloc_root(root)); 2113 2113 2114 - if (unlikely(btrfs_is_shutdown(fs_info))) { 2114 + if (btrfs_is_shutdown(fs_info)) { 2115 2115 ret = -EIO; 2116 2116 goto error; 2117 2117 }
+1 -1
fs/btrfs/ioctl.c
··· 5000 5000 5001 5001 int btrfs_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags) 5002 5002 { 5003 - if (unlikely(btrfs_is_shutdown(inode_to_fs_info(file_inode(cmd->file))))) 5003 + if (btrfs_is_shutdown(inode_to_fs_info(file_inode(cmd->file)))) 5004 5004 return -EIO; 5005 5005 5006 5006 switch (cmd->cmd_op) {
+1 -1
fs/btrfs/reflink.c
··· 873 873 bool same_inode = dst_inode == src_inode; 874 874 int ret; 875 875 876 - if (unlikely(btrfs_is_shutdown(inode_to_fs_info(file_inode(src_file))))) 876 + if (btrfs_is_shutdown(inode_to_fs_info(file_inode(src_file)))) 877 877 return -EIO; 878 878 879 879 if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY))