cachefiles: cache objects get created on a frozen cache filesystem

From: Christian Brauner

Date: Sat Nov 14 2026 - 04:42:25 EST


Hey,

I'm working on freeze protection fixes across the tree and this one I
just can't fix myself.

cachefiles only takes freeze protection around its xattr updates since
80887f316729 ("cachefiles: Fix non-taking of sb_writers around
set/removexattr"). The namespace operations on the cache filesystem
still don't have it. So cachefiles modifies a frozen cache filesystem.
On ext4 that trips the WARN_ON() in ext4_journal_check_start().

Reproduced on v7.4-rc1 with the cache on ext4, bound through
/dev/cachefiles, and an NFS mount with -o fsc. Freeze the cache
filesystem and read files through NFS that aren't cached yet:

WARNING: fs/ext4/ext4_jbd2.c:90 at ext4_journal_check_start+0x1f6/0x2d0, CPU#2: kworker/u16:1/43
Workqueue: fscache fscache_cookie_worker
Call Trace:
__ext4_journal_start_sb+0x7a/0x470
__ext4_new_inode+0x23da/0x45d0
ext4_tmpfile+0x1b9/0x490
vfs_tmpfile+0x414/0xa90
kernel_tmpfile_open+0x3d/0x70
cachefiles_create_tmpfile+0x1c7/0x800
cachefiles_create_file+0x6f/0x2f0
cachefiles_look_up_object+0x71a/0x8a0
cachefiles_lookup_cookie+0x3b8/0x8f0
fscache_cookie_worker+0xa23/0x19a0
process_one_work+0x946/0x1820
worker_thread+0x4f1/0xd60
kthread+0x364/0x460

That's one per file read.

>From reading the code the other namespace operations have the same
problem but I've only triggered the tmpfile creation:

- vfs_mkdir() in cachefiles_get_directory()
- vfs_rename() in cachefiles_bury_object()
- vfs_unlink() in cachefiles_unlink()
- vfs_link() in cachefiles_commit_tmpfile()

They need mnt_want_write(cache->mnt) taken before the parent's inode
lock, like the xattr helpers do it.

The tmpfile creation goes back to 1f08c925e7a3 ("cachefiles: Implement
backing file wrangling").