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 82D3F2D8364; Mon, 13 Apr 2026 16:34:36 +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=1776098076; cv=none; b=kK7oz2IWxDPb3qkNKoxGrx/SoUofcMzhg+Mrr28FDWp5NugWUWq0VDtoKzYpKT1dcnFvHu7PUf5IdyIVh6NsiZM77DotnMChuEqgNuWRvYaE0qrm1QGqO46KML12WrQ7J1r2M0zCvcLAUkbwKqBhYpitfXUjvPRPgPvYIwT+p9w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776098076; c=relaxed/simple; bh=LsDb5T4FiLuCYJgMvld9LFHZhNktBM73O5Djx4MBmEM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y9oZwxa9KTImhf+DnxDf6rFPS3u4d3rhEdsd617foa4xJ8vH9jYGmhfT2WqB3aL6EcYLc6UGehOmZvjhSAj7Fag+dB/fzpgVnJccMx8HpUqhnZAlEQZKd7Q8/lltcAllqKlSZ9l4C65M/AVGPDeuG4B/9OpMhwH1DxfKstN8vBI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=z+kaoh1f; 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="z+kaoh1f" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 182EBC2BCAF; Mon, 13 Apr 2026 16:34:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776098076; bh=LsDb5T4FiLuCYJgMvld9LFHZhNktBM73O5Djx4MBmEM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z+kaoh1fVJK0/wyEWLIgcv4hexqIQI4v4Q3lsML1wrtMCicE5FMomyrXq2cMXVrN4 asm4VQMEQN7un5jMLVhXzryvTiLaMcSuBtUrx8kUtUrYHNsSJ6bgshnVNLUXegtJpI +mGVyudBJvD91POYGrxlQMydl1rjJIyVwTsyCaqE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Theodore Tso , stable@kernel.org Subject: [PATCH 5.15 385/570] ext4: always drain queued discard work in ext4_mb_release() Date: Mon, 13 Apr 2026 17:58:36 +0200 Message-ID: <20260413155844.900657959@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260413155830.386096114@linuxfoundation.org> References: <20260413155830.386096114@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-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 @@ -3628,13 +3628,11 @@ int 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)); if (sbi->s_group_info) { for (i = 0; i < ngroups; i++) {