linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roman Mamedov <rm@romanrm.net>
To: Anand Jain <anand.jain@oracle.com>
Cc: dsterba@suse.cz, Timofey Titovets <nefelim4ag@gmail.com>,
	linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v3] Btrfs: add skeleton code for compression heuristic
Date: Fri, 21 Jul 2017 23:37:49 +0500	[thread overview]
Message-ID: <20170721233749.5175d611@natsu> (raw)
In-Reply-To: <f85d6fa7-4d1e-bfb8-7e64-ef02c468e42d@oracle.com>

On Fri, 21 Jul 2017 13:00:56 +0800
Anand Jain <anand.jain@oracle.com> wrote:

> 
> 
> On 07/18/2017 02:30 AM, David Sterba wrote:
> > So it basically looks good, I could not resist and rewrote the changelog
> > and comments. There's one code fix:
> > 
> > On Mon, Jul 17, 2017 at 04:52:58PM +0300, Timofey Titovets wrote:
> >> -static inline int inode_need_compress(struct inode *inode)
> >> +static inline int inode_need_compress(struct inode *inode, u64 start, u64 end)
> >>   {
> >>   	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
> >>
> >>   	/* force compress */
> >>   	if (btrfs_test_opt(fs_info, FORCE_COMPRESS))
> >> -		return 1;
> >> +		return btrfs_compress_heuristic(inode, start, end);
> 
> 
> 
> > This must stay 'return 1', if force-compress is on, so the change is
> > reverted.
> 
>   Initially I thought 'return 1' is correct, but looking in depth,
>   it is not correct as below..
> 
>   The biggest beneficiary of the estimating the compression ratio
>   in advance (heuristic) is when customers are using the
>   -o compress-force. But 'return 1' here is making them not to
>   use heuristic. So definitely something is wrong.

man mount says for btrfs:

    If compress-force is specified, all files will be compressed,  whether
    or  not they compress well.

So compress-force by definition should always compress all files no matter
what, and not use any heuristic. In fact it has no right to, as user forced
compression to always on. Returning 1 up there does seem right to me.

>   -o compress is about the whether each of the compression-granular bytes
>   (BTRFS_MAX_UNCOMPRESSED) of the inode should be tried to compress OR
>   just give up for the whole inode by looking at the compression ratio
>   of the current compression-granular.
>   This approach can be overridden by -o compress-force. So in
>   -o compress-force there will be a lot more efforts in _trying_
>   to compression than in -o compress. We must use heuristic for
>   -o compress-force.

Semantic and the user expectation of compress-force dictates to always
compress without giving up, even if it turns out to be slower and not providing
much benefit.

-- 
With respect,
Roman

  reply	other threads:[~2017-07-21 18:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-17 13:52 [PATCH v3] Btrfs: add skeleton code for compression heuristic Timofey Titovets
2017-07-17 18:30 ` David Sterba
2017-07-21  5:00   ` Anand Jain
2017-07-21 18:37     ` Roman Mamedov [this message]
2017-07-21 21:00       ` Adam Borowski
2017-07-22  0:52         ` Anand Jain
2017-07-24 14:53         ` David Sterba
2017-07-24 15:40           ` Anand Jain
2017-07-27 15:36             ` David Sterba
2017-07-28 14:04               ` Anand Jain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170721233749.5175d611@natsu \
    --to=rm@romanrm.net \
    --cc=anand.jain@oracle.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nefelim4ag@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).