<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/btrfs/zlib.c, branch linux-rolling-lts</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-rolling-lts</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-rolling-lts'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2026-02-06T15:57:29Z</updated>
<entry>
<title>btrfs: zlib: fix the folio leak on S390 hardware acceleration</title>
<updated>2026-02-06T15:57:29Z</updated>
<author>
<name>Qu Wenruo</name>
</author>
<published>2026-01-19T05:54:04Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e80617a5e1c246da2f112a1a072cdd535046adfe'/>
<id>urn:sha1:e80617a5e1c246da2f112a1a072cdd535046adfe</id>
<content type='text'>
[ Upstream commit 0d0f1314e8f86f5205f71f9e31e272a1d008e40b ]

[BUG]
After commit aa60fe12b4f4 ("btrfs: zlib: refactor S390x HW acceleration
buffer preparation"), we no longer release the folio of the page cache
of folio returned by btrfs_compress_filemap_get_folio() for S390
hardware acceleration path.

[CAUSE]
Before that commit, we call kumap_local() and folio_put() after handling
each folio.

Although the timing is not ideal (it release previous folio at the
beginning of the loop, and rely on some extra cleanup out of the loop),
it at least handles the folio release correctly.

Meanwhile the refactored code is easier to read, it lacks the call to
release the filemap folio.

[FIX]
Add the missing folio_put() for copy_data_into_buffer().

CC: linux-s390@vger.kernel.org # 6.18+
Fixes: aa60fe12b4f4 ("btrfs: zlib: refactor S390x HW acceleration buffer preparation")
Reviewed-by: Boris Burkov &lt;boris@bur.io&gt;
Signed-off-by: Qu Wenruo &lt;wqu@suse.com&gt;
Reviewed-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>btrfs: add unlikely annotations to branches leading to EIO</title>
<updated>2025-09-23T06:49:26Z</updated>
<author>
<name>David Sterba</name>
</author>
<published>2025-09-17T17:53:55Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=cc53bd2085c8fa7b199a9a8e10e634b62a6d3fa8'/>
<id>urn:sha1:cc53bd2085c8fa7b199a9a8e10e634b62a6d3fa8</id>
<content type='text'>
The unlikely() annotation is a static prediction hint that compiler may
use to reorder code out of hot path. We use it elsewhere (namely
tree-checker.c) for error branches that almost never happen, where
EIO is one of them.

Reviewed-by: Filipe Manana &lt;fdmanana@suse.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
</content>
</entry>
<entry>
<title>btrfs: prepare zlib to support bs &gt; ps cases</title>
<updated>2025-09-23T06:49:25Z</updated>
<author>
<name>Qu Wenruo</name>
</author>
<published>2025-09-08T09:06:37Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e88cb48e6709d73fe9f82f2b56a43ac9ba2a1fe2'/>
<id>urn:sha1:e88cb48e6709d73fe9f82f2b56a43ac9ba2a1fe2</id>
<content type='text'>
This involves converting the following functions to use correct folio
sizes/shifts:

- zlib_compress_folios()
- zlib_decompress_bio()

There is a special handling for s390 hardware acceleration.
With bs &gt; ps cases, we can go with 16K block size on s390 (which uses
fixed 4K page size).
In that case we do not need to do the buffer copy as our folio is large
enough for hardware acceleration.

So factor out the s390 specific and folio size check into a helper,
need_special_buffer().

Signed-off-by: Qu Wenruo &lt;wqu@suse.com&gt;
Reviewed-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
</content>
</entry>
<entry>
<title>btrfs: prepare compression folio alloc/free for bs &gt; ps cases</title>
<updated>2025-09-23T06:49:24Z</updated>
<author>
<name>Qu Wenruo</name>
</author>
<published>2025-09-08T06:37:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c2ffb1ec1a7cfc754c1d2fe66d317f0aa4c0f1e6'/>
<id>urn:sha1:c2ffb1ec1a7cfc754c1d2fe66d317f0aa4c0f1e6</id>
<content type='text'>
This includes the following preparation for bs &gt; ps cases:

- Always alloc/free the folio directly if bs &gt; ps
  This adds a new @fs_info parameter for btrfs_alloc_compr_folio(), thus
  affecting all compression algorithms.

  For btrfs_free_compr_folio() it needs no parameter for now, as we can
  use the folio size to skip the caching part.

  For now the change is just to passing a @fs_info into the function,
  all the folio size assumption is still based on page size.

- Properly zero the last folio in compress_file_range()
  Since the compressed folios can be larger than a page, we need to
  properly zero the whole folio.

- Use correct folio size for btrfs_add_compressed_bio_folios()
  Instead of page size, use the correct folio size.

- Use correct folio size/shift for btrfs_compress_filemap_get_folio()
  As we are not only using simple page sized folios anymore.

- Use correct folio size for btrfs_decompress()
  There is an ASSERT() making sure the decompressed range is no larger
  than a page, which will be triggered for bs &gt; ps cases.

- Skip readahead for compressed pages
  Similar to subpage cases.

- Make btrfs_alloc_folio_array() to accept a new @order parameter

- Add a helper to calculate the minimal folio size

All those changes should not affect the existing bs &lt;= ps handling.

Signed-off-by: Qu Wenruo &lt;wqu@suse.com&gt;
Reviewed-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
</content>
</entry>
<entry>
<title>btrfs: reduce compression workspace buffer space to block size</title>
<updated>2025-09-23T06:49:16Z</updated>
<author>
<name>Qu Wenruo</name>
</author>
<published>2025-08-14T01:14:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=74e8f002b772686408d62e420d9f70a4bcb1c2c4'/>
<id>urn:sha1:74e8f002b772686408d62e420d9f70a4bcb1c2c4</id>
<content type='text'>
Currently the compression workspace buffer size is always based on
PAGE_SIZE, but btrfs has support subpage sized block size for some time.

This means for one-shot compression algorithm like lzo, we're wasting
quite some memory if the block size is smaller than page size, as the
LZO only works on one block (thus one-shot).

On 64K page sized systems with 4K block size, it means we only need at
most 8K buffer space for lzo, but in reality we're allocating 64K
buffer.

So to reduce the memory usage, change all workspace buffer to base its
size based on block size other than page size.

Signed-off-by: Qu Wenruo &lt;wqu@suse.com&gt;
Reviewed-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
</content>
</entry>
<entry>
<title>btrfs: rename btrfs_compress_op to btrfs_compress_levels</title>
<updated>2025-09-23T06:49:16Z</updated>
<author>
<name>Qu Wenruo</name>
</author>
<published>2025-08-14T01:05:23Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0d0b80929eff93e7e0323060899d04905b8e6de9'/>
<id>urn:sha1:0d0b80929eff93e7e0323060899d04905b8e6de9</id>
<content type='text'>
Since all workspace managers are per-fs, there is no need nor no way to
store them inside btrfs_compress_op::wsm anymore.

With that said, we can do the following modifications:

- Remove zstd_workspace_mananger::ops
  Zstd always grab the global btrfs_compress_op[].
- Remove btrfs_compress_op::wsm member
- Rename btrfs_compress_op to btrfs_compress_levels

This should make it more clear that btrfs_compress_levels structures are
only to indicate the levels of each compress algorithm.

Signed-off-by: Qu Wenruo &lt;wqu@suse.com&gt;
Reviewed-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
</content>
</entry>
<entry>
<title>btrfs: cleanup the per-module compression workspace managers</title>
<updated>2025-09-23T06:49:16Z</updated>
<author>
<name>Qu Wenruo</name>
</author>
<published>2025-08-14T00:59:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9c8f4cf45651b8f07bd06df443871d526dc53cea'/>
<id>urn:sha1:9c8f4cf45651b8f07bd06df443871d526dc53cea</id>
<content type='text'>
Since all workspaces are handled by the per-fs workspace managers, we
can safely remove the old per-module managers.

Signed-off-by: Qu Wenruo &lt;wqu@suse.com&gt;
Reviewed-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
</content>
</entry>
<entry>
<title>btrfs: add an fs_info parameter for compression workspace manager</title>
<updated>2025-09-23T06:49:15Z</updated>
<author>
<name>Qu Wenruo</name>
</author>
<published>2025-08-13T05:03:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=2c5cca03c1738e1342cbe57671d463f275c00623'/>
<id>urn:sha1:2c5cca03c1738e1342cbe57671d463f275c00623</id>
<content type='text'>
[BACKGROUND]
Currently btrfs shares workspaces and their managers for all filesystems,
this is mostly fine as all those workspaces are using page size based
buffers, and btrfs only support block size (bs) &lt;= page size (ps).

This means even if bs &lt; ps, we at most waste some buffer space in the
workspace, but everything will still work fine.

The problem here is that is limiting our support for bs &gt; ps cases.

As now a workspace now may need larger buffer to handle bs &gt; ps cases,
but since the pool has no way to distinguish different workspaces, a
regular workspace (which is still using buffer size based on ps) can be
passed to a btrfs whose bs &gt; ps.

In that case the buffer is not large enough, and will cause various
problems.

[ENHANCEMENT]
To prepare for the per-fs workspace migration, add an fs_info parameter
to all workspace related functions.

For now this new fs_info parameter is not yet utilized.

Signed-off-by: Qu Wenruo &lt;wqu@suse.com&gt;
Reviewed-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
</content>
</entry>
<entry>
<title>btrfs: use blocksize to check if compression is making things larger</title>
<updated>2025-09-22T08:54:31Z</updated>
<author>
<name>Qu Wenruo</name>
</author>
<published>2025-08-11T00:13:42Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0a6dcd42353b96ab4a74796aed1541591de5890c'/>
<id>urn:sha1:0a6dcd42353b96ab4a74796aed1541591de5890c</id>
<content type='text'>
[BEHAVIOR DIFFERENCE BETWEEN COMPRESSION ALGOS]
Currently LZO compression algorithm will check if we're making the
compressed data larger after compressing more than 2 blocks.

But zlib and zstd do the same checks after compressing more than 8192
bytes.

This is not a big deal, but since we're already supporting larger block
size (e.g. 64K block size if page size is also 64K), this check is not
suitable for all block sizes.

For example, if our page and block size are both 16KiB, and after the
first block compressed using zlib, the resulted compressed data is
slightly  larger than 16KiB, we will immediately abort the compression.

This makes zstd and zlib compression algorithms to behave slightly
different from LZO, which only aborts after compressing two blocks.

[ENHANCEMENT]
To unify the behavior, only abort the compression after compressing at
least two blocks.

Reviewed-by: Anand Jain &lt;anand.jain@oracle.com&gt;
Signed-off-by: Qu Wenruo &lt;wqu@suse.com&gt;
Reviewed-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
</content>
</entry>
<entry>
<title>btrfs: pass btrfs_inode pointer directly into btrfs_compress_folios()</title>
<updated>2025-09-22T08:54:31Z</updated>
<author>
<name>Qu Wenruo</name>
</author>
<published>2025-08-10T10:44:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d71b419f274c2eea83038c8623ddc45d51af70e9'/>
<id>urn:sha1:d71b419f274c2eea83038c8623ddc45d51af70e9</id>
<content type='text'>
For the 3 supported compression algorithms, two of them (zstd and zlib)
are already grabbing the btrfs inode for error messages.

It's more common to pass btrfs_inode and grab the address space from it.

Reviewed-by: Anand Jain &lt;anand.jain@oracle.com&gt;
Signed-off-by: Qu Wenruo &lt;wqu@suse.com&gt;
Reviewed-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
</content>
</entry>
</feed>
