From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=18.9.28.11 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796313211; b=pSFDMPcFOCxN3rOvoDL/nu35Io0PCjBdm8Gn7qKrxL21zIb0dk6NIShTrtqWHezmxUrP 81u3n91VJJI+P43Y2By7OznbO7GxTmvCKgg7hw1E+wXCt54J61LI4eCVRr6s2jWWQcpiT LzFFYrvXfOsfV6EMo9/7dOSbrkSLUreFSDYPTd3Oi6kv66ZQsipdX2uDyiWZSlcRTheNL IrXAOQfoU2DP4INZEKu8Esiv25V0imgTl5TL2rBLBj0yelmdV82N1FxJFJgd6LY6A1CMr pyszPOuEI3gt93x4I+1zFNd7YcUlz/pHi4CKp9uTzlUK2fJFP2WZTcy/0I9FruxPeKA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796313211; h=DMARC-Filter:Received:DKIM-Signature:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; bh=PD8Xpl1RLAYnz2RYhStvrjuxEsYPgxNUePC8gbcSAkg=; b=aq/rZI/TOFgIp6fbO26NfuMEnZUWgjDPj7IwXzb2jFypIfitfdVB5BNVWiX3evmakFMJ RvdkUhUV4MJrMOluwLlUG1G5yWUeZAZACDth1UdJvT7N9aPTJiSTR+5bjU3Ek+SSI0iSN OIT06HhXDYgPD8hq09ZZRFgEOzljvAbNApuIgaKyfTNQUjj/f2pPL5ptnszt3NLVSwpbI 3YJ+GlN3HMpgmHbWpaf6t2N8srStR5CeSeGSA4ip6p18zY/hqlrbMNYvSFzG4Ui7wsmMD F6iZGKSQl/QE71r+DvTuAY8pLba+jBVuM/U7UFQ4doim4fhmhy44YW/mw2cp0c4Z7/g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=mit.edu; spf=pass smtp.mailfrom=mit.edu; dkim=pass header.d=mit.edu header.i=@mit.edu header.a=rsa-sha256 header.s=outgoing header.b=X1xvLuEW; arc=none smtp.remote-ip=18.9.28.11 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BA86606A322 for ; Thu, 3 Dec 2026 15:53:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6BA86606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mit.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mit.edu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=mit.edu header.i=@mit.edu header.a=rsa-sha256 header.s=outgoing header.b=X1xvLuEW Received: from trampoline.thunk.org (pool-108-26-156-184.bstnma.fios.verizon.net [108.26.156.184]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 6B3FrPtf010377 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 3 Dec 2026 10:53:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=outgoing; t=1796313207; bh=PD8Xpl1RLAYnz2RYhStvrjuxEsYPgxNUePC8gbcSAkg=; h=Date:From:Subject:Message-ID:MIME-Version:Content-Type; b=X1xvLuEWlaE84frhY6Kj3eoa4i+k/8nRXPpWJk4P4bm9QQalw/thaOGbS6V374cNt nnxFF+SaWVjhsbwN/PyyQZtQbECXPkgku6Ax50gdMvgxpzz0ndDtHK1q3xdhClr0Zf fs1wdD++FUoVy7fzbZ1//mLYZBaj7qPN5otNbPKQ616t6s5+TVjfvNYgX/+UssUFTW G3tKboVx7k/F39cqS4fglTCGl9tlIL5JZvs9/CCZrUlj1BPzjWrgm5GHYBCSLrLwLG aNVZVw7K6GyTDqcQamDD0fYIsFFmHX83NA97ATPM2q+ryz4/EQsnJ6lzCeZ3bbL03y JwxSTYm16oejw== Received: by trampoline.thunk.org (Postfix, from userid 15806) id 75B322E011A; Thu, 03 Dec 2026 10:53:25 -0500 (EST) Date: Thu, 3 Dec 2026 10:53:25 -0500 From: "Theodore Ts'o" To: Matthias Goergens Cc: linux-ext4@vger.kernel.org Subject: Re: [PATCH e2fsprogs 1/2] libext2fs: fix self-deadlock in flush_cached_blocks() write-error retry Message-ID: References: <20260922110435.1528332-1-matthias.goergens@gmail.com> <20260922110435.1528332-2-matthias.goergens@gmail.com> X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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