Skip to content

Commit e6f9d69

Browse files
ccchengkdave
authored andcommitted
btrfs: export a helper for compression hard check
inode_can_compress will be used outside of inode.c to check the availability of setting compression flag by xattr. This patch moves this function as an internal helper and renames it to btrfs_inode_can_compress. Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: Chung-Chiang Cheng <cccheng@synology.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 5f0addf commit e6f9d69

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

fs/btrfs/btrfs_inode.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,17 @@ static inline bool btrfs_inode_in_log(struct btrfs_inode *inode, u64 generation)
384384
return ret;
385385
}
386386

387+
/*
388+
* Check if the inode has flags compatible with compression
389+
*/
390+
static inline bool btrfs_inode_can_compress(const struct btrfs_inode *inode)
391+
{
392+
if (inode->flags & BTRFS_INODE_NODATACOW ||
393+
inode->flags & BTRFS_INODE_NODATASUM)
394+
return false;
395+
return true;
396+
}
397+
387398
struct btrfs_dio_private {
388399
struct inode *inode;
389400

fs/btrfs/inode.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -480,17 +480,6 @@ static noinline int add_async_extent(struct async_chunk *cow,
480480
return 0;
481481
}
482482

483-
/*
484-
* Check if the inode has flags compatible with compression
485-
*/
486-
static inline bool inode_can_compress(struct btrfs_inode *inode)
487-
{
488-
if (inode->flags & BTRFS_INODE_NODATACOW ||
489-
inode->flags & BTRFS_INODE_NODATASUM)
490-
return false;
491-
return true;
492-
}
493-
494483
/*
495484
* Check if the inode needs to be submitted to compression, based on mount
496485
* options, defragmentation, properties or heuristics.
@@ -500,7 +489,7 @@ static inline int inode_need_compress(struct btrfs_inode *inode, u64 start,
500489
{
501490
struct btrfs_fs_info *fs_info = inode->root->fs_info;
502491

503-
if (!inode_can_compress(inode)) {
492+
if (!btrfs_inode_can_compress(inode)) {
504493
WARN(IS_ENABLED(CONFIG_BTRFS_DEBUG),
505494
KERN_ERR "BTRFS: unexpected compression for ino %llu\n",
506495
btrfs_ino(inode));
@@ -2019,7 +2008,7 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page
20192008
ASSERT(!zoned || btrfs_is_data_reloc_root(inode->root));
20202009
ret = run_delalloc_nocow(inode, locked_page, start, end,
20212010
page_started, nr_written);
2022-
} else if (!inode_can_compress(inode) ||
2011+
} else if (!btrfs_inode_can_compress(inode) ||
20232012
!inode_need_compress(inode, start, end)) {
20242013
if (zoned)
20252014
ret = run_delalloc_zoned(inode, locked_page, start, end,

0 commit comments

Comments
 (0)