|
|
Log in / Subscribe / Register

Some buffer-heads cleanup work

By Jake Edge
June 17, 2026

LSFMM+BPF

Jan Kara has been working on cleaning up how buffer heads are used by some kernel filesystems. In a short filesystem-track session at the 2026 Linux Storage, Filesystem, Memory Management, and BPF Summit, he gave an update on that work and where it is headed. Topics included generic infrastructure to track buffer heads for metadata, a buffer-head cleanup for the Amiga filesystem, and some planned locking fixes.

Buffer heads are "ancient stuff", he began, having been part of the kernel "basically since day zero of Linux". They are used to track filesystem information at the granularity of blocks, rather than folios. Kernel filesystem developers are trying to remove buffer heads from the data path in filesystems, but they are still used in the metadata path for many filesystems. Overall, buffer heads are not going away anytime soon because those filesystems need fine-grained tracking for the state of individual blocks.

[Jan Kara]

One of the things he has been working on is generic infrastructure for tracking all of the metadata blocks that belong to a given inode so that they can be flushed on an fsync() call. That infrastructure is used by ext4, ext2, UDF, VFAT, and a few others, he said. He factored the metadata-buffer-head tracking out of the generic inode structure and into the filesystem-private part of the inode that can be used by filesystems that care. Filesystems that do not need that tracking can have an inode that is 40 bytes smaller, he said. That work has been merged by Christian Brauner for the 7.1 kernel.

Kara also made a small cleanup for the Amiga Fast File System (AFFS) Linux implementation. The filesystem took the trouble to track the metadata buffer heads, but never used that information at fsync() time. Since the maintainer told him that AFFS performance is not really a concern, he removed the tracking instead of switching AFFS to use the new infrastructure.

There is a race in the tracking of the metadata buffer heads that can result in the inode and all of the metadata not being written to the backing store. So if an fsync() is followed by a crash, the metadata that should have been flushed to disk may be missing. That has been worked around for ext4, but all of the other filesystems using the new infrastructure are vulnerable to it. He is working on a generic fix, which will require expanding the structure used to track the metadata buffer heads.

He is also planning to rework the locking for buffer heads. There are two locks that protect buffer heads when they are attached to folios, he said; one is the folio lock (folio_lock()) for the folio it is attached to and the other is the private lock for the mapping (i_private_lock in struct address_space). The latter is used in places where the folio lock, which can sleep, cannot be taken, but he would like to stop using the private lock because it substantially complicates the locking; he would like to use read-copy-update (RCU) instead. He hopes to get that work done over the next year or less.

Christoph Hellwig asked about an "only vaguely related" problem where ext4 in data=journal mode can create dirty buffer heads that are detached from the mapping and "need magic handling". He wondered if Kara had any ideas on how to untangle that. Kara said that the problem can occur in other modes, but is more common with data=journal. It happens when the VFS would like to reclaim a block or folio, but the filesystem will not allow that to be done because it is still journaling the data, which puts the data into "a strange limbo state".

He has some ideas on what needs to be done. There are two paths where journaled buffer heads undergo writeback; one is the standard path that ends up at the block layer and works fine, but the other is in the journal path that simply writes the blocks tracked by the buffer heads without changing the state of the folios that contain them, which creates the problem. The fix is for the journal path to use the standard writeback machinery to write folios "instead of stealing the buffer heads from underneath", which "is a bit non-trivial of a rewrite of the journaling machinery", he said to some knowing laughter. He can provide pointers and some code to anyone who wants to tackle the problem.

Hellwig said that he has been working with Namjae Jeon on converting the exfat filesystem to use iomap for its data path. Since exfat is a "typical simple filesystem", that work could provide a good template to convert other filesystems to use iomap in a similar way, "because it's a recent conversion of a generic doesn't-do-anything-crazy filesystem". That work originally targeted the 7.1 merge window but ran into some problems; it should appear in 7.2. With no more topics to discuss, the session concluded.


Index entries for this article
KernelBlock layer/Buffer heads
ConferenceStorage, Filesystem, Memory-Management and BPF Summit/2026


to post comments

OT question about AFFS and other less used filesystems

Posted Jun 18, 2026 8:21 UTC (Thu) by rwmj (subscriber, #5474) [Link] (2 responses)

Really appreciate the quality and clarity of these articles. Very useful for people who are interested in what the kernel is up to but don't have time for watching conference proceedings or tracking every message on LKML.

About AFFS and similar filesystems, there was an earlier article about how some of these might be removed from the kernel (since they are a source of security issues, especially so in the brave new world of AI-generated reports). I guess from the article that AFFS is more actively maintained, but any news on what's happening in that space?

OT question about AFFS and other less used filesystems

Posted Jun 18, 2026 14:42 UTC (Thu) by josh (subscriber, #17465) [Link] (1 responses)

I know there's a lot of work going into some infrastructure to make it possible to build *fast* userspace filesystem implementations using FUSE and iomaps. I expect that once that work proves the concept, more filesystems may follow.

OT question about AFFS and other less used filesystems

Posted Jun 20, 2026 7:19 UTC (Sat) by jengelh (subscriber, #33263) [Link]

But you are also probably not going to use AFFS for billion-file multi-terabyte datasets either, so performing well is not a pressing need.


Copyright © 2026, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds