Linux kernel source tree
Find a file
David Disseldorp 5467e85508
gen_init_cpio: add -a <data_align> as reflink optimization
As described in buffer-format.rst, the existing initramfs.c extraction
logic works fine if the cpio filename field is padded out with trailing
zeros, with a caveat that the padded namesize can't exceed PATH_MAX.

Add filename zero-padding logic to gen_init_cpio, which can be triggered
via the new -a <data_align> parameter. Performance and storage
utilization is improved for Btrfs and XFS workloads, as copy_file_range
can reflink the entire source file into a filesystem block-size aligned
destination offset within the cpio archive.

Btrfs benchmarks run on 6.15.8-1-default (Tumbleweed) x86_64 host:
  > truncate --size=2G /tmp/backing.img
  > /sbin/mkfs.btrfs /tmp/backing.img
  ...
  Sector size:        4096        (CPU page size: 4096)
  ...
  > sudo mount /tmp/backing.img mnt
  > sudo chown $USER mnt
  > cd mnt
  mnt> dd if=/dev/urandom of=foo bs=1M count=20 && cat foo >/dev/null
  ...
  mnt> echo "file /foo foo 0755 0 0" > list
  mnt> perf stat -r 10 gen_init_cpio -o unaligned_btrfs list
  ...
            0.023496 +- 0.000472 seconds time elapsed  ( +-  2.01% )

  mnt> perf stat -r 10 gen_init_cpio -o aligned_btrfs -a 4096 list
  ...
           0.0010010 +- 0.0000565 seconds time elapsed  ( +-  5.65% )

  mnt> /sbin/xfs_io -c "fiemap -v" unaligned_btrfs
  unaligned_btrfs:
   EXT: FILE-OFFSET      BLOCK-RANGE      TOTAL FLAGS
     0: [0..40967]:      695040..736007   40968   0x1
  mnt> /sbin/xfs_io -c "fiemap -v" aligned_btrfs
  aligned_btrfs:
   EXT: FILE-OFFSET      BLOCK-RANGE      TOTAL FLAGS
     0: [0..7]:          26768..26775         8   0x0
     1: [8..40967]:      269056..310015   40960 0x2000
     2: [40968..40975]:  26776..26783         8   0x1
  mnt> /sbin/btrfs fi du unaligned_btrfs aligned_btrfs
       Total   Exclusive  Set shared  Filename
    20.00MiB    20.00MiB       0.00B  unaligned_btrfs
    20.01MiB     8.00KiB    20.00MiB  aligned_btrfs

XFS benchmarks run on same host:
  > sudo umount mnt && rm /tmp/backing.img
  > truncate --size=2G /tmp/backing.img
  > /sbin/mkfs.xfs /tmp/backing.img
  ...
           =                       reflink=1    ...
  data     =                       bsize=4096   blocks=524288, imaxpct=25
  ...
  > sudo mount /tmp/backing.img mnt
  > sudo chown $USER mnt
  > cd mnt
  mnt> dd if=/dev/urandom of=foo bs=1M count=20 && cat foo >/dev/null
  ...
  mnt> echo "file /foo foo 0755 0 0" > list
  mnt> perf stat -r 10 gen_init_cpio -o unaligned_xfs list
  ...
            0.011069 +- 0.000469 seconds time elapsed  ( +-  4.24% )

  mnt> perf stat -r 10 gen_init_cpio -o aligned_xfs -a 4096 list
  ...
            0.001273 +- 0.000288 seconds time elapsed  ( +- 22.60% )

  mnt> /sbin/xfs_io -c "fiemap -v" unaligned_xfs
   unaligned_xfs:
   EXT: FILE-OFFSET      BLOCK-RANGE      TOTAL FLAGS
     0: [0..40967]:      106176..147143   40968   0x0
     1: [40968..65023]:  147144..171199   24056 0x801
  mnt> /sbin/xfs_io -c "fiemap -v" aligned_xfs
   aligned_xfs:
   EXT: FILE-OFFSET      BLOCK-RANGE      TOTAL FLAGS
     0: [0..7]:          120..127             8   0x0
     1: [8..40967]:      192..41151       40960 0x2000
     2: [40968..40975]:  236728..236735       8   0x0
     3: [40976..106495]: 236736..302255   65520 0x801

The alignment is best-effort; a stderr message is printed if alignment
can't be achieved due to PATH_MAX overrun, with fallback to non-padded
filename. This allows it to still be useful for opportunistic alignment,
e.g. on aarch64 Btrfs with 64K block-size. Alignment failure messages
provide an indicator that reordering of the cpio-manifest may be
beneficial.

