<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/btrfs/misc.h, 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-03-12T11:09:31Z</updated>
<entry>
<title>btrfs: define the AUTO_KFREE/AUTO_KVFREE helper macros</title>
<updated>2026-03-12T11:09:31Z</updated>
<author>
<name>Miquel Sabaté Solà</name>
</author>
<published>2025-10-24T10:21:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4b508c53f3c50d8d85985214077a71778478c2cc'/>
<id>urn:sha1:4b508c53f3c50d8d85985214077a71778478c2cc</id>
<content type='text'>
[ Upstream commit d00cbce0a7d5de5fc31bf60abd59b44d36806b6e ]

These are two simple macros which ensure that a pointer is initialized
to NULL and with the proper cleanup attribute for it.

Signed-off-by: Miquel Sabaté Solà &lt;mssola@mssola.com&gt;
Reviewed-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
Stable-dep-of: 52ee9965d09b ("btrfs: zoned: fixup last alloc pointer after extent removal for RAID0/10")
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>btrfs: introduce btrfs_bio_for_each_block_all() helper</title>
<updated>2025-09-23T06:49:17Z</updated>
<author>
<name>Qu Wenruo</name>
</author>
<published>2025-09-02T07:15:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7425a2894019778460e65d24e8adfaeddac3b3b1'/>
<id>urn:sha1:7425a2894019778460e65d24e8adfaeddac3b3b1</id>
<content type='text'>
Currently if we want to iterate all blocks inside a bio, we do something
like this:

	bio_for_each_segment_all(bvec, bio, iter_all) {
		for (off = 0; off &lt; bvec-&gt;bv_len; off += sectorsize) {
			/* Iterate blocks using bv + off */
		}
	}

That's fine for now, but it will not handle future bs &gt; ps, as
bio_for_each_segment_all() is a single-page iterator, it will always
return a bvec that's no larger than a page.

But for bs &gt; ps cases, we need a full folio (which covers at least one
block) so that we can work on the block.

To address this problem and handle future bs &gt; ps cases better:

- Introduce a helper btrfs_bio_for_each_block_all()
  This helper will create a local bvec_iter, which has the size of the
  target bio. Then grab the current physical address of the current
  location, then advance the iterator by block size.

- Use btrfs_bio_for_each_block_all() to replace existing call sites
  Including:

  * set_bio_pages_uptodate() in raid56
  * verify_bio_data_sectors() in raid56

  Both will result much easier to read code.

Signed-off-by: Qu Wenruo &lt;wqu@suse.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
</content>
</entry>
<entry>
<title>btrfs: introduce btrfs_bio_for_each_block() helper</title>
<updated>2025-09-23T06:49:17Z</updated>
<author>
<name>Qu Wenruo</name>
</author>
<published>2025-09-02T05:21:49Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9afc617265383f591614e94b702d558dfb1519c0'/>
<id>urn:sha1:9afc617265383f591614e94b702d558dfb1519c0</id>
<content type='text'>
Currently if we want to iterate a bio in block unit, we do something
like this:

	while (iter-&gt;bi_size) {
		struct bio_vec bv = bio_iter_iovec();

		/* Do something with using the bv */

		bio_advance_iter_single(&amp;bbio-&gt;bio, iter, sectorsize);
	}

That's fine for now, but it will not handle future bs &gt; ps, as
bio_iter_iovec() returns a single-page bvec, meaning the bv_len will not
exceed page size.

This means the code using that bv can only handle a block if bs &lt;= ps.

To address this problem and handle future bs &gt; ps cases better:

- Introduce a helper btrfs_bio_for_each_block()
  Instead of bio_vec, which has single and multiple page version and
  multiple page version has quite some limits, use my favorite way to
  represent a block, phys_addr_t.

  For bs &lt;= ps cases, nothing is changed, except we will do a very
  small overhead to convert phys_addr_t to a folio, then use the proper
  folio helpers to handle the possible highmem cases.

  For bs &gt; ps cases, all blocks will be backed by large folios, meaning
  every folio will cover at least one block. And still use proper folio
  helpers to handle highmem cases.

  With phys_addr_t, we will handle both large folio and highmem
  properly. So there is no better single variable to present a btrfs
  block than phys_addr_t.

