[PATCH] jbd2: skip updating journal superblock on -ESHUTDOWN abort
From: Jia Zhu
Date: Tue Dec 01 2026 - 02:36:02 EST
Removing a block device with a mounted ext4 filesystem can trigger a
hung task (or hang indefinitely) in ext4_shutdown():
EXT4-fs (nvme3n1p1): shut down requested (2)
Aborting journal on device nvme3n1p1-8.
INFO: task kworker/u456:2:885880 blocked for more than 122 seconds.
Workqueue: kacpi_hotplug acpi_hotplug_work_fn
Call Trace:
__wait_on_buffer
jbd2_write_superblock
jbd2_journal_update_sb_errno
jbd2_journal_abort
ext4_force_shutdown
ext4_shutdown
fs_bdev_mark_dead
bdev_mark_dead
blk_report_disk_dead
__del_gendisk
del_gendisk
nvme_ns_remove
nvme_remove_namespaces
nvme_remove
pci_device_remove
...
acpiphp_disable_and_eject_slot
Stalling here holds sb->s_umount, device_lock, and (on ACPI/PCI hotplug)
the ordered kacpi_hotplug workqueue and pci_rescan_remove_lock, blocking
teardown, umount, subsequent hotplug, and device_shutdown().
Commit fb7c02445c49 ("ext4: pass -ESHUTDOWN code to jbd2 layer") switched
shutdown aborts from 0 to -ESHUTDOWN so a racing error abort could be
cleared back to s_errno = 0, inadvertently causing an initial -ESHUTDOWN
abort to write 0 over an already-zero s_errno (and attempt writes on
read-only mounts or NOLOGFLUSH shutdowns).
Skip jbd2_journal_update_sb_errno() on the initial abort path when errno
is -ESHUTDOWN, leaving the existing JBD2_ABORT override path for racing
error aborts unchanged.
Fixes: fb7c02445c49 ("ext4: pass -ESHUTDOWN code to jbd2 layer")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Jia Zhu <zhujia.zj@xxxxxxxxxxxxx>
---
fs/jbd2/journal.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index eb8e944f1f9e6..866132fbcd8c9 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -2629,9 +2629,11 @@ void jbd2_journal_abort(journal_t *journal, int errno)
/*
* Record errno to the journal super block, so that fsck and jbd2
- * layer could realise that a filesystem check is needed.
+ * layer could realise that a filesystem check is needed. Skip
+ * -ESHUTDOWN since no error needs to be recorded on disk.
*/
- jbd2_journal_update_sb_errno(journal);
+ if (errno != -ESHUTDOWN)
+ jbd2_journal_update_sb_errno(journal);
mutex_unlock(&journal->j_abort_mutex);
}
--
2.39.5 (Apple Git-154)