Archive read performance for reflinked initramfs images may suffer due
to the effects of fragmentation, particularly on spinning disks. To
mitigate excessive fragmentation, files with lengths less than
data_align aren't padded.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Nicolas Schier <nsc@kernel.org>
Link: https://lore.kernel.org/r/20250819032607.28727-8-ddiss@suse.de
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
2025-08-20 16:02:56 -07:00
arch - Fix an interrupt vector setup race which leads to a non-functioning device 2025-08-10 08:15:32 +03:00
block block-6.17-20250808 2025-08-09 08:47:28 +03:00
certs sign-file,extract-cert: use pkcs11 provider for OPENSSL MAJOR >= 3 2024-09-20 19:52:48 +03:00
crypto Significant patch series in this pull request: 2025-08-03 16:23:09 -07:00
Documentation docs: initramfs: file data alignment via name padding 2025-08-20 16:02:56 -07:00
drivers - Fix a wrong ioremap size in mvebu-gicp 2025-08-10 08:46:47 +03:00
fs NFS client updates for Linux 6.17 2025-08-09 07:20:44 +03:00
include TTY revert fix for 6.16-rc1 2025-08-09 18:12:23 +03:00
init Significant patch series in this pull request: 2025-08-03 16:23:09 -07:00
io_uring io_uring/memmap: cast nr_pages to size_t before shifting 2025-08-08 06:35:14 -06:00
ipc vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
kernel - Remove an obsolete comment and fix spelling 2025-08-10 08:51:37 +03:00
lib block-6.17-20250808 2025-08-09 08:47:28 +03:00
LICENSES LICENSES: Replace the obsolete address of the FSF in the GFDL-1.2 2025-07-24 11:15:39 +02:00
mm Significant patch series in this pull request: 2025-08-05 16:02:07 +03:00
net NFS client updates for Linux 6.17 2025-08-09 07:20:44 +03:00
rust Rust changes for v6.17 2025-08-03 13:49:10 -07:00
samples Significant patch series in this pull request: 2025-08-03 16:23:09 -07:00
scripts kconfig: qconf/xconfig: show the OptionsMode radio button setting at startup 2025-08-18 10:48:15 -07:00
security + Features 2025-08-04 08:17:28 -07:00
sound gpio updates for v6.17-rc1 2025-08-09 08:15:43 +03:00
tools .gitignore: ignore compile_commands.json globally 2025-08-12 15:53:55 -07:00
usr gen_init_cpio: add -a <data_align> as reflink optimization 2025-08-20 16:02:56 -07:00
virt Merge tag 'kvm-x86-no_assignment-6.17' of https://github.com/kvm-x86/linux into HEAD 2025-07-29 08:36:42 -04:00
.clang-format Linux 6.15-rc5 2025-05-06 16:39:25 +10:00
.clippy.toml rust: clean Rust 1.88.0's warning about clippy::disallowed_macros configuration 2025-05-07 00:11:47 +02:00
.cocciconfig
.editorconfig .editorconfig: remove trim_trailing_whitespace option 2024-06-13 16:47:52 +02:00
.get_maintainer.ignore MAINTAINERS: Retire Ralf Baechle 2024-11-12 15:48:59 +01:00
.gitattributes .gitattributes: set diff driver for Rust source code files 2023-05-31 17:48:25 +02:00
.gitignore .gitignore: ignore compile_commands.json globally 2025-08-12 15:53:55 -07:00
.mailmap Significant patch series in this pull request: 2025-08-03 16:23:09 -07:00
.pylintrc docs: add a .pylintrc file with sys path for docs scripts 2025-04-09 12:10:33 -06:00
.rustfmt.toml rust: add .rustfmt.toml 2022-09-28 09:02:20 +02:00
COPYING COPYING: state that all contributions really are covered by this file 2020-02-10 13:32:20 -08:00
CREDITS Kbuild updates for v6.17 2025-08-06 07:32:52 +03:00
Kbuild drm: ensure drm headers are self-contained and pass kernel-doc 2025-02-12 10:44:43 +02:00
Kconfig io_uring: Rename KConfig to Kconfig 2025-02-19 14:53:27 -07:00
MAINTAINERS spi: Fixes for v6.17 2025-08-09 08:43:24 +03:00
Makefile kbuild: userprogs: avoid duplication of flags inherited from kernel 2025-08-18 10:42:58 -07:00
README README: Fix spelling 2024-03-18 03:36:32 -06:00

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the reStructuredText markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.