Re: [PATCH v2] erofs-utils: mkfs: emit an inode's xattrs in a canonical order

Gao Xiang <[email protected]> Tue, 4 Aug 2026 07:23:27 +0800
Newsgroups org.ozlabs.lists.linux-erofs
Message-ID <[email protected]>
On Mon, Aug 03, 2026 at 01:52:37PM +0200, Martin Pitt wrote:
> listxattr(2) makes no promise about the order it reports, and
> filesystems disagree: tmpfs reports them in insertion order on recent
> kernels (or in a random order on older ones), while ext4 and btrfs
> report their own on-disk order.
> 
> mkfs.erofs stored an inode's attributes in exactly the order it received
> them, so staging the same tree on different filesystems (or on older
> kernels merely twice in the same place) produced images that differed
> byte for byte. That made EROFS images unreproducible.
> 
> Insert into the inode's list ordered by attribute name instead, and move
> inline attributes onto the on-stack list with list_add_tail() so the
> emitted order matches. The shared attribute pool already sorts by the
> same key, so generalize comp_shared_xattritem() into
> erofs_comp_xattritem() and use it for both.
> 
> The length tiebreak previously returned only 0 or 1, never a negative
> value; make it a proper three-way comparison with cmpsgn().
> 
> Suggested-by: Gao Xiang <[email protected]>
> Signed-off-by: Martin Pitt <[email protected]>

Thanks, applied.

Thanks,
Gao Xiang