* [PATCH] ext4: Avoid entering writeback paths during fastcommit replay
@ 2026-08-04 10:41 Jan Kara
2026-08-04 12:08 ` Ojaswin Mujoo
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Jan Kara @ 2026-08-04 10:41 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-ext4, Ojaswin Mujoo, Venkat Rao Bagalkote, Jan Kara
Fastcommit replay effectively happens in nojournal mode. This results in
ext4_mark_iloc_dirty() setting I_METADATA_WRITEBACK flag and as a result
we end up entering filesystem writeback functions. However during
fastcommit replay s_writepages_rwsem isn't initialized yet and hence we
crash.
Fix the problem by avoiding setting I_METADATA_WRITEBACK during
fastcommit replay. Journal replay flushes the whole block device after
replay anyway so all metadata is properly persisted and replay is faster
this way as a bonus.
Fixes: c26339e1df33 ("ext4: Fix data integrity writeout issues in nojournal mode")
Reported-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Reported-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/ext4/inode.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
Christian, please add this fixup to my sync fixing series. Thanks!
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 7a1f961cd11c..12ff84ab5741 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -6408,9 +6408,10 @@ int ext4_chunk_trans_blocks(struct inode *inode, int nrblocks)
int ext4_mark_iloc_dirty(handle_t *handle,
struct inode *inode, struct ext4_iloc *iloc)
{
+ struct super_block *sb = inode->i_sb;
int err = 0;
- err = ext4_emergency_state(inode->i_sb);
+ err = ext4_emergency_state(sb);
if (unlikely(err)) {
put_bh(iloc->bh);
return err;
@@ -6425,9 +6426,13 @@ int ext4_mark_iloc_dirty(handle_t *handle,
put_bh(iloc->bh);
/*
* Mark that there's metadata writeout pending for the inode so that it
- * gets properly flushed on fsync(2) and similar.
+ * gets properly flushed on fsync(2) and similar. We don't bother for
+ * fastcommit replay as that flushes the whole bdev afterwards anyway.
+ * It is faster this way and we avoid entering fs writeback paths which
+ * aren't fully initialized yet.
*/
- if (!EXT4_SB(inode->i_sb)->s_journal) {
+ if (!ext4_handle_valid(handle) &&
+ !(EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY)) {
/*
* Inode didn't need to go through dirtying, make sure it is
* attached to wb so that writeback can handle it.
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ext4: Avoid entering writeback paths during fastcommit replay
2026-08-04 10:41 [PATCH] ext4: Avoid entering writeback paths during fastcommit replay Jan Kara
@ 2026-08-04 12:08 ` Ojaswin Mujoo
2026-08-06 14:48 ` Theodore Tso
2026-08-07 4:14 ` Venkat Rao Bagalkote
2 siblings, 0 replies; 5+ messages in thread
From: Ojaswin Mujoo @ 2026-08-04 12:08 UTC (permalink / raw)
To: Jan Kara; +Cc: Christian Brauner, linux-ext4, Venkat Rao Bagalkote
On Tue, Aug 04, 2026 at 12:41:13PM +0200, Jan Kara wrote:
> Fastcommit replay effectively happens in nojournal mode. This results in
> ext4_mark_iloc_dirty() setting I_METADATA_WRITEBACK flag and as a result
> we end up entering filesystem writeback functions. However during
> fastcommit replay s_writepages_rwsem isn't initialized yet and hence we
> crash.
>
> Fix the problem by avoiding setting I_METADATA_WRITEBACK during
> fastcommit replay. Journal replay flushes the whole block device after
> replay anyway so all metadata is properly persisted and replay is faster
> this way as a bonus.
>
> Fixes: c26339e1df33 ("ext4: Fix data integrity writeout issues in nojournal mode")
> Reported-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
> Reported-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
Hey Jan, yes makese sense and it is fixing the issue for me. Feel free
to add:
Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Regards,
ojaswin
> fs/ext4/inode.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> Christian, please add this fixup to my sync fixing series. Thanks!
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 7a1f961cd11c..12ff84ab5741 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -6408,9 +6408,10 @@ int ext4_chunk_trans_blocks(struct inode *inode, int nrblocks)
> int ext4_mark_iloc_dirty(handle_t *handle,
> struct inode *inode, struct ext4_iloc *iloc)
> {
> + struct super_block *sb = inode->i_sb;
> int err = 0;
>
> - err = ext4_emergency_state(inode->i_sb);
> + err = ext4_emergency_state(sb);
> if (unlikely(err)) {
> put_bh(iloc->bh);
> return err;
> @@ -6425,9 +6426,13 @@ int ext4_mark_iloc_dirty(handle_t *handle,
> put_bh(iloc->bh);
> /*
> * Mark that there's metadata writeout pending for the inode so that it
> - * gets properly flushed on fsync(2) and similar.
> + * gets properly flushed on fsync(2) and similar. We don't bother for
> + * fastcommit replay as that flushes the whole bdev afterwards anyway.
> + * It is faster this way and we avoid entering fs writeback paths which
> + * aren't fully initialized yet.
> */
> - if (!EXT4_SB(inode->i_sb)->s_journal) {
> + if (!ext4_handle_valid(handle) &&
> + !(EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY)) {
> /*
> * Inode didn't need to go through dirtying, make sure it is
> * attached to wb so that writeback can handle it.
> --
> 2.51.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ext4: Avoid entering writeback paths during fastcommit replay
2026-08-04 10:41 [PATCH] ext4: Avoid entering writeback paths during fastcommit replay Jan Kara
2026-08-04 12:08 ` Ojaswin Mujoo
@ 2026-08-06 14:48 ` Theodore Tso
2026-08-06 15:07 ` Jan Kara
2026-08-07 4:14 ` Venkat Rao Bagalkote
2 siblings, 1 reply; 5+ messages in thread
From: Theodore Tso @ 2026-08-06 14:48 UTC (permalink / raw)
To: Jan Kara; +Cc: Christian Brauner, linux-ext4, Ojaswin Mujoo,
Venkat Rao Bagalkote
On Tue, Aug 04, 2026 at 12:41:13PM -0500, Jan Kara wrote:
> Fastcommit replay effectively happens in nojournal mode. This results in
> ext4_mark_iloc_dirty() setting I_METADATA_WRITEBACK flag and as a result
> we end up entering filesystem writeback functions. However during
> fastcommit replay s_writepages_rwsem isn't initialized yet and hence we
> crash.
>
> Fix the problem by avoiding setting I_METADATA_WRITEBACK during
> fastcommit replay. Journal replay flushes the whole block device after
> replay anyway so all metadata is properly persisted and replay is faster
It looks like this patch is only applicable if the patch series "fs:
Fix missed inode write during fsync" is applied, and in fact appears
to fix a problem introduced in "[PATCH v5 17/20] ext4: Fix data
integrity writeout issues in nojournal mode"?
- Ted
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ext4: Avoid entering writeback paths during fastcommit replay
2026-08-06 14:48 ` Theodore Tso
@ 2026-08-06 15:07 ` Jan Kara
0 siblings, 0 replies; 5+ messages in thread
From: Jan Kara @ 2026-08-06 15:07 UTC (permalink / raw)
To: Theodore Tso
Cc: Jan Kara, Christian Brauner, linux-ext4, Ojaswin Mujoo,
Venkat Rao Bagalkote
On Thu 06-08-26 10:48:47, Theodore Tso wrote:
> On Tue, Aug 04, 2026 at 12:41:13PM -0500, Jan Kara wrote:
> > Fastcommit replay effectively happens in nojournal mode. This results in
> > ext4_mark_iloc_dirty() setting I_METADATA_WRITEBACK flag and as a result
> > we end up entering filesystem writeback functions. However during
> > fastcommit replay s_writepages_rwsem isn't initialized yet and hence we
> > crash.
> >
> > Fix the problem by avoiding setting I_METADATA_WRITEBACK during
> > fastcommit replay. Journal replay flushes the whole block device after
> > replay anyway so all metadata is properly persisted and replay is faster
>
> It looks like this patch is only applicable if the patch series "fs:
> Fix missed inode write during fsync" is applied, and in fact appears
> to fix a problem introduced in "[PATCH v5 17/20] ext4: Fix data
> integrity writeout issues in nojournal mode"?
Right, yes, it's meant for Christian to pick this patch up to his tree.
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ext4: Avoid entering writeback paths during fastcommit replay
2026-08-04 10:41 [PATCH] ext4: Avoid entering writeback paths during fastcommit replay Jan Kara
2026-08-04 12:08 ` Ojaswin Mujoo
2026-08-06 14:48 ` Theodore Tso
@ 2026-08-07 4:14 ` Venkat Rao Bagalkote
2 siblings, 0 replies; 5+ messages in thread
From: Venkat Rao Bagalkote @ 2026-08-07 4:14 UTC (permalink / raw)
To: Jan Kara, Christian Brauner; +Cc: linux-ext4, Ojaswin Mujoo
On 04/08/26 4:11 pm, Jan Kara wrote:
> Fastcommit replay effectively happens in nojournal mode. This results in
> ext4_mark_iloc_dirty() setting I_METADATA_WRITEBACK flag and as a result
> we end up entering filesystem writeback functions. However during
> fastcommit replay s_writepages_rwsem isn't initialized yet and hence we
> crash.
>
> Fix the problem by avoiding setting I_METADATA_WRITEBACK during
> fastcommit replay. Journal replay flushes the whole block device after
> replay anyway so all metadata is properly persisted and replay is faster
> this way as a bonus.
>
> Fixes: c26339e1df33 ("ext4: Fix data integrity writeout issues in nojournal mode")
> Reported-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
> Reported-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
Tested this patch and its fixes the reported issue. Hence,
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Regards,
Venkat.
> fs/ext4/inode.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> Christian, please add this fixup to my sync fixing series. Thanks!
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 7a1f961cd11c..12ff84ab5741 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -6408,9 +6408,10 @@ int ext4_chunk_trans_blocks(struct inode *inode, int nrblocks)
> int ext4_mark_iloc_dirty(handle_t *handle,
> struct inode *inode, struct ext4_iloc *iloc)
> {
> + struct super_block *sb = inode->i_sb;
> int err = 0;
>
> - err = ext4_emergency_state(inode->i_sb);
> + err = ext4_emergency_state(sb);
> if (unlikely(err)) {
> put_bh(iloc->bh);
> return err;
> @@ -6425,9 +6426,13 @@ int ext4_mark_iloc_dirty(handle_t *handle,
> put_bh(iloc->bh);
> /*
> * Mark that there's metadata writeout pending for the inode so that it
> - * gets properly flushed on fsync(2) and similar.
> + * gets properly flushed on fsync(2) and similar. We don't bother for
> + * fastcommit replay as that flushes the whole bdev afterwards anyway.
> + * It is faster this way and we avoid entering fs writeback paths which
> + * aren't fully initialized yet.
> */
> - if (!EXT4_SB(inode->i_sb)->s_journal) {
> + if (!ext4_handle_valid(handle) &&
> + !(EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY)) {
> /*
> * Inode didn't need to go through dirtying, make sure it is
> * attached to wb so that writeback can handle it.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-08-07 4:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-04 10:41 [PATCH] ext4: Avoid entering writeback paths during fastcommit replay Jan Kara
2026-08-04 12:08 ` Ojaswin Mujoo
2026-08-06 14:48 ` Theodore Tso
2026-08-06 15:07 ` Jan Kara
2026-08-07 4:14 ` Venkat Rao Bagalkote
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox