On 07/18/2017 02:46 AM, David Sterba wrote:
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).
There is a hidden workaround... even with the existing inode_need_compression(). BTRFS_INODE_NOCOMPRESS gets reset [1] so .. (btrfs prop set /btrfs/sv1 compression "") btrfs prop set /btrfs/sv1 compression lzo A normal defrag or with -c will try to compress again. ---------------- static int prop_compression_apply(struct inode *inode, const char *value, size_t len) { int type; if (len == 0) { BTRFS_I(inode)->flags |= BTRFS_INODE_NOCOMPRESS; BTRFS_I(inode)->flags &= ~BTRFS_INODE_COMPRESS; BTRFS_I(inode)->force_compress = BTRFS_COMPRESS_NONE; return 0; } if (!strncmp("lzo", value, len)) type = BTRFS_COMPRESS_LZO; else if (!strncmp("zlib", value, len)) type = BTRFS_COMPRESS_ZLIB; else return -EINVAL; BTRFS_I(inode)->flags &= ~BTRFS_INODE_NOCOMPRESS; <---- [1] BTRFS_I(inode)->flags |= BTRFS_INODE_COMPRESS; BTRFS_I(inode)->force_compress = type; return 0; } --------------- So what's missing is btrfs prop set /btrfs/sv1 compress-force and rest cleanup as discussed in the other email. Thanks, Anand -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html