* [PATCH] erofs: reset buf->off in erofs_init_metabuf()
@ 2026-11-11 14:15 Zhan Xusheng
0 siblings, 0 replies; only message in thread
From: Zhan Xusheng @ 2026-11-11 14:15 UTC (permalink / raw)
To: xiang
Cc: chao, zbestahu, jefflexu, dhavale, hongbohbli, guochunhai,
linux-erofs, linux-kernel, zhanxusheng
From: Zhan Xusheng <zhanxusheng@xiaomi.com>
erofs_init_metabuf() sets buf->off only for the block device and keeps
the old value when it switches to the metabox or the managed cache.
erofs_bread() adds buf->off to every offset, so the result depends on
how the buffer was last initialized.
getxattr and listxattr init the same buffer twice, for the inline and
the shared xattrs, with in_metabox taken from different places. On a
block device mount with fsoffset=, if the inode is outside the metabox
and COMPAT_SHARED_EA_IN_METABOX is set, the shared xattrs are read at
their metabox offset plus fsoffset. The same image mounted file-backed
returns the right values.
Reset buf->off on every init.
Fixes: 414091322c63 ("erofs: implement metadata compression")
Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
---
Tested with a hand-edited image, as mkfs.erofs does not produce this
layout.
---
fs/erofs/data.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 968303afd620..da4f3e7bd443 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -60,6 +60,7 @@ int erofs_init_metabuf(struct erofs_buf *buf, struct super_block *sb,
struct erofs_sb_info *sbi = EROFS_SB(sb);
buf->mc = false;
+ buf->off = 0;
if (in_metabox) {
if (unlikely(!sbi->metabox_inode))
return -EFSCORRUPTED;
base-commit: 7c26dc33ea7bb677db294bfb4e58d4207477c9e3
--
2.43.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-11 14:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-11 14:15 [PATCH] erofs: reset buf->off in erofs_init_metabuf() Zhan Xusheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®