Hi,

On 2023/5/18 10:45, Jingbo Xu wrote:
Introduce erofs_xattr_iter_fixup_aligned() helper where
it.ofs <= EROFS_BLKSIZ is mandatory.

Signed-off-by: Jingbo Xu <[email protected]>
---
  fs/erofs/xattr.c | 79 +++++++++++++++++++++---------------------------
  1 file changed, 35 insertions(+), 44 deletions(-)

diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c
index bbfe7ce170d2..b79be2a556ba 100644
--- a/fs/erofs/xattr.c
+++ b/fs/erofs/xattr.c
@@ -29,6 +29,28 @@ struct xattr_iter {
        unsigned int ofs;
  };
+static inline int erofs_xattr_iter_fixup(struct xattr_iter *it)
+{
+       if (it->ofs < it->sb->s_blocksize)
+               return 0;
+
+       it->blkaddr += erofs_blknr(it->sb, it->ofs);
+       it->kaddr = erofs_read_metabuf(&it->buf, it->sb, it->blkaddr, 
EROFS_KMAP);

could we use a new buf interface to init_metabuf at once?

+       if (IS_ERR(it->kaddr))
+               return PTR_ERR(it->kaddr);
+       it->ofs = erofs_blkoff(it->sb, it->ofs);
+       return 0;
+}
+
+static inline int erofs_xattr_iter_fixup_aligned(struct xattr_iter *it)

Since we're doing cleanup, this name sounds confusing to me
since here the meaning is actually "we don't allow pos >
blksize", IOWs, any pos <= blksize is allowed here, so
'aligned' is not accurate.

Could we think out a better one?

Thanks,
Gao Xiang

Reply via email to