Re: [RFC PATCH 0/1] block: long udev open waits during cache teardown
From: Christian Brauner
Date: Fri Nov 20 2026 - 07:40:58 EST
On Tue, Nov 17, 2026 at 06:51:06PM +0800, Ethan wrote:
> The main questions are whether __fput is an acceptable hook, whether
> this should instead remain an explicit userspace action, and whether
> a different block close locking design would better address the issue.
No, __fput() is very wrong for this. It runs for the final fput of
every block device file. So every close of any block device fd would
fsync the whole device and throw away its page cache, including the
cache of everyone else who has it open. udev opens and closes block
devices all the time. That makes the common case a lot worse.
Mainline already syncs before taking open_mutex when it looks like the
last opener is going away. Exactly to avoid multi-minute syncs under the
mutex, look at bdev_release().
What's left under open_mutex is the kill_bdev() in
blkdev_flush_mapping() and going by your numbers that's the truncate
you're waiting on. If that still reproduces on mainline it's a question
about the bdev release locking. It absolutely isn't something to hook
into the generic file release path.
And mkfs can just fsync() and POSIX_FADV_DONTNEED the device itself
before it closes it.