linux/fs/ext4
Theodore Ts'o 9ee29d20aa ext4: always drain queued discard work in ext4_mb_release()
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 <tytso@mit.edu>
Fixes: 55cdd0af2b ("ext4: get discard out of jbd2 commit kthread contex")
Cc: stable@kernel.org
2026-03-27 23:39:10 -04:00
..
.kunitconfig ext4: add .kunitconfig fragment to enable ext4-specific tests 2021-02-11 23:16:30 -05:00
Kconfig ext4: remove obsolete EXT3 config options 2025-09-25 14:47:05 -04:00
Makefile ext4: fix extents-test.c is not compiled when EXT4_KUNIT_TESTS=M 2026-03-27 23:36:06 -04:00
acl.c ext4: convert to ctime accessor functions 2023-07-24 10:29:54 +02:00
acl.h Revert "ext4: apply umask if ACL support is disabled" 2024-05-02 18:25:39 -04:00
balloc.c fs/ext4: fix typo in comment 2025-11-26 17:13:34 -05:00
bitmap.c ext4: remove sbi argument from ext4_chksum() 2025-05-20 10:31:12 -04:00
block_validity.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
crypto.c ext4: fix journal credit check when setting fscrypt context 2026-03-27 23:30:25 -04:00
dir.c Convert 'alloc_flex' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
ext4.h ext4: fix use-after-free in update_super_work when racing with umount 2026-03-27 23:37:39 -04:00
ext4_extents.h ext4: fix extents-test.c is not compiled when EXT4_KUNIT_TESTS=M 2026-03-27 23:36:06 -04:00
ext4_jbd2.c ext4: make data=journal support large block size 2025-11-28 22:35:28 -05:00
ext4_jbd2.h ext4/jbd2: convert jbd2_journal_blocks_per_page() to support large folio 2025-05-20 10:31:12 -04:00
extents-test.c ext4: fix extents-test.c is not compiled when EXT4_KUNIT_TESTS=M 2026-03-27 23:36:06 -04:00
extents.c ext4: skip split extent recovery on corruption 2026-03-27 23:38:52 -04:00
extents_status.c ext4: add extent status cache support to kunit tests 2026-01-23 16:49:43 -05:00
extents_status.h ext4: make ext4_es_lookup_extent() pass out the extent seq counter 2025-11-06 10:44:39 -05:00
fast_commit.c ext4: fix iloc.bh leak in ext4_fc_replay_inode() error paths 2026-03-27 23:38:01 -04:00
fast_commit.h ext4: mark move extents fast-commit ineligible 2026-01-19 19:26:35 -05:00
file.c mm.git review status for linus..mm-stable 2026-02-18 20:50:32 -08:00
fsmap.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
fsmap.h ext4: fsmap: fix the block/inode bitmap comment 2021-06-24 09:48:29 -04:00
fsync.c ext4: fix fsync(2) for nojournal mode 2026-03-27 23:31:43 -04:00
hash.c ext4: make error code in __ext4fs_dirhash() consistent. 2025-11-06 10:32:33 -05:00
ialloc.c ext4: make recently_deleted() properly work with lazy itable initialization 2026-03-27 23:30:37 -04:00
indirect.c ext4: add ext4_sb_bread_nofail() helper function for ext4_free_branches() 2025-09-25 14:36:54 -04:00
inline.c ext4: replace BUG_ON with proper error handling in ext4_read_inline_folio 2026-03-27 23:31:52 -04:00
inode-test.c ext4: add missing MODULE_DESCRIPTION() 2024-07-05 16:07:24 -04:00
inode.c ext4: test if inode's all dirty pages are submitted to disk 2026-03-27 23:33:34 -04:00
ioctl.c New features and improvements for the ext4 file system 2026-02-12 10:19:58 -08:00
mballoc-test.c ext4: fix mballoc-test.c is not compiled when EXT4_KUNIT_TESTS=M 2026-03-27 23:36:02 -04:00
mballoc.c ext4: always drain queued discard work in ext4_mb_release() 2026-03-27 23:39:10 -04:00
mballoc.h ext4: fix mballoc-test.c is not compiled when EXT4_KUNIT_TESTS=M 2026-03-27 23:36:02 -04:00
migrate.c ext4: mark inode format migration fast-commit ineligible 2026-01-19 19:26:35 -05:00
mmp.c ext4: use super write guard in write_mmp_block() 2025-11-05 22:52:15 +01:00
move_extent.c ext4: mark move extents fast-commit ineligible 2026-01-19 19:26:35 -05:00
namei.c ext4: add EXT4_LBLK_TO_B macro for logical block to bytes conversion 2025-11-28 22:35:27 -05:00
orphan.c Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
page-io.c ext4: fix stale xarray tags after writeback 2026-03-27 23:29:39 -04:00
readpage.c fsverity updates for 7.0 2026-02-12 10:41:34 -08:00
resize.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
super.c ext4: fix deadlock on inode reallocation 2026-03-27 23:37:48 -04:00
symlink.c ext4_get_link(): fix breakage in RCU mode 2024-02-25 02:10:32 -05:00
sysfs.c ext4: fix use-after-free in update_super_work when racing with umount 2026-03-27 23:37:39 -04:00
truncate.h ext4: Convert to use mapping->invalidate_lock 2021-07-13 14:29:00 +02:00
verity.c fsverity updates for 7.0 2026-02-12 10:41:34 -08:00
xattr.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
xattr.h ext4: fix out-of-bound read in ext4_xattr_inode_dec_ref_all() 2025-03-18 00:15:19 -04:00
xattr_hurd.c fs: port xattr to mnt_idmap 2023-01-19 09:24:28 +01:00
xattr_security.c fs: port xattr to mnt_idmap 2023-01-19 09:24:28 +01:00
xattr_trusted.c fs: port xattr to mnt_idmap 2023-01-19 09:24:28 +01:00
xattr_user.c fs: port xattr to mnt_idmap 2023-01-19 09:24:28 +01:00