Btrfs Change Coming For Linux 7.2 Yields Very Healthy Performance Gain
([Linux Storage] 5 Hours Ago
Direct I/O)
- Reference: 0001636564
- News link: https://www.phoronix.com/news/Btrfs-No-Serialize-Direct-IO
- Source link:
A change coming on the way for the upcoming [1]Linux 7.2 kernel cycle is yielding a significant improvement to the direct I/O write performance. While a big gain, technically it's a regression fix after a change mistakenly dropped the behavior several years ago.
The change on its way to Linux 7.2 for Btrfs is to not force Direct I/O (DIO) writes to be serialized. Mark Harmstone with Meta discovered that Btrfs was mistakenly serializing DIO writes since 2023 when [2]converting the file-system over to the new mount API for the Linux kernel . Harmstone explained with [3]the change :
"Before btrfs switched to the new mount API in 2023, we were setting SB_NOSEC in btrfs_mount_root(). This flag tells the VFS that the filesystem may have files which don't have security xattrs, enabling it to do some optimizations.
Unfortunately this was missed in the transition, meaning that IS_NOSEC will always return false for a btrfs inode. This means that btrfs_direct_write() calls will always get the inode lock exclusively, meaning that DIO writes to the same file will be serialized.
On my machine, this one-line change results in a ~59% improvement in DIO throughput."
A very nice win with nearly 60% throughput improvement from 826 MB/s to 1311 MB/s.
Intel's Kernel Test Robot is also [4]reporting around a 12% improvement for Btrfs with this change in their own test and hardware.
With the patch now in the "-next" code, look for this Btrfs change to land with the Linux 7.2 merge window happening in June.
[1] https://www.phoronix.com/search/Linux+7.2
[2] https://www.phoronix.com/news/Btrfs-New-Mount-API-Linux-6.8
[3] https://www.phoronix.com/news/Btrfs-No-Serialize-Direct-IO
[4] https://lore.kernel.org/all/202605291631.659bf248-lkp@intel.com/
The change on its way to Linux 7.2 for Btrfs is to not force Direct I/O (DIO) writes to be serialized. Mark Harmstone with Meta discovered that Btrfs was mistakenly serializing DIO writes since 2023 when [2]converting the file-system over to the new mount API for the Linux kernel . Harmstone explained with [3]the change :
"Before btrfs switched to the new mount API in 2023, we were setting SB_NOSEC in btrfs_mount_root(). This flag tells the VFS that the filesystem may have files which don't have security xattrs, enabling it to do some optimizations.
Unfortunately this was missed in the transition, meaning that IS_NOSEC will always return false for a btrfs inode. This means that btrfs_direct_write() calls will always get the inode lock exclusively, meaning that DIO writes to the same file will be serialized.
On my machine, this one-line change results in a ~59% improvement in DIO throughput."
A very nice win with nearly 60% throughput improvement from 826 MB/s to 1311 MB/s.
Intel's Kernel Test Robot is also [4]reporting around a 12% improvement for Btrfs with this change in their own test and hardware.
With the patch now in the "-next" code, look for this Btrfs change to land with the Linux 7.2 merge window happening in June.
[1] https://www.phoronix.com/search/Linux+7.2
[2] https://www.phoronix.com/news/Btrfs-New-Mount-API-Linux-6.8
[3] https://www.phoronix.com/news/Btrfs-No-Serialize-Direct-IO
[4] https://lore.kernel.org/all/202605291631.659bf248-lkp@intel.com/