Linux EXT4 FS development
 help / color / mirror / Atom feed
* [PATCH] jbd2: skip updating journal superblock on -ESHUTDOWN abort
@ 2026-12-01  7:35 Jia Zhu
  2026-12-01  7:42 ` sashiko-bot
  2026-12-01 10:29 ` Jan Kara
  0 siblings, 2 replies; 3+ messages in thread
From: Jia Zhu @ 2026-12-01  7:35 UTC (permalink / raw)
  To: Theodore Ts'o, Jan Kara
  Cc: linux-ext4, linux-kernel, Christoph Hellwig, Zhang Yi, Jia Zhu,
	stable

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@vger.kernel.org
Signed-off-by: Jia Zhu <zhujia.zj@bytedance.com>
---
 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)

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-01 10:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01  7:35 [PATCH] jbd2: skip updating journal superblock on -ESHUTDOWN abort Jia Zhu
2026-12-01  7:42 ` sashiko-bot
2026-12-01 10:29 ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox