From: "Theodore Ts'o" <tytso@mit.edu>
To: Matthias Goergens <matthias.goergens@gmail.com>
Cc: linux-ext4@vger.kernel.org
Subject: Re: [PATCH e2fsprogs 1/2] libext2fs: fix self-deadlock in flush_cached_blocks() write-error retry
Date: Thu, 3 Dec 2026 10:53:25 -0500 [thread overview]
Message-ID: <axGOkGg9oWsACn7m@mit.edu> (raw)
In-Reply-To: <20260922110435.1528332-2-matthias.goergens@gmail.com>
On Tue, Sep 22, 2026 at 07:04:34PM +0800, Matthias Goergens wrote:
> flush_cached_blocks() drops CACHE_MTX before invoking the channel's
> write_error handler, then re-acquires it and jumps to the retry label.
> The retry label is above the while loop, whose first statement acquires
> CACHE_MTX again...
Thanks for the patch. Unforutnately, there were some problems with it:
* The patch simply deletes mutex_lock(data, CACHE_MTX) with the
comment "the loop head re-acquires CACHE_MTX". That comment is
false whenever FLUSH_NOLOCK is set (shrink_cache(), grow_cache(),
and unix_set_blksize() in unix_io.c):
- mutex_unlock(data, CACHE_MTX) before channel->write_error
drops the caller's lock.
- When retrying if ((flags & FLUSH_NOLOCK) == 0) skips re-locking.
- Subsequent scan iterations run without CACHE_MTX (race
condition under IO_FLAG_THREADS), any second failing block
unlocks an already-unlocked mutex, and the caller's
mutex_unlock(data, CACHE_MTX) on return performs a
double-unlock.
The issues you flagged have been fixed in commit 09ce957b ("libext2fs:
fix deadlocks when writing back the unix_io cache fails") with some
additional locking fixes in commit b4d184a8 ("libext2fs: don't lose
acache eviction write errors in unix_write_blk64()". Both of these
commits also have unit tests, which is now the preferred way of adding
tests and doing test-driven development for pure library code changes
to libext2fs.
Cheers,
- Ted
next prev parent reply other threads:[~2026-12-03 15:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 11:04 [PATCH e2fsprogs 0/2] e2fsck: fix a self-deadlock that hangs fsck on corrupt images Matthias Goergens
2026-09-22 11:04 ` [PATCH e2fsprogs 1/2] libext2fs: fix self-deadlock in flush_cached_blocks() write-error retry Matthias Goergens
2026-09-22 18:18 ` Darrick J. Wong
2026-12-03 15:53 ` Theodore Ts'o [this message]
2026-09-22 11:04 ` [PATCH e2fsprogs 2/2] tests: add f_cache_mtx_deadlock for the flush_cached_blocks() retry lock Matthias Goergens
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=axGOkGg9oWsACn7m@mit.edu \
--to=tytso@mit.edu \
--cc=linux-ext4@vger.kernel.org \
--cc=matthias.goergens@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.