mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 10:04:04 +02:00
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>
This commit is contained in:
parent
858f32937c
commit
7d7608cc9a
|
|
@ -1437,7 +1437,7 @@ ssize_t btrfs_do_write_iter(struct kiocb *iocb, struct iov_iter *from,
|
|||
struct btrfs_inode *inode = BTRFS_I(file_inode(file));
|
||||
ssize_t num_written, num_sync;
|
||||
|
||||
if (unlikely(btrfs_is_shutdown(inode->root->fs_info)))
|
||||
if (btrfs_is_shutdown(inode->root->fs_info))
|
||||
return -EIO;
|
||||
/*
|
||||
* If the fs flips readonly due to some impossible error, although we
|
||||
|
|
@ -2042,7 +2042,7 @@ static int btrfs_file_mmap_prepare(struct vm_area_desc *desc)
|
|||
struct file *filp = desc->file;
|
||||
struct address_space *mapping = filp->f_mapping;
|
||||
|
||||
if (unlikely(btrfs_is_shutdown(inode_to_fs_info(file_inode(filp)))))
|
||||
if (btrfs_is_shutdown(inode_to_fs_info(file_inode(filp))))
|
||||
return -EIO;
|
||||
if (!mapping->a_ops->read_folio)
|
||||
return -ENOEXEC;
|
||||
|
|
@ -3113,7 +3113,7 @@ static long btrfs_fallocate(struct file *file, int mode,
|
|||
int blocksize = BTRFS_I(inode)->root->fs_info->sectorsize;
|
||||
int ret;
|
||||
|
||||
if (unlikely(btrfs_is_shutdown(inode_to_fs_info(inode))))
|
||||
if (btrfs_is_shutdown(inode_to_fs_info(inode)))
|
||||
return -EIO;
|
||||
|
||||
/* Do not allow fallocate in ZONED mode */
|
||||
|
|
@ -3807,7 +3807,7 @@ static int btrfs_file_open(struct inode *inode, struct file *filp)
|
|||
{
|
||||
int ret;
|
||||
|
||||
if (unlikely(btrfs_is_shutdown(inode_to_fs_info(inode))))
|
||||
if (btrfs_is_shutdown(inode_to_fs_info(inode)))
|
||||
return -EIO;
|
||||
|
||||
filp->f_mode |= FMODE_NOWAIT | FMODE_CAN_ODIRECT;
|
||||
|
|
@ -3822,7 +3822,7 @@ static ssize_t btrfs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
|
|||
{
|
||||
ssize_t ret = 0;
|
||||
|
||||
if (unlikely(btrfs_is_shutdown(inode_to_fs_info(file_inode(iocb->ki_filp)))))
|
||||
if (btrfs_is_shutdown(inode_to_fs_info(file_inode(iocb->ki_filp))))
|
||||
return -EIO;
|
||||
|
||||
if (iocb->ki_flags & IOCB_DIRECT) {
|
||||
|
|
@ -3839,7 +3839,7 @@ static ssize_t btrfs_file_splice_read(struct file *in, loff_t *ppos,
|
|||
struct pipe_inode_info *pipe,
|
||||
size_t len, unsigned int flags)
|
||||
{
|
||||
if (unlikely(btrfs_is_shutdown(inode_to_fs_info(file_inode(in)))))
|
||||
if (btrfs_is_shutdown(inode_to_fs_info(file_inode(in))))
|
||||
return -EIO;
|
||||
|
||||
return filemap_splice_read(in, ppos, pipe, len, flags);
|
||||
|
|
|
|||
|
|
@ -1154,9 +1154,9 @@ static inline void btrfs_wake_unfinished_drop(struct btrfs_fs_info *fs_info)
|
|||
(unlikely(test_bit(BTRFS_FS_STATE_LOG_CLEANUP_ERROR, \
|
||||
&(fs_info)->fs_state)))
|
||||
|
||||
static inline bool btrfs_is_shutdown(struct btrfs_fs_info *fs_info)
|
||||
static inline bool btrfs_is_shutdown(const struct btrfs_fs_info *fs_info)
|
||||
{
|
||||
return test_bit(BTRFS_FS_STATE_EMERGENCY_SHUTDOWN, &fs_info->fs_state);
|
||||
return unlikely(test_bit(BTRFS_FS_STATE_EMERGENCY_SHUTDOWN, &fs_info->fs_state));
|
||||
}
|
||||
|
||||
static inline void btrfs_force_shutdown(struct btrfs_fs_info *fs_info)
|
||||
|
|
|
|||
|
|
@ -901,7 +901,7 @@ static void compress_file_range(struct btrfs_work *work)
|
|||
int compress_type = fs_info->compress_type;
|
||||
int compress_level = fs_info->compress_level;
|
||||
|
||||
if (unlikely(btrfs_is_shutdown(fs_info)))
|
||||
if (btrfs_is_shutdown(fs_info))
|
||||
goto cleanup_and_bail_uncompressed;
|
||||
|
||||
inode_should_defrag(inode, start, end, end - start + 1, SZ_16K);
|
||||
|
|
@ -1445,7 +1445,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode,
|
|||
unsigned long page_ops;
|
||||
int ret = 0;
|
||||
|
||||
if (unlikely(btrfs_is_shutdown(fs_info))) {
|
||||
if (btrfs_is_shutdown(fs_info)) {
|
||||
ret = -EIO;
|
||||
goto out_unlock;
|
||||
}
|
||||
|
|
@ -2111,7 +2111,7 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode,
|
|||
*/
|
||||
ASSERT(!btrfs_is_zoned(fs_info) || btrfs_is_data_reloc_root(root));
|
||||
|
||||
if (unlikely(btrfs_is_shutdown(fs_info))) {
|
||||
if (btrfs_is_shutdown(fs_info)) {
|
||||
ret = -EIO;
|
||||
goto error;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5000,7 +5000,7 @@ static int btrfs_uring_encoded_write(struct io_uring_cmd *cmd, unsigned int issu
|
|||
|
||||
int btrfs_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags)
|
||||
{
|
||||
if (unlikely(btrfs_is_shutdown(inode_to_fs_info(file_inode(cmd->file)))))
|
||||
if (btrfs_is_shutdown(inode_to_fs_info(file_inode(cmd->file))))
|
||||
return -EIO;
|
||||
|
||||
switch (cmd->cmd_op) {
|
||||
|
|
|
|||
|
|
@ -873,7 +873,7 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
|
|||
bool same_inode = dst_inode == src_inode;
|
||||
int ret;
|
||||
|
||||
if (unlikely(btrfs_is_shutdown(inode_to_fs_info(file_inode(src_file)))))
|
||||
if (btrfs_is_shutdown(inode_to_fs_info(file_inode(src_file))))
|
||||
return -EIO;
|
||||
|
||||
if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY))
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user