Hello,

Milos Nikic, le lun. 31 août 2026 08:54:23 -0700, a ecrit:
> But from what I can tell, it seems that memory misalignment in the
> ext2_lifeboat cache is the root of the problem.

What memory misalignment?

> @@ -162,7 +162,7 @@ struct journal_lifeboat
>    uint64_t alloc_mask[JRNL_LIFEBOAT_ALLOC_MASK_LEN];
>  
>    /* The pre-allocated payload pool (512 * 4KB = 2MB) */
> -  char payloads[JRNL_LIFEBOAT_CAPACITY][4096];
> +  char payloads[JRNL_LIFEBOAT_CAPACITY][4096] __attribute__((aligned(4096)));
>  };
>  
>  static struct journal_lifeboat ext2_lifeboat;

I don't see the benefit of this? It is only memcpy'd or passed to
store_write, which cope with unaligned data fine.

Aligning would help with performance, though.

That actually makes me realize: this 4096 here is hardcoded, and
block_size is assumed to be that.

Better make payloads a char*, and allocate the whole payloads array
dynamically with mmap(JRNL_LIFEBOAT_CAPACITY*block_size) and access it
with &payloads[i*block_size]

> This small patch fixes the alignment and also adds

As always in all software projects, please keep unrelated changes
separate, so they can be tested independently easily.

> a physical hardware flush to the end of the journal shutdown.

> diff --git a/ext2fs/journal.c b/ext2fs/journal.c
> index 91b8e64ff..8b03604ab 100644
> --- a/ext2fs/journal.c
> +++ b/ext2fs/journal.c
> @@ -1459,6 +1459,7 @@ journal_quiesce_checkpoints (void)
>    /* Clear the list and write s_start = 0 to the JBD2 superblock */
>    journal_clear_checkpoint_list_locked (ext2_journal);
>    JOURNAL_UNLOCK (ext2_journal);
> +  flush_to_disk ();
>  }

I don't see why adding it here: it's only at filesystem shutdown that
we want to make sure that the updates hit the disk. Put another way,
it's diskfs_shutdown_pager that we want to see flush things, and that
already calls store_sync, so there is some problem somewhere along the
path, to be just fixed rather than add flushing calls that would mostly
brown-tape-fix with performance impact.

With regards,
Samuel

Reply via email to