Last cycle we introduced a new posix acl api. Filesystems now only need to implement the inode operations for posix acls. The generic xattr handlers aren't used anymore by the vfs and will be completely removed. Keeping the handler around is confusing and gives the false impression that the xattr infrastructure of the vfs is used to interact with posix acls when it really isn't anymore. For this to work we simply rework the ->listxattr() inode operation to not rely on the generix posix acl handlers anymore. Cc: <linux-erofs@xxxxxxxxxxxxxxxx> Signed-off-by: Christian Brauner (Microsoft) <brauner@xxxxxxxxxx> --- fs/erofs/xattr.c | 49 +++++++++++++++++++++++++++++++++++++++---------- fs/erofs/xattr.h | 21 --------------------- 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c index a62fb8a3318a..a787e74d9a21 100644 --- a/fs/erofs/xattr.c +++ b/fs/erofs/xattr.c @@ -469,10 +469,6 @@ const struct xattr_handler __maybe_unused erofs_xattr_security_handler = { const struct xattr_handler *erofs_xattr_handlers[] = { &erofs_xattr_user_handler, -#ifdef CONFIG_EROFS_FS_POSIX_ACL - &posix_acl_access_xattr_handler, - &posix_acl_default_xattr_handler, -#endif &erofs_xattr_trusted_handler, #ifdef CONFIG_EROFS_FS_SECURITY &erofs_xattr_security_handler, @@ -480,6 +476,43 @@ const struct xattr_handler *erofs_xattr_handlers[] = { NULL, }; +static const char *erofs_xattr_prefix(int xattr_index, struct dentry *dentry) +{ + const char *name = NULL; + const struct xattr_handler *handler = NULL; + + switch (xattr_index) { + case EROFS_XATTR_INDEX_USER: + handler = &erofs_xattr_user_handler; + break; + case EROFS_XATTR_INDEX_TRUSTED: + handler = &erofs_xattr_trusted_handler; + break; +#ifdef CONFIG_EROFS_FS_SECURITY + case EROFS_XATTR_INDEX_SECURITY: + handler = &erofs_xattr_security_handler; + break; +#endif +#ifdef CONFIG_EROFS_FS_POSIX_ACL + case EROFS_XATTR_INDEX_POSIX_ACL_ACCESS: + if (posix_acl_dentry_list(dentry)) + name = XATTR_NAME_POSIX_ACL_ACCESS; + break; + case EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT: + if (posix_acl_dentry_list(dentry)) + name = XATTR_NAME_POSIX_ACL_DEFAULT; + break; +#endif + default: + return NULL; + } + + if (xattr_dentry_list(handler, dentry)) + name = xattr_prefix(handler); + + return name; +} + struct listxattr_iter { struct xattr_iter it; @@ -496,13 +529,9 @@ static int xattr_entrylist(struct xattr_iter *_it, unsigned int prefix_len; const char *prefix; - const struct xattr_handler *h = - erofs_xattr_handler(entry->e_name_index); - - if (!h || (h->list && !h->list(it->dentry))) + prefix = erofs_xattr_prefix(entry->e_name_index, it->dentry); + if (!prefix) return 1; - - prefix = xattr_prefix(h); prefix_len = strlen(prefix); if (!it->buffer) { diff --git a/fs/erofs/xattr.h b/fs/erofs/xattr.h index 0a43c9ee9f8f..9376cbdc32d8 100644 --- a/fs/erofs/xattr.h +++ b/fs/erofs/xattr.h @@ -40,27 +40,6 @@ static inline unsigned int xattrblock_offset(struct erofs_sb_info *sbi, extern const struct xattr_handler erofs_xattr_user_handler; extern const struct xattr_handler erofs_xattr_trusted_handler; extern const struct xattr_handler erofs_xattr_security_handler; - -static inline const struct xattr_handler *erofs_xattr_handler(unsigned int idx) -{ - static const struct xattr_handler *xattr_handler_map[] = { - [EROFS_XATTR_INDEX_USER] = &erofs_xattr_user_handler, -#ifdef CONFIG_EROFS_FS_POSIX_ACL - [EROFS_XATTR_INDEX_POSIX_ACL_ACCESS] = - &posix_acl_access_xattr_handler, - [EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT] = - &posix_acl_default_xattr_handler, -#endif - [EROFS_XATTR_INDEX_TRUSTED] = &erofs_xattr_trusted_handler, -#ifdef CONFIG_EROFS_FS_SECURITY - [EROFS_XATTR_INDEX_SECURITY] = &erofs_xattr_security_handler, -#endif - }; - - return idx && idx < ARRAY_SIZE(xattr_handler_map) ? - xattr_handler_map[idx] : NULL; -} - extern const struct xattr_handler *erofs_xattr_handlers[]; int erofs_getxattr(struct inode *, int, const char *, void *, size_t); -- 2.34.1