- Extract the data block csum calculation into a helper
  The new helper, btrfs_calculate_block_csum() will be utilized by
  btrfs_csum_one_bio().

- Use btrfs_bio_for_each_block() to replace existing call sites
  Including:

  * index_one_bio() from raid56.c
    Very straight-forward.

  * btrfs_check_read_bio()
    Also update repair_one_sector() to grab the folio using phys_addr_t,
    and do extra checks to make sure the folio covers at least one
    block.
    We do not need to bother bv_len at all now.

  * btrfs_csum_one_bio()
    Now we can move the highmem handling into a dedicated helper,
    calculate_block_csum(), and use btrfs_bio_for_each_block() helper.

There is one exception in btrfs_decompress_buf2page(), which is copying
decompressed data into the original bio, which is not iterating using
block size thus we don't need to bother.

Signed-off-by: Qu Wenruo &lt;wqu@suse.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
</content>
</entry>
<entry>
<title>btrfs: add helper folio_end()</title>
<updated>2025-07-21T21:58:01Z</updated>
<author>
<name>David Sterba</name>
</author>
<published>2025-06-10T12:17:53Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=89a3cc19e4e4158b3ffd746918227bc409f91e12'/>
<id>urn:sha1:89a3cc19e4e4158b3ffd746918227bc409f91e12</id>
<content type='text'>
There are several cases of folio_pos + folio_size, add a convenience
helper for that. This is a local helper and not proposed as folio API
because it does not seem to be heavily used elsewhere:

A quick grep (folio_size + folio_end) in fs/ shows

     24 btrfs
      4 iomap
      4 ext4
      2 xfs
      2 netfs
      1 gfs2
      1 f2fs
      1 bcachefs
      1 buffer.c

Reviewed-by: Johannes Thumshirn &lt;johannes.thumshirn@wdc.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
</content>
</entry>
<entry>
<title>btrfs: use rb_find_add() in rb_simple_insert()</title>
<updated>2025-07-21T21:53:26Z</updated>
<author>
<name>Pan Chuang</name>
</author>
<published>2025-05-16T03:03:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=46d549928cc93f9b08fd66d0ff7778e800bb17f3'/>
<id>urn:sha1:46d549928cc93f9b08fd66d0ff7778e800bb17f3</id>
<content type='text'>
Use the rb-tree helper so we don't open code the search and insert
code.

Signed-off-by: Pan Chuang &lt;panchuang@vivo.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 struct rb_simple_node pointer directly in rb_simple_insert()</title>
<updated>2025-07-21T21:53:26Z</updated>
<author>
<name>Pan Chuang</name>
</author>
<published>2025-05-16T03:03:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c52ea14d0544cfcd3c76ac9e3ce8ca16832cc033'/>
<id>urn:sha1:c52ea14d0544cfcd3c76ac9e3ce8ca16832cc033</id>
<content type='text'>
Replace struct embedding with union to enable safe type conversion in
btrfs_backref_node, tree_block and mapping_node.

Adjust function calls to use the new unified API, eliminating redundant
parameters.

Signed-off-by: Pan Chuang &lt;panchuang@vivo.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: constify pointer parameters where applicable</title>
<updated>2024-07-11T13:33:22Z</updated>
<author>
<name>David Sterba</name>
</author>
<published>2024-05-30T17:14:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=2917f74102cf23afe770c1293aabce005f956b4f'/>
<id>urn:sha1:2917f74102cf23afe770c1293aabce005f956b4f</id>
<content type='text'>
We can add const to many parameters, this is for clarity and minor
addition to safety. There are some minor effects, in the assembly
code and .ko measured on release config. This patch does not cover all
possible conversions.

Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
</content>
</entry>
<entry>
<title>btrfs: add forward declarations and headers, part 2</title>
<updated>2024-03-04T15:24:49Z</updated>
<author>
<name>David Sterba</name>
</author>
<published>2024-01-27T02:19:56Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=602035d7fecf4d00c75c2ca5b956fa44136c3b86'/>
<id>urn:sha1:602035d7fecf4d00c75c2ca5b956fa44136c3b86</id>
<content type='text'>
Do a cleanup in more headers:

- add forward declarations for types referenced by pointers
- add includes when types need them

This fixes potential compilation problems if the headers are reordered
or the missing includes are not provided indirectly.

Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
</content>
</entry>
<entry>
<title>minmax: add in_range() macro</title>
<updated>2023-08-24T23:20:18Z</updated>
<author>
<name>Matthew Wilcox (Oracle)</name>
</author>
<published>2023-08-02T15:13:29Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f9bff0e31881d03badf191d3b0005839391f5f2b'/>
<id>urn:sha1:f9bff0e31881d03badf191d3b0005839391f5f2b</id>
<content type='text'>
Patch series "New page table range API", v6.

This patchset changes the API used by the MM to set up page table entries.
The four APIs are:

    set_ptes(mm, addr, ptep, pte, nr)
    update_mmu_cache_range(vma, addr, ptep, nr)
    flush_dcache_folio(folio) 
    flush_icache_pages(vma, page, nr)

flush_dcache_folio() isn't technically new, but no architecture
implemented it, so I've done that for them.  The old APIs remain around
but are mostly implemented by calling the new interfaces.

The new APIs are based around setting up N page table entries at once. 
The N entries belong to the same PMD, the same folio and the same VMA, so
ptep++ is a legitimate operation, and locking is taken care of for you. 
Some architectures can do a better job of it than just a loop, but I have
hesitated to make too deep a change to architectures I don't understand
well.

One thing I have changed in every architecture is that PG_arch_1 is now a
per-folio bit instead of a per-page bit when used for dcache clean/dirty
tracking.  This was something that would have to happen eventually, and it
makes sense to do it now rather than iterate over every page involved in a
cache flush and figure out if it needs to happen.

The point of all this is better performance, and Fengwei Yin has measured
improvement on x86.  I suspect you'll see improvement on your architecture
too.  Try the new will-it-scale test mentioned here:
https://lore.kernel.org/linux-mm/20230206140639.538867-5-fengwei.yin@intel.com/
You'll need to run it on an XFS filesystem and have
CONFIG_TRANSPARENT_HUGEPAGE set.

This patchset is the basis for much of the anonymous large folio work
being done by Ryan, so it's received quite a lot of testing over the last
few months.


This patch (of 38):

Determine if a value lies within a range more efficiently (subtraction +
comparison vs two comparisons and an AND).  It also has useful (under some
circumstances) behaviour if the range exceeds the maximum value of the
type.  Convert all the conflicting definitions of in_range() within the
kernel; some can use the generic definition while others need their own
definition.

Link: https://lkml.kernel.org/r/20230802151406.3735276-1-willy@infradead.org
Link: https://lkml.kernel.org/r/20230802151406.3735276-2-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) &lt;willy@infradead.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>btrfs: export bitmap_test_range_all_{set,zero}</title>
<updated>2023-06-19T11:59:22Z</updated>
<author>
<name>Naohiro Aota</name>
</author>
<published>2023-04-25T15:19:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b5345d6ceeee3ef378e4800f538c8fc06bf9de48'/>
<id>urn:sha1:b5345d6ceeee3ef378e4800f538c8fc06bf9de48</id>
<content type='text'>
bitmap_test_range_all_{set,zero} defined in subpage.c are useful for other
components. Move them to misc.h and use them in zoned.c. Also, as
find_next{,_zero}_bit take/return "unsigned long" instead of "unsigned
int", convert the type to "unsigned long".

While at it, also rewrite the "if (...) return true; else return false;"
pattern and add const to the input bitmap.

Signed-off-by: Naohiro Aota &lt;naohiro.aota@wdc.com&gt;
Reviewed-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
</content>
</entry>
</feed>
