I noticed a few days ago that btrfs fi defrag -cXXX can not be used to compress files unless they are fragmented. The attached patch passes the compression flag to should_defrag_range, where it disables the adjacent-extent and extent size checks if set. The inline/sparse extent check is not modified - I assumed it would not be useful to compress inline extents.
-- Andrew Mahone andrew DOT mahone AT gmail DOT com\
btrfs_defrag_compress.patch
Description: Binary data