提交 1e20d1c4 编写于 作者: D David Sterba

btrfs: allow defrag compress to override NOCOMPRESS attribute

Currently, the BTRFS_INODE_NOCOMPRESS will prevent any compression on a
given file, except when the mount is force-compress. As users have
reported on IRC, this will also prevent compression when requested by
defrag (btrfs fi defrag -c file).

The nocompress flag is set automatically by filesystem when the ratios
are bad and the user would have to manually drop the bit in order to
make defrag -c work. This is not good from the usability perspective.

This patch will raise priority for the defrag -c over nocompress, ie.
any file with NOCOMPRESS bit set will get defragmented. The bit will
remain untouched.

Alternate option was to also drop the nocompress bit and keep the
decision logic as is, but I think this is not the right solution.
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 1e2ef46d
...@@ -399,12 +399,12 @@ static inline int inode_need_compress(struct inode *inode, u64 start, u64 end) ...@@ -399,12 +399,12 @@ static inline int inode_need_compress(struct inode *inode, u64 start, u64 end)
/* force compress */ /* force compress */
if (btrfs_test_opt(fs_info, FORCE_COMPRESS)) if (btrfs_test_opt(fs_info, FORCE_COMPRESS))
return 1; return 1;
/* bad compression ratios */
if (BTRFS_I(inode)->flags & BTRFS_INODE_NOCOMPRESS)
return 0;
/* defrag ioctl */ /* defrag ioctl */
if (BTRFS_I(inode)->defrag_compress) if (BTRFS_I(inode)->defrag_compress)
return 1; return 1;
/* bad compression ratios */
if (BTRFS_I(inode)->flags & BTRFS_INODE_NOCOMPRESS)
return 0;
if (btrfs_test_opt(fs_info, COMPRESS) || if (btrfs_test_opt(fs_info, COMPRESS) ||
BTRFS_I(inode)->flags & BTRFS_INODE_COMPRESS || BTRFS_I(inode)->flags & BTRFS_INODE_COMPRESS ||
BTRFS_I(inode)->prop_compress) BTRFS_I(inode)->prop_compress)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册