From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 462D831714F; Tue, 31 Mar 2026 16:45:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774975557; cv=none; b=Rb1+LSB+XQ9Dj7i6nCPfFpRO5zzfGnieFrcy0cg8NKGgCQrMpnGQpUVH5/RTrhDu3SkY1p9KFuep/QPY+6pB3aQuDZtGYZcV1nVc7o6rcVFz/v9caAauVDoXcyMePJo52DCyYOCoT+FhD/SnK9qw+lpXFEl3e4QI6Vud/bN1Hi4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774975557; c=relaxed/simple; bh=Ef5MujG0t1g1nGwRsfqRferhB83hzFsnK69YRgtvjuo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GYF5qzQw4BbBytw4zaax9Y/Saqc6djdyYJfYEzNvJ+HOHxCRBwT/pokISDjtcUyCnjN7p0A3D7Fn7HnLBrfiaWJuuAkbZPbo0aijmL0mlatyDc9TLScUaaM4Y6FYzf+kecv0mgJlZ79QspZw8cFJeje9RJwW487Qn6LQxflumC0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Pc6BePZ4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Pc6BePZ4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0E11C19423; Tue, 31 Mar 2026 16:45:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774975557; bh=Ef5MujG0t1g1nGwRsfqRferhB83hzFsnK69YRgtvjuo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pc6BePZ4/hiNYk15LynGaXdX1Twl/Uc2i/NySmh2LmGQWJ5QrCGEaUiLHz6YeKZ3E /zDwwXntiFzIUjt7Q7o9VECtCwHgeA/RhdRVNx4pnKoNEENXdnKdpTi6m5yKHTR1lS o0NW3D3sSNo4TIQHd6VPlhJD8BN+OEcTDOWIoGBs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Theodore Tso , stable@kernel.org Subject: [PATCH 6.19 307/342] ext4: always drain queued discard work in ext4_mb_release() Date: Tue, 31 Mar 2026 18:22:20 +0200 Message-ID: <20260331161810.221839942@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260331161758.909578033@linuxfoundation.org> References: <20260331161758.909578033@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Theodore Ts'o commit 9ee29d20aab228adfb02ca93f87fb53c56c2f3af upstream. While reviewing recent ext4 patch[1], Sashiko raised the following concern[2]: > If the filesystem is initially mounted with the discard option, > deleting files will populate sbi->s_discard_list and queue > s_discard_work. If it is then remounted with nodiscard, the > EXT4_MOUNT_DISCARD flag is cleared, but the pending s_discard_work is > neither cancelled nor flushed. [1] https://lore.kernel.org/r/20260319094545.19291-1-qiang.zhang@linux.dev/ [2] https://sashiko.dev/#/patchset/20260319094545.19291-1-qiang.zhang%40linux.dev The concern was valid, but it had nothing to do with the patch[1]. One of the problems with Sashiko in its current (early) form is that it will detect pre-existing issues and report it as a problem with the patch that it is reviewing. In practice, it would be hard to hit deliberately (unless you are a malicious syzkaller fuzzer), since it would involve mounting the file system with -o discard, and then deleting a large number of files, remounting the file system with -o nodiscard, and then immediately unmounting the file system before the queued discard work has a change to drain on its own. Fix it because it's a real bug, and to avoid Sashiko from raising this concern when analyzing future patches to mballoc.c. Signed-off-by: Theodore Ts'o Fixes: 55cdd0af2bc5 ("ext4: get discard out of jbd2 commit kthread contex") Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/ext4/mballoc.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -3895,13 +3895,11 @@ void ext4_mb_release(struct super_block struct kmem_cache *cachep = get_groupinfo_cache(sb->s_blocksize_bits); int count; - if (test_opt(sb, DISCARD)) { - /* - * wait the discard work to drain all of ext4_free_data - */ - flush_work(&sbi->s_discard_work); - WARN_ON_ONCE(!list_empty(&sbi->s_discard_list)); - } + /* + * wait the discard work to drain all of ext4_free_data + */ + flush_work(&sbi->s_discard_work); + WARN_ON_ONCE(!list_empty(&sbi->s_discard_list)); group_info = rcu_access_pointer(sbi->s_group_info); if (group_info) {