* [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* Re: [PATCH] jbd2: skip updating journal superblock on -ESHUTDOWN abort
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
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-12-01 7:42 UTC (permalink / raw)
To: Jia Zhu; +Cc: linux-ext4, tytso
> 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
> [ ... ]
> 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>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201073538.33788-1-zhujia.zj@bytedance.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] jbd2: skip updating journal superblock on -ESHUTDOWN abort
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
1 sibling, 0 replies; 3+ messages in thread
From: Jan Kara @ 2026-12-01 10:29 UTC (permalink / raw)
To: Jia Zhu
Cc: Theodore Ts'o, Jan Kara, linux-ext4, linux-kernel,
Christoph Hellwig, Zhang Yi, stable
On Tue 01-12-26 15:35:38, Jia Zhu wrote:
> 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>
Thanks for the fix but I think instead of this special-casing of shutdown,
we should just modify jbd2_write_superblock() to properly detect dead
device and stop doing IO to it. In fact we have there such check:
/* Buffer got discarded which means block device got invalidated */
if (!buffer_mapped(bh)) {
unlock_buffer(bh);
return -EIO;
}
but it doesn't work for this shutdown path because invalidate_bdev() gets
called only after ->mark_dead() callback is done. So just enhance this
check to something like:
/*
* If buffer got discarded or gendisk is dead, the device doesn't
* exist anymore.
*/
if (!buffer_mapped(bh) || !disk_live(bh->b_bdev->bd_disk))
Honza
> 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)
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [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