From: Christian Brauner <brauner@kernel.org>
To: linux-fsdevel@vger.kernel.org, Christoph Hellwig <hch@lst.de>
Cc: "Christian Brauner \(Microsoft\)" <brauner@kernel.org>,
linux-f2fs-devel@lists.sourceforge.net,
Al Viro <viro@zeniv.linux.org.uk>,
Seth Forshee <sforshee@kernel.org>
Subject: [f2fs-dev] [PATCH 08/12] f2fs: drop posix acl handlers
Date: Wed, 25 Jan 2023 12:28:53 +0100 [thread overview]
Message-ID: <20230125-fs-acl-remove-generic-xattr-handlers-v1-8-6cf155b492b6@kernel.org> (raw)
In-Reply-To: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org>
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-f2fs-devel@lists.sourceforge.net>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
---
fs/f2fs/xattr.c | 63 ++++++++++++++++++++++++++++++++++-----------------------
1 file changed, 38 insertions(+), 25 deletions(-)
diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
index dc2e8637189e..e5bd071fac8c 100644
--- a/fs/f2fs/xattr.c
+++ b/fs/f2fs/xattr.c
@@ -189,25 +189,8 @@ const struct xattr_handler f2fs_xattr_security_handler = {
.set = f2fs_xattr_generic_set,
};
-static const struct xattr_handler *f2fs_xattr_handler_map[] = {
- [F2FS_XATTR_INDEX_USER] = &f2fs_xattr_user_handler,
-#ifdef CONFIG_F2FS_FS_POSIX_ACL
- [F2FS_XATTR_INDEX_POSIX_ACL_ACCESS] = &posix_acl_access_xattr_handler,
- [F2FS_XATTR_INDEX_POSIX_ACL_DEFAULT] = &posix_acl_default_xattr_handler,
-#endif
- [F2FS_XATTR_INDEX_TRUSTED] = &f2fs_xattr_trusted_handler,
-#ifdef CONFIG_F2FS_FS_SECURITY
- [F2FS_XATTR_INDEX_SECURITY] = &f2fs_xattr_security_handler,
-#endif
- [F2FS_XATTR_INDEX_ADVISE] = &f2fs_xattr_advise_handler,
-};
-
const struct xattr_handler *f2fs_xattr_handlers[] = {
&f2fs_xattr_user_handler,
-#ifdef CONFIG_F2FS_FS_POSIX_ACL
- &posix_acl_access_xattr_handler,
- &posix_acl_default_xattr_handler,
-#endif
&f2fs_xattr_trusted_handler,
#ifdef CONFIG_F2FS_FS_SECURITY
&f2fs_xattr_security_handler,
@@ -216,13 +199,44 @@ const struct xattr_handler *f2fs_xattr_handlers[] = {
NULL,
};
-static inline const struct xattr_handler *f2fs_xattr_handler(int index)
+static const char *f2fs_xattr_prefix(int xattr_index, struct dentry *dentry)
{
+ const char *name = NULL;
const struct xattr_handler *handler = NULL;
- if (index > 0 && index < ARRAY_SIZE(f2fs_xattr_handler_map))
- handler = f2fs_xattr_handler_map[index];
- return handler;
+ switch (xattr_index) {
+ case F2FS_XATTR_INDEX_USER:
+ handler = &f2fs_xattr_user_handler;
+ break;
+ case F2FS_XATTR_INDEX_TRUSTED:
+ handler = &f2fs_xattr_trusted_handler;
+ break;
+ case F2FS_XATTR_INDEX_ADVISE:
+ handler = &f2fs_xattr_advise_handler;
+ break;
+#ifdef CONFIG_F2FS_FS_SECURITY
+ case F2FS_XATTR_INDEX_SECURITY:
+ handler = &f2fs_xattr_security_handler;
+ break;
+#endif
+#ifdef CONFIG_F2FS_FS_POSIX_ACL
+ case F2FS_XATTR_INDEX_POSIX_ACL_ACCESS:
+ if (posix_acl_dentry_list(dentry))
+ name = XATTR_NAME_POSIX_ACL_ACCESS;
+ break;
+ case F2FS_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;
}
static struct f2fs_xattr_entry *__find_xattr(void *base_addr,
@@ -573,12 +587,12 @@ ssize_t f2fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
last_base_addr = (void *)base_addr + XATTR_SIZE(inode);
list_for_each_xattr(entry, base_addr) {
- const struct xattr_handler *handler =
- f2fs_xattr_handler(entry->e_name_index);
const char *prefix;
size_t prefix_len;
size_t size;
+ prefix = f2fs_xattr_prefix(entry->e_name_index, dentry);
+
if ((void *)(entry) + sizeof(__u32) > last_base_addr ||
(void *)XATTR_NEXT_ENTRY(entry) > last_base_addr) {
f2fs_err(F2FS_I_SB(inode), "inode (%lu) has corrupted xattr",
@@ -590,10 +604,9 @@ ssize_t f2fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
goto cleanup;
}
- if (!handler || (handler->list && !handler->list(dentry)))
+ if (!prefix)
continue;
- prefix = xattr_prefix(handler);
prefix_len = strlen(prefix);
size = prefix_len + entry->e_name_len + 1;
if (buffer) {
--
2.34.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2023-01-25 11:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-25 11:28 [f2fs-dev] [PATCH 00/12] acl: remove remaining posix acl handlers Christian Brauner
2023-01-25 11:28 ` Christian Brauner [this message]
2023-01-30 9:10 ` Christian Brauner
2023-01-30 9:16 ` Christoph Hellwig
2023-01-30 10:23 ` Christian Brauner
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=20230125-fs-acl-remove-generic-xattr-handlers-v1-8-6cf155b492b6@kernel.org \
--to=brauner@kernel.org \
--cc=hch@lst.de \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=sforshee@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).