Torvalds Warns After 40,000 Lines of AI-Generated Code Land in EXT4 Late in the rc Cycle

2026-11-25来源 dev.to LinuxEnglish

An EXT4 maintainer submitted a 41,197-line pull request for Linux 7.4-rc5. Most of it consisted of AI-generated tests and fixes; Linus Torvalds merged it but warned that he would ignore a similar request next time.

Key points

  • What happened: An EXT4 pull request for Linux 7.4-rc5 added 41,197 lines, most of them AI-generated tests and bug fixes
  • Why it matters: Torvalds merged the request but emphasized the principle that "fixes can contain bugs too—do not drop 40,000 lines into the end of an rc cycle"
  • An 80-line improvement: A Samsung patch in the same pull request improves parallel file creation from 290,000 to 780,000 files per second

A 41,197-line pull request

EXT4 filesystem maintainer Theodore Ts'o posted a pull request for Linux 7.4-rc5 to the kernel mailing list on November 24, 2026. The changes across 68 files added 41,197 lines and removed 621, an unusual scale for the release-candidate stage.

According to Ts'o, most of the added lines were tests for KUnit, the in-kernel unit-testing framework, introduced to make the validation of AI-generated patches safer. Twenty-four commits adding or expanding KUnit tests appear under Ts'o's name alone. They cover nearly every major EXT4 component, including balloc, block_validity, dir, extents, fast_commit, ialloc, inline, inode, and xattr.

In addition to the tests, Ts'o said there were "a large number of bug fixes, most of them AI-generated." The list contains dozens of fixes, including measures to prevent data loss in fast commit, correct out-of-bounds access on corrupted filesystems, and fix use-after-free bugs.

Linus Torvalds replied on the kernel mailing list the same day.

Honestly, I don't think this was appropriate at this stage. The tests should have been kept in a separate branch for your own testing, and this enormous update should have waited for the next merge window

Torvalds wrote that he had considered rejecting the pull request, but resolved the conflicts, merged it, and limited his response to a warning.

I was going to reject it, but I dealt with it this time and will leave it as a fair warning. The next time this happens, I will simply ignore it

"Fixes can contain bugs too"

At the core of Torvalds's anger was the principle governing the release-candidate (rc) stage.

The whole idea that "it is a fix, so it is fine to put it in rc" is wrong

In the Linux kernel development cycle, new features are accepted during the merge window, after which the rc period is devoted to stabilization. The principle is to minimize new code and let the release settle over several weeks. Adding 40,000 lines departs sharply from that principle.

Torvalds went further.

Do you think adding 41,197 lines cannot cause problems because most of them are not compiled, or because the rest are fixes? If so, you are wrong

Suppose AI found a subtle bug that had gone undetected for a long time. By definition, its fix addresses something subtle and rare—something nobody had noticed before. That means the "fix" itself can contain bugs

The logic is straightforward and concerns the development process. Fixes are new code, and new code can introduce bugs. A fix for a hard-to-detect bug is also hard to validate. If such changes total 40,000 lines, they do not belong late in an rc cycle.

Torvalds used Claude Code to write a kernel patch himself (in Japanese) one month earlier. He is not opposed to AI use itself. His point is that usage and timing matter, and AI-generated work must follow the discipline of the development cycle.

Tell your AI companion too: do new development and test cases in a separate branch, then integrate them during the merge window. What is so difficult about that

Yes, dealing with conflicts while running the tests will be your job. But that is better than throwing tens of thousands of lines of unknown code into the middle of a release

Distributing inodes across sibling directories

The pull request that angered Torvalds also contains an understated but highly effective performance patch. Submitted in October by Samsung's Daejun Park, it speeds up parallel file creation in EXT4.

The root of the problem lies in inode placement. An inode stores a file's metadata. When EXT4's flex_bg feature is enabled, files in sibling directories, or directories under the same parent, become concentrated in the same block group. When multiple processes create files at the same time, they wait for locks on the same inode-table block. In Park's measurements, 90% of context switches were spent waiting for buffer locks.

The patch uses a simple approach: it determines the inode placement target within the flex group from the parent directory's inode number. Files from different directories are spread across different block groups, reducing lock contention.

In a QEMU environment with a passed-through Samsung 990 PRO NVMe drive, 16 tasks each created 60,000 files. Before the patch, throughput was 290,000 files per second, with about 50,000 inode-table reads. Afterward, throughput rose to 780,000 files per second, while reads fell sharply to 300–500. Throughput improved by about 2.7x, and unnecessary disk reads fell to less than one-hundredth of their previous level.

The result was even more pronounced with 32 tasks, improving from 460,000 to as many as 1.02 million files per second. The time for a cold ls -l also fell from 0.76 seconds to 0.49 seconds after the 16-task run.

Figure omitted — see the original article

The patch changes only two files and adds 80 lines. The 40,000 lines of KUnit tests that enraged Torvalds and the 80-line performance patch are part of the same pull request. The diff itself shows that code volume and value are not proportional.

Originally published on Joho no Todai. The Japanese original is here.

原文:https://www.a8q9.cn/en/article/torvalds-warns-after-40-000-lines-of-ai-generated-code-land-in-ext4-late-in-the--047d0c.html

相关文章