From: Yue Hu <zbestahu@gmail.com>
To: Jingbo Xu <jefflexu@linux.alibaba.com>
Cc: xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org,
linux-kernel@vger.kernel.org, huyue2@coolpad.com,
zhangwen@coolpad.com
Subject: Re: [PATCH v2 1/8] erofs: move several xattr helpers into xattr.c
Date: Fri, 31 Mar 2023 11:59:19 +0800 [thread overview]
Message-ID: <20230331115919.0000002d.zbestahu@gmail.com> (raw)
In-Reply-To: <20230330082910.125374-2-jefflexu@linux.alibaba.com>
On Thu, 30 Mar 2023 16:29:03 +0800
Jingbo Xu <jefflexu@linux.alibaba.com> wrote:
> Move xattrblock_addr() and xattrblock_offset() helpers into xattr.c,
> as they are not used outside of xattr.c.
>
> inlinexattr_header_size() has only one caller, and thus make it inlined
> into the caller directly.
>
> Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Reviewed-by: Yue Hu <huyue2@coolpad.com>
> ---
> fs/erofs/xattr.c | 48 +++++++++++++++++++++++++++++-------------------
> fs/erofs/xattr.h | 23 -----------------------
> 2 files changed, 29 insertions(+), 42 deletions(-)
>
> diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c
> index 459caa3cd65d..9ccd57581bc7 100644
> --- a/fs/erofs/xattr.c
> +++ b/fs/erofs/xattr.c
> @@ -7,6 +7,19 @@
> #include <linux/security.h>
> #include "xattr.h"
>
> +static inline erofs_blk_t erofs_xattr_blkaddr(struct super_block *sb,
> + unsigned int xattr_id)
> +{
> + return EROFS_SB(sb)->xattr_blkaddr +
> + erofs_blknr(sb, xattr_id * sizeof(__u32));
> +}
> +
> +static inline unsigned int erofs_xattr_blkoff(struct super_block *sb,
> + unsigned int xattr_id)
> +{
> + return erofs_blkoff(sb, xattr_id * sizeof(__u32));
> +}
> +
> struct xattr_iter {
> struct super_block *sb;
> struct erofs_buf buf;
> @@ -157,7 +170,8 @@ static int inline_xattr_iter_begin(struct xattr_iter *it,
> struct erofs_inode *const vi = EROFS_I(inode);
> unsigned int xattr_header_sz, inline_xattr_ofs;
>
> - xattr_header_sz = inlinexattr_header_size(inode);
> + xattr_header_sz = sizeof(struct erofs_xattr_ibody_header) +
> + sizeof(u32) * vi->xattr_shared_count;
> if (xattr_header_sz >= vi->xattr_isize) {
> DBG_BUGON(xattr_header_sz > vi->xattr_isize);
> return -ENOATTR;
> @@ -351,20 +365,18 @@ static int inline_getxattr(struct inode *inode, struct getxattr_iter *it)
> static int shared_getxattr(struct inode *inode, struct getxattr_iter *it)
> {
> struct erofs_inode *const vi = EROFS_I(inode);
> - struct super_block *const sb = inode->i_sb;
> - unsigned int i;
> + struct super_block *const sb = it->it.sb;
> + unsigned int i, xsid;
> int ret = -ENOATTR;
>
> for (i = 0; i < vi->xattr_shared_count; ++i) {
> - erofs_blk_t blkaddr =
> - xattrblock_addr(sb, vi->xattr_shared_xattrs[i]);
> -
> - it->it.ofs = xattrblock_offset(sb, vi->xattr_shared_xattrs[i]);
> - it->it.kaddr = erofs_read_metabuf(&it->it.buf, sb, blkaddr,
> - EROFS_KMAP);
> + xsid = vi->xattr_shared_xattrs[i];
> + it->it.blkaddr = erofs_xattr_blkaddr(sb, xsid);
> + it->it.ofs = erofs_xattr_blkoff(sb, xsid);
> + it->it.kaddr = erofs_read_metabuf(&it->it.buf, sb,
> + it->it.blkaddr, EROFS_KMAP);
> if (IS_ERR(it->it.kaddr))
> return PTR_ERR(it->it.kaddr);
> - it->it.blkaddr = blkaddr;
>
> ret = xattr_foreach(&it->it, &find_xattr_handlers, NULL);
> if (ret != -ENOATTR)
> @@ -562,20 +574,18 @@ static int shared_listxattr(struct listxattr_iter *it)
> {
> struct inode *const inode = d_inode(it->dentry);
> struct erofs_inode *const vi = EROFS_I(inode);
> - struct super_block *const sb = inode->i_sb;
> - unsigned int i;
> + struct super_block *const sb = it->it.sb;
> + unsigned int i, xsid;
> int ret = 0;
>
> for (i = 0; i < vi->xattr_shared_count; ++i) {
> - erofs_blk_t blkaddr =
> - xattrblock_addr(sb, vi->xattr_shared_xattrs[i]);
> -
> - it->it.ofs = xattrblock_offset(sb, vi->xattr_shared_xattrs[i]);
> - it->it.kaddr = erofs_read_metabuf(&it->it.buf, sb, blkaddr,
> - EROFS_KMAP);
> + xsid = vi->xattr_shared_xattrs[i];
> + it->it.blkaddr = erofs_xattr_blkaddr(sb, xsid);
> + it->it.ofs = erofs_xattr_blkoff(sb, xsid);
> + it->it.kaddr = erofs_read_metabuf(&it->it.buf, sb,
> + it->it.blkaddr, EROFS_KMAP);
> if (IS_ERR(it->it.kaddr))
> return PTR_ERR(it->it.kaddr);
> - it->it.blkaddr = blkaddr;
>
> ret = xattr_foreach(&it->it, &list_xattr_handlers, NULL);
> if (ret)
> diff --git a/fs/erofs/xattr.h b/fs/erofs/xattr.h
> index f7a21aaa9755..a65158cba14f 100644
> --- a/fs/erofs/xattr.h
> +++ b/fs/erofs/xattr.h
> @@ -13,29 +13,6 @@
> /* Attribute not found */
> #define ENOATTR ENODATA
>
> -static inline unsigned int inlinexattr_header_size(struct inode *inode)
> -{
> - return sizeof(struct erofs_xattr_ibody_header) +
> - sizeof(u32) * EROFS_I(inode)->xattr_shared_count;
> -}
> -
> -static inline erofs_blk_t xattrblock_addr(struct super_block *sb,
> - unsigned int xattr_id)
> -{
> -#ifdef CONFIG_EROFS_FS_XATTR
> - return EROFS_SB(sb)->xattr_blkaddr +
> - xattr_id * sizeof(__u32) / sb->s_blocksize;
> -#else
> - return 0;
> -#endif
> -}
> -
> -static inline unsigned int xattrblock_offset(struct super_block *sb,
> - unsigned int xattr_id)
> -{
> - return (xattr_id * sizeof(__u32)) % sb->s_blocksize;
> -}
> -
> #ifdef CONFIG_EROFS_FS_XATTR
> extern const struct xattr_handler erofs_xattr_user_handler;
> extern const struct xattr_handler erofs_xattr_trusted_handler;
next prev parent reply other threads:[~2023-03-31 3:52 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-30 8:29 [PATCH v2 0/8] erofs: cleanup of xattr handling Jingbo Xu
2023-03-30 8:29 ` [PATCH v2 1/8] erofs: move several xattr helpers into xattr.c Jingbo Xu
2023-03-30 9:34 ` Gao Xiang
2023-03-31 3:59 ` Yue Hu [this message]
2023-04-16 14:21 ` Chao Yu
2023-03-30 8:29 ` [PATCH v2 2/8] erofs: rename init_inode_xattrs with erofs_ prefix Jingbo Xu
2023-03-31 6:11 ` Yue Hu
2023-04-16 14:21 ` Chao Yu
2023-03-30 8:29 ` [PATCH v2 3/8] erofs: simplify erofs_xattr_generic_get() Jingbo Xu
2023-03-31 2:43 ` Gao Xiang
2023-03-31 6:24 ` Yue Hu
2023-04-16 14:29 ` Chao Yu
2023-03-30 8:29 ` [PATCH v2 4/8] erofs: introduce erofs_xattr_iter_fixup_aligned() helper Jingbo Xu
2023-03-30 8:29 ` [PATCH v2 5/8] erofs: unify xattr_iter structures Jingbo Xu
2023-03-30 8:29 ` [PATCH v2 6/8] erofs: make the size of read data stored in buffer_ofs Jingbo Xu
2023-03-30 8:29 ` [PATCH v2 7/8] erofs: unify inline/share xattr iterators for listxattr/getxattr Jingbo Xu
2023-03-30 8:29 ` [PATCH v2 8/8] erofs: use separate xattr parsers " Jingbo Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230331115919.0000002d.zbestahu@gmail.com \
--to=zbestahu@gmail.com \
--cc=chao@kernel.org \
--cc=huyue2@coolpad.com \
--cc=jefflexu@linux.alibaba.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xiang@kernel.org \
--cc=zhangwen@coolpad.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox