summaryrefslogtreecommitdiff
path: root/include/linux/stackprotector.h
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2026-11-10 19:59:02 +0100
committerChristian Brauner <brauner@kernel.org>2026-11-11 11:59:26 +0100
commita57ad4d3abd9735129e05f7990ba21406ccd9dab (patch)
tree2afc2dec7b4c1407631fb951e74ff3aa91be407c /include/linux/stackprotector.h
parent2d956723e82cddae8ff8e9da99a666217b02065f (diff)
parenta5ef6d6deed263a3e37eee1429788777e4403a7b (diff)
Merge patch series "fs: reclaim inodes with I_METADATA_WRITEBACK"
Christian Brauner <brauner@kernel.org> says: Since v7.3 ext2, ext4 without a journal, fat, udf and minix set I_METADATA_WRITEBACK when they copy an inode into its buffer and only fsync() and friends clear it again. inode_lru_isolate() treats it like any other state bit and takes the inode off the LRU, expecting something to put it back once the bit is gone. Nothing ever does. So these inodes can't be reclaimed until something fsyncs them or the filesystem is unmounted. That's a DoS. On ext4 without a journal an atime update is enough to pin an inode, and creating 60000 small files in a memory cgroup limited to 96M gets the task OOM killed after about 43000 of them. The original provided fix was quite ugly. It handed such inodes from inode_lru_isolate() to a per-sb work item with a reference held, synced them there and put them back on the LRU. We've had discussions in that direction for unrelated reasons and we found that quite terrible. It's a second inode reclaim offload mechanism next to Jan's deferred inode reclaim, it needs a new inode state bit, and the reference shows up in everything that looks for open deleted files. So instead, let the shrinker reclaim these inodes like any other clean inode and make evict() write out what I_METADATA_WRITEBACK tracks unless the inode is being deleted. The first seven patches make ->sync_inode_metadata() of ext2, ext4, minix and udf look the inode block up in the buffer cache instead of reading it from disk, the way fat already does, so that calling it from reclaim is fine. The eighth sets I_METADATA_WRITEBACK from mmb_mark_buffer_dirty() so that the bit covers the tracked metadata buffers as well. The ninth is the actual fix. The last five drop the mmb_sync() calls from ->evict_inode() that evict() makes redundant. This still writes and waits from reclaim if the inode block is still dirty. Once Jan's deferred inode reclaim lands these inodes can go to his workers instead. I have that on top of his v3 (cf. [1]). All of this is meant for v7.3 stable. v7.3 still has bfs which sets I_METADATA_WRITEBACK as well, so the backport needs the cache-only lookup for bfs too. Tested on 65ba8f34ec88 with KASAN and lockdep: creating 5000 files, sync(2) and two drop_caches leave about 5000 of 5000 inodes around on ext2, ext4, vfat and minix without this series and none with it. The memory cgroup run creates all 60000 files and nothing gets killed. Blocks the flusher left dirty get written out on eviction on all five filesystems. No splats. udf inodes with their data in the ICB are still dirty after sync(2), with and without this series. That's a separate issue I didn't care about. [1]: https://patch.msgid.link/20261029-work-inode-metadata_writeback-deferred-v1-1-7e49f6c12b60@kernel.org * patches from https://patch.msgid.link/20261109-work-inode-metadata_writeback-v3-0-91ac6c024018@kernel.org: fat: drop mmb_sync() from fat_evict_inode() udf: drop mmb_sync() from udf_evict_inode() minix: drop mmb_sync() from minix_evict_inode() ext4: drop mmb_sync() from ext4_evict_inode() ext2: drop mmb_sync() from ext2_evict_inode() fs: don't strand I_METADATA_WRITEBACK inodes outside the LRU fs: set I_METADATA_WRITEBACK in mmb_mark_buffer_dirty() udf: don't allocate the inode block in udf_sync_inode_metadata() minix: don't read the inode block in minix_sync_inode_metadata() minix: add minix_inode_block() helper ext4: don't read the inode block in ext4_sync_inode_metadata() ext4: use sb_find_get_block_nonatomic() in ext4_get_inode_loc_noio() ext2: don't read the inode block in ext2_sync_inode_metadata() ext2: add ext2_inode_block() helper Link: https://patch.msgid.link/20261109-work-inode-metadata_writeback-v3-0-91ac6c024018@kernel.org Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Diffstat (limited to 'include/linux/stackprotector.h')
0 files changed, 0 insertions, 0 deletions