Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Zygo Blaxell <ce3g8jdj@umail.furryterror.org>
To: Nemcev Aleksey <Nemcev_Aleksey@inbox.ru>
Cc: Chris Murphy <lists@colorremedies.com>,
	Btrfs BTRFS <linux-btrfs@vger.kernel.org>
Subject: Re: compsize reports that filesystem uses zlib compression, while I set zstd compression everywhere
Date: Wed, 26 Oct 2022 21:03:20 -0400	[thread overview]
Message-ID: <Y1nY2FJGYS+iWMcS@hungrycats.org> (raw)
In-Reply-To: <fa62c9cb-0fe9-b838-3f69-477dc61dbd45@inbox.ru>

On Thu, Oct 27, 2022 at 01:29:35AM +0300, Nemcev Aleksey wrote:
> 26.10.2022 22:07, Chris Murphy пишет:
> > 
> > On Wed, Oct 26, 2022, at 6:21 AM, Nemcev Aleksey wrote:
> > > Hello.
> > > 
> > > Recently I decided to compress the existing Btrfs volume with zstd.
> > > 
> > > To do this, I set property `compression=zstd` for all subvolumes to
> > > compress new files with the default zstd:3 compression level.
> > > 
> > > Then I run `btrfs filesystem defragment -c zstd:12 -v -r` on all
> > > subvolumes to compress existing files using zstd:12 compression level
> > > (to spend more time now and save more space later, but don't want to
> > > keep slow zstd:12 level all the time).
> > > 
> > > After defragment, I run `btrfs filesystem balance` on all subvolumes to
> > > make Btrfs happy.
> > > 
> > > And after all, I run `compsize` on the root subvolume to check the
> > > compression ratio, and compsize shows me the following:
> > > Processed 1100578 files, 1393995 regular extents (1649430 refs), 666312
> > > inline.
> > > Type      Perc    Disk Usage  Uncompressed Referenced
> > > TOTAL      77%     169G        217G        226G
> > > none      100%      99G         99G        100G
> > > zlib       52%      54G        102G        109G
> > > zstd       19%      12M         65M         66M
> > > prealloc  100%      15G         15G         16G
> > > 
> > > I'm very confused why almost all compressed data is compressed with zlib
> > > while I haven't used zlib at any step.
> > > Why do compsize reports this?
> > > Should I worry about this? It seems zstd offers a much faster
> > > decompression speed than zlib.
> > > Thank you.
> > 
> > If you use chattr +c anywhere, it uses the btrfs default compression algo which is zlib. There is a way to set a compression algo property, but I'm uncertain if the kernel honors it.
> > 
> > So you'll want to recursively remove the compression file attribute. I'm not sure it's worth recompressing but you can use defrag -z for that.
> > 
> Thank you for the idea, I understood where I failed.
> 
> `btrfs filesystem defragment -c zstd -r /` is not correct command, but
> `btrfs filesystem defragment -czstd -r /` is correct one (note the space).
> 
> And the first command will try to defragment the file named zstd using
> default compression (zlib), not the compression from the `compression`
> subvolume property.
> 
> And also it's not possible to specify compression level in defragment - so,
> I'll change the level in subvolume properties, defragment with -czstd, and
> change the level back.

It's not possible to set the level in subvol properties either.  Only the
compress= mount option can set the level.

  reply	other threads:[~2022-10-27  1:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-26 10:21 compsize reports that filesystem uses zlib compression, while I set zstd compression everywhere Nemcev Aleksey
2022-10-26 19:07 ` Chris Murphy
2022-10-26 22:29   ` Nemcev Aleksey
2022-10-27  1:03     ` Zygo Blaxell [this message]
2022-10-27 13:21       ` Chris Murphy
2022-10-27 14:32         ` Zygo Blaxell

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=Y1nY2FJGYS+iWMcS@hungrycats.org \
    --to=ce3g8jdj@umail.furryterror.org \
    --cc=Nemcev_Aleksey@inbox.ru \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=lists@colorremedies.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