* [PATCH] jbd2: skip updating journal superblock on -ESHUTDOWN abort
@ 2026-12-01 7:35 Jia Zhu
2026-12-01 7:42 ` sashiko-bot
` (2 more replies)
0 siblings, 3 replies; 6+ 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] 6+ 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
2026-12-01 13:17 ` Jan Kara
2 siblings, 0 replies; 6+ 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] 6+ 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
2026-12-01 12:32 ` Jia Zhu
2026-12-01 13:17 ` Jan Kara
2 siblings, 1 reply; 6+ 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] 6+ messages in thread
* Re: [PATCH] jbd2: skip updating journal superblock on -ESHUTDOWN abort
2026-12-01 10:29 ` Jan Kara
@ 2026-12-01 12:32 ` Jia Zhu
2026-12-01 13:17 ` Jan Kara
0 siblings, 1 reply; 6+ messages in thread
From: Jia Zhu @ 2026-12-01 12:32 UTC (permalink / raw)
To: Jan Kara
Cc: Theodore Ts'o, linux-ext4, linux-kernel, Christoph Hellwig,
Zhang Yi, stable
On Tue, Dec 01, 2026 at 11:29:06AM +0100, Jan Kara wrote:
> 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))
Hi Jan,
Thanks for the review!
My concern with !disk_live() in jbd2_write_superblock() is that on an
orderly removal of a healthy disk, disk_live() becomes false before
the final sync:
__del_gendisk()
bdev_unhash(part) /* disk_live() is now false */
blk_report_disk_dead(disk, false)
fs_bdev_mark_dead(bdev, false)
sync_filesystem(sb) /* disk can still do I/O */
...
jbd2_journal_commit_transaction()
if (JBD2_FLUSHED)
jbd2_journal_update_sb_log_tail() /* retval ignored */
jbd2_write_superblock() /* -EIO, no abort */
/* commit succeeds with on-disk s_start still 0 */
sb->s_op->shutdown(sb)
Recovery could then treat the journal as empty and skip that transaction.
(GD_DEAD isn't set until after blk_report_disk_dead() either.)
Checking disk_live() also misses blk_mark_disk_dead() (which doesn't
unhash part0) and EXT4_IOC_SHUTDOWN(EXT4_GOING_FLAGS_NOLOGFLUSH) on an
unresponsive device that is still live.
Fixing this in jbd2_journal_abort() instead avoids touching
jbd2_write_superblock() at all. When the journal has not been aborted
before, there is no prior error recorded in s_errno, and
jbd2_journal_update_sb_errno() would only convert -ESHUTDOWN to 0 and
write 0 again. If an error abort already happened first, the existing
JBD2_ABORT branch still writes 0 to clear that error.
Would you be OK with keeping the fix in jbd2_journal_abort()?
Best regards,
Jia
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] jbd2: skip updating journal superblock on -ESHUTDOWN abort
2026-12-01 12:32 ` Jia Zhu
@ 2026-12-01 13:17 ` Jan Kara
0 siblings, 0 replies; 6+ messages in thread
From: Jan Kara @ 2026-12-01 13:17 UTC (permalink / raw)
To: Jia Zhu
Cc: Jan Kara, Theodore Ts'o, linux-ext4, linux-kernel,
Christoph Hellwig, Zhang Yi, stable
On Tue 01-12-26 20:32:34, Jia Zhu wrote:
> On Tue, Dec 01, 2026 at 11:29:06AM +0100, Jan Kara wrote:
> > 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))
>
> Hi Jan,
>
> Thanks for the review!
>
> My concern with !disk_live() in jbd2_write_superblock() is that on an
> orderly removal of a healthy disk, disk_live() becomes false before
> the final sync:
>
> __del_gendisk()
> bdev_unhash(part) /* disk_live() is now false */
> blk_report_disk_dead(disk, false)
> fs_bdev_mark_dead(bdev, false)
> sync_filesystem(sb) /* disk can still do I/O */
> ...
> jbd2_journal_commit_transaction()
> if (JBD2_FLUSHED)
> jbd2_journal_update_sb_log_tail() /* retval ignored */
> jbd2_write_superblock() /* -EIO, no abort */
> /* commit succeeds with on-disk s_start still 0 */
> sb->s_op->shutdown(sb)
>
> Recovery could then treat the journal as empty and skip that transaction.
> (GD_DEAD isn't set until after blk_report_disk_dead() either.)
>
> Checking disk_live() also misses blk_mark_disk_dead() (which doesn't
> unhash part0) and EXT4_IOC_SHUTDOWN(EXT4_GOING_FLAGS_NOLOGFLUSH) on an
> unresponsive device that is still live.
Fair, what I've suggested doesn't work.
> Fixing this in jbd2_journal_abort() instead avoids touching
> jbd2_write_superblock() at all. When the journal has not been aborted
> before, there is no prior error recorded in s_errno, and
> jbd2_journal_update_sb_errno() would only convert -ESHUTDOWN to 0 and
> write 0 again. If an error abort already happened first, the existing
> JBD2_ABORT branch still writes 0 to clear that error.
>
> Would you be OK with keeping the fix in jbd2_journal_abort()?
I'm a bit nervous with skipping the superblock write (the errno update
isn't needed, that's correct, I was more concerned about some other fields
needing to be written back as this is practically their last chance to be
written). But after some more thinking that shouldn't be an issue so I'm ok
with your fix.
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 6+ 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
@ 2026-12-01 13:17 ` Jan Kara
2 siblings, 0 replies; 6+ messages in thread
From: Jan Kara @ 2026-12-01 13:17 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>
Looks ok. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> 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)
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-12-01 13:17 UTC | newest]
Thread overview: 6+ 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
2026-12-01 12:32 ` Jia Zhu
2026-12-01 13:17 ` Jan Kara
2026-12-01 13:17 ` Jan Kara
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.