public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Gerhard Wiesinger <lists@wiesinger.com>, linux-btrfs@vger.kernel.org
Subject: Re: BTRFS doesn't compress on the fly
Date: Fri, 1 Dec 2023 07:23:27 +1030	[thread overview]
Message-ID: <ccec2d73-98a7-4e73-a9ee-9be0fc2e1c92@gmx.com> (raw)
In-Reply-To: <ac521d3f-6575-4a72-a911-1991a2ca5f67@wiesinger.com>



On 2023/11/30 21:51, Gerhard Wiesinger wrote:
> Dear All,
>
> I created a new BTRFS volume with migrating an existing PostgreSQL
> database on it. Versions are recent.

Does the data base directory has something like NODATACOW or NODATASUM set?
The other possibility is preallocation, for the first write on
preallocated range, no matter if the compression is enabled, the write
would be treated as NOCOW.

>
> Compression is not done on the fly although everything is IMHO
> configured correctly to do so.
>
> I need to run the following command that everything gets compressed:
> btrfs filesystem defragment -r -v -czstd /var/lib/pgsql
>
> Had also a problem that
> chattr -R +c /var/lib/pgsql
> didn't work for some files.
>
> Find further details below.
>
> Looks like a bug to me.
>
> Any ideas?
>
> Thanx.
>
> Ciao,
> Gerhard
>
> uname -a
> Linux myhostname 6.5.12-300.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Nov
> 20 22:44:24 UTC 2023 x86_64 GNU/Linux
>
> btrfs --version
> btrfs-progs v6.5.1
>
> btrfs filesystem show
> Label: 'database'  uuid: 6ad6ef90-30fa-4979-9509-99803f7545aa
>          Total devices 1 FS bytes used 15.76GiB
>          devid    1 size 129.98GiB used 21.06GiB path /dev/mapper/datab
>
> btrfs filesystem df /var/lib/pgsql
> Data, single: total=19.00GiB, used=15.61GiB
> System, DUP: total=32.00MiB, used=16.00KiB
> Metadata, DUP: total=1.00GiB, used=151.92MiB
> GlobalReserve, single: total=85.38MiB, used=0.00B
>
> # Mounted via force
> findmnt -vno OPTIONS /var/lib/pgsql
> rw,relatime,compress-force=zstd:3,space_cache=v2,subvolid=5,subvol=/'
>
> # all files even have "c" attribute, set after creation of the filesystem
> lsattr /var/lib/pgsql
> --------c------------- /var/lib/pgsql/16
>
> # Should be empty and is empty, so everything has the comressed
> attribute (after creation and also all new files)
> lsattr -R /var/lib/pgsql | grep -v "^/" | grep -v "^$" | grep -v
> "^........c"
>
> # Stays here at this compression level
> compsize -x /var/lib/pgsql
> Processed 5332 files, 575858 regular extents (591204 refs), 40 inline.
> Type       Perc     Disk Usage   Uncompressed Referenced
> TOTAL       63%       51G          80G          80G
> none       100%       40G          40G          40G
> zstd        27%       10G          40G          40G
> prealloc   100%      5.0M         5.0M         5.5M

Not sure if the preallocation is the cause, but maybe you can try
disabling preallocation of postgresql?

As preallocation doesn't make that much sense on btrfs, there are too
many cases that can break the preallocation.

>
> # After running: btrfs filesystem defragment -r -v -czstd /var/lib/pgsql
> compsize -x /var/lib/pgsql
> Processed 5563 files, 664076 regular extents (664076 refs), 40 inline.
> Type       Perc     Disk Usage   Uncompressed Referenced
> TOTAL       19%       15G          80G          80G
> none       100%      120K         120K         120K
> zstd        19%       15G          80G          80G
>
> # At the first time creating the filesystem I had also the problem that
> I couln't change all attributes, didn't find a way to get rid of this.
> Any ideas.
> chattr -R +c /var/lib/pgsql
> chattr: Invalid argument while setting flags on

A lot of flags can only be set on empty files IIRC.

Thanks,
Qu

> /var/lib/pgsql/16/data/base/1/2836
> chattr: Invalid argument while setting flags on
> /var/lib/pgsql/16/data/base/1/2840
> chattr: Invalid argument while setting flags on
> /var/lib/pgsql/16/data/base/1/2838
> chattr: Invalid argument while setting flags on
> /var/lib/pgsql/16/data/base/4/2836
> chattr: Invalid argument while setting flags on
> /var/lib/pgsql/16/data/base/4/2838
> chattr: Invalid argument while setting flags on
> /var/lib/pgsql/16/data/base/5/2836
> chattr: Invalid argument while setting flags on
> /var/lib/pgsql/16/data/base/5/2838
>
>

  reply	other threads:[~2023-11-30 20:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-30 11:21 BTRFS doesn't compress on the fly Gerhard Wiesinger
2023-11-30 20:53 ` Qu Wenruo [this message]
2023-12-02 12:02   ` Gerhard Wiesinger
2023-12-02 20:07     ` Qu Wenruo
2023-12-02 21:56       ` Qu Wenruo
2023-12-03  8:24         ` Gerhard Wiesinger
2023-12-03  9:11           ` Qu Wenruo
2023-12-03  9:45             ` Gerhard Wiesinger
2023-12-03 10:19               ` Qu Wenruo
2023-12-22  5:58                 ` Gerhard Wiesinger
2023-12-22  6:13                   ` Qu Wenruo
2024-08-11  9:39                     ` Gerhard Wiesinger

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=ccec2d73-98a7-4e73-a9ee-9be0fc2e1c92@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=lists@wiesinger.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