-----Original Message-----
> From: linux-btrfs-ow...@vger.kernel.org <linux-btrfs-
> ow...@vger.kernel.org> On Behalf Of Nikolay Borisov
> Sent: Thursday, 20 December 2018 9:44 PM
> To: Qu Wenruo <quwenruo.bt...@gmx.com>; devz...@web.de; linux-
> bt...@vger.kernel.org
> Subject: Re: compress-force not really forcing compression?
> 
> 
> 
> On 20.12.18 г. 2:57 ч., Qu Wenruo wrote:
> >
> >
> > On 2018/12/19 下午11:41, devz...@web.de wrote:
> >> does compress-force really force compression?
> >
> > It should.
> >
> > The only exception is block size.
> >
> > If the file is smaller than the sector size (4K for x86_64), then no
> > compression no matter whatever the mount options are.
> 
> What FORCE_COMPRESS does is it ensures that compression is always tried
> for a file (check code in compress_file_range in the if (pages) branch).
> However, if btrfs_compress_pages detects compression makes no
> difference then 'if (pages)'  branch is executed since will_compress will not
> be set and only thing it will be do is not set BTRFS_INODE_NOCOMPRESS.
> 
> What this all means is that with FORCE_COMPRESS future writes will also be
> tried to be compressed. For example if you do some non-compressible
> writes on a file with no FORCE_COMPRESS then
> BTRFS_INODE_NOCOMPRESS will be set. This means that all future
> invocation of inode_need_compress for this inode will return false. So if at a
> later time the io pattern changes to one which is compressible then it wont'
> be compressed.
> 
> OTOH with force-compress you will also be compressing those portions of
> the file which are compressible.
> 
> IMHO the more pertinent question is :
> 
> If a file has portions which are not easily compressible does that imply all
> future writes are also incompressible. IMO no, so I think what will be prudent
> is remove FORCE_COMPRESS altogether and make the code act as if it's
> always on.
> 
> Any opinions?


That is a good idea. If I turn on compression I would expect everything to be 
compressed, except in cases where there is no size benefit.

Reply via email to