Allowing directories to be modified in parallel was the topic of Jeff Layton's filesystem-track session at the 2025 Linux Storage, Filesystem, Memory Management, and BPF Summit (LSFMM+BPF). There are certain use cases, including for the NFS and Lustre filesystems, as mentioned in a patch set referenced in the topic proposal, where contention in creating multiple files in a directory is causing noticeable performance problems. In some testing, Layton has found that the inode read-write semaphore (i_rwsem) for the directory is serializing operations; he wanted to discuss alternatives.
允许并行修改目录是 Jeff Layton 在 2025 年 Linux 存储、文件系统、内存管理和 BPF 峰会(LSFMM+BPF)文件系统分会上的议题。在一些特定场景中(例如 NFS 和 Lustre 文件系统),如议题提案中提到的补丁集中所描述,多个线程在同一目录中创建文件时会产生竞争,导致明显的性能问题。Layton 在一些测试中发现,目录的 inode 读写信号量(i_rwsem)会将这些操作串行化,因此他希望讨论其他可行的替代方案。
He and Christian Brauner had worked on a patch set that addressed some of the low-hanging fruit from the problem. It would avoid taking the exclusive lock on the directory if an open with the O_CREAT flag did not actually create a new file. It provided a substantial improvement for certain workloads, Layton said.
他和 Christian Brauner 曾经合作开发了一个补丁集,解决了该问题中一些“低垂的果实”。这个补丁集在打开文件时带有 O_CREAT 标志但并未实际创建新文件的情况下,会避免获取目录的独占锁。Layton 表示,这对于某些工作负载带来了显著的性能提升。
But what is really desired, he said, is to be able to do all sorts of parallel directory operations (mkdir, unlink, rmdir, etc.). Neil Brown developed the patch set referenced earlier (which was up to v7 as of the summit) that would stop taking the exclusive (write) lock for every operation on the directory; it would take the sh