Re: [PATCH] btrfs: Merge inode_can_compress in inode_need_compress
From: Qu Wenruo <hidden>
Date: 2020-08-18 07:51:10
On 2020/8/18 下午2:30, Nikolay Borisov wrote:
The latter is the only caller of the former. Just open code can_compress into need_compress and also remove the warning since it's made redundant by this change. Signed-off-by: Nikolay Borisov <redacted>
Reviewed-by: Qu Wenruo <redacted> Thanks, Qu
quoted hunk ↗ jump to hunk
--- fs/btrfs/inode.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-)diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 15dc8b6871ac..19e1918bad5c 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c@@ -410,17 +410,6 @@ static noinline int add_async_extent(struct async_chunk *cow, return 0; } -/* - * Check if the inode has flags compatible with compression - */ -static inline bool inode_can_compress(struct btrfs_inode *inode) -{ - if (inode->flags & BTRFS_INODE_NODATACOW || - inode->flags & BTRFS_INODE_NODATASUM) - return false; - return true; -} - /* * Check if the inode needs to be submitted to compression, based on mount * options, defragmentation, properties or heuristics.@@ -430,12 +419,9 @@ static inline int inode_need_compress(struct btrfs_inode *inode, u64 start, { struct btrfs_fs_info *fs_info = inode->root->fs_info; - if (!inode_can_compress(inode)) { - WARN(IS_ENABLED(CONFIG_BTRFS_DEBUG), - KERN_ERR "BTRFS: unexpected compression for ino %llu\n", - btrfs_ino(inode)); + if (inode->flags & BTRFS_INODE_NODATACOW || + inode->flags & BTRFS_INODE_NODATASUM) return 0; - } /* force compress */ if (btrfs_test_opt(fs_info, FORCE_COMPRESS)) return 1;@@ -1833,8 +1819,7 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page } else if (inode->flags & BTRFS_INODE_PREALLOC && !force_cow) { ret = run_delalloc_nocow(inode, locked_page, start, end, page_started, 0, nr_written); - } else if (!inode_can_compress(inode) || - !inode_need_compress(inode, start, end)) { + } else if (!inode_need_compress(inode, start, end)) { ret = cow_file_range(inode, locked_page, start, end, page_started, nr_written, 1); } else {