* [PATCH v3 06/10] reiserfs: rework ->listxattr() implementation
2023-02-01 13:14 [PATCH v3 00/10] acl: drop posix acl handlers from xattr handlers Christian Brauner
@ 2023-02-01 13:14 ` Christian Brauner
2023-02-01 13:14 ` [PATCH v3 08/10] reiserfs: rework priv inode handling Christian Brauner
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Christian Brauner @ 2023-02-01 13:14 UTC (permalink / raw)
To: linux-fsdevel, Christoph Hellwig
Cc: Al Viro, Seth Forshee, Christian Brauner (Microsoft),
reiserfs-devel
Rework reiserfs so it doesn't have to rely on the dummy xattr handlers
in its s_xattr list anymore as this is completely unused for setting and
getting posix acls.
Cc: reiserfs-devel@vger.kernel.org
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
---
Changes in v3:
- Patch unchanged.
Changes in v2:
- Rework patch to account for reiserfs quirks.
---
fs/reiserfs/xattr.c | 46 +++++++++++++++++++++++++---------------------
1 file changed, 25 insertions(+), 21 deletions(-)
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index 8b2d52443f41..0b949dc45484 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -52,6 +52,7 @@
#include <linux/quotaops.h>
#include <linux/security.h>
#include <linux/posix_acl_xattr.h>
+#include <linux/xattr.h>
#define PRIVROOT_NAME ".reiserfs_priv"
#define XAROOT_NAME "xattrs"
@@ -770,23 +771,34 @@ reiserfs_xattr_get(struct inode *inode, const char *name, void *buffer,
(handler) != NULL; \
(handler) = *(handlers)++)
+static inline bool reiserfs_posix_acl_list(const char *name,
+ struct dentry *dentry)
+{
+ return (posix_acl_type(name) >= 0) &&
+ IS_POSIXACL(d_backing_inode(dentry));
+}
+
/* This is the implementation for the xattr plugin infrastructure */
-static inline const struct xattr_handler *
-find_xattr_handler_prefix(const struct xattr_handler **handlers,
- const char *name)
+static inline bool reiserfs_xattr_list(const struct xattr_handler **handlers,
+ const char *name, struct dentry *dentry)
{
- const struct xattr_handler *xah;
+ if (handlers) {
+ const struct xattr_handler *xah = NULL;
- if (!handlers)
- return NULL;
+ for_each_xattr_handler(handlers, xah) {
+ const char *prefix = xattr_prefix(xah);
- for_each_xattr_handler(handlers, xah) {
- const char *prefix = xattr_prefix(xah);
- if (strncmp(prefix, name, strlen(prefix)) == 0)
- break;
+ if (strncmp(prefix, name, strlen(prefix)))
+ continue;
+
+ if (!xattr_handler_can_list(xah, dentry))
+ return false;
+
+ return true;
+ }
}
- return xah;
+ return reiserfs_posix_acl_list(name, dentry);
}
struct listxattr_buf {
@@ -807,12 +819,8 @@ static bool listxattr_filler(struct dir_context *ctx, const char *name,
if (name[0] != '.' ||
(namelen != 1 && (name[1] != '.' || namelen != 2))) {
- const struct xattr_handler *handler;
-
- handler = find_xattr_handler_prefix(b->dentry->d_sb->s_xattr,
- name);
- if (!handler /* Unsupported xattr name */ ||
- (handler->list && !handler->list(b->dentry)))
+ if (!reiserfs_xattr_list(b->dentry->d_sb->s_xattr, name,
+ b->dentry))
return true;
size = namelen + 1;
if (b->buf) {
@@ -910,10 +918,6 @@ const struct xattr_handler *reiserfs_xattr_handlers[] = {
#endif
#ifdef CONFIG_REISERFS_FS_SECURITY
&reiserfs_xattr_security_handler,
-#endif
-#ifdef CONFIG_REISERFS_FS_POSIX_ACL
- &posix_acl_access_xattr_handler,
- &posix_acl_default_xattr_handler,
#endif
NULL
};
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v3 08/10] reiserfs: rework priv inode handling
2023-02-01 13:14 [PATCH v3 00/10] acl: drop posix acl handlers from xattr handlers Christian Brauner
2023-02-01 13:14 ` [PATCH v3 06/10] reiserfs: rework ->listxattr() implementation Christian Brauner
@ 2023-02-01 13:14 ` Christian Brauner
2023-02-01 13:30 ` [PATCH v3 00/10] acl: drop posix acl handlers from xattr handlers Christoph Hellwig
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Christian Brauner @ 2023-02-01 13:14 UTC (permalink / raw)
To: linux-fsdevel, Christoph Hellwig
Cc: Al Viro, Seth Forshee, Christian Brauner (Microsoft),
reiserfs-devel
Reiserfs is the only filesystem that removes IOP_XATTR without also
using a set of dedicated inode operations at the same time that nop all
xattr related inode operations. This means we need to have a IOP_XATTR
check in vfs_listxattr() instead of just being able to check for
->listxatt() being implemented.
Introduce a dedicated set of nop inode operations that are used when
IOP_XATTR is removed, allowing us to remove that check from
vfs_listxattr(). This in turn allows us to completely decouple POSIX ACLs from
IOP_XATTR.
Cc: reiserfs-devel@vger.kernel.org
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
---
Changes in v3:
- Patch introduced.
---
fs/reiserfs/file.c | 7 +++++++
fs/reiserfs/inode.c | 6 ++----
fs/reiserfs/namei.c | 50 +++++++++++++++++++++++++++++++++++++++++++++-----
fs/reiserfs/reiserfs.h | 2 ++
fs/reiserfs/xattr.c | 9 +++------
5 files changed, 59 insertions(+), 15 deletions(-)
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index 467d13da198f..b54cc7048f02 100644
--- a/fs/reiserfs/file.c
+++ b/fs/reiserfs/file.c
@@ -261,3 +261,10 @@ const struct inode_operations reiserfs_file_inode_operations = {
.fileattr_get = reiserfs_fileattr_get,
.fileattr_set = reiserfs_fileattr_set,
};
+
+const struct inode_operations reiserfs_priv_file_inode_operations = {
+ .setattr = reiserfs_setattr,
+ .permission = reiserfs_permission,
+ .fileattr_get = reiserfs_fileattr_get,
+ .fileattr_set = reiserfs_fileattr_set,
+};
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index c7d1fa526dea..4ec357919588 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -2087,10 +2087,8 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
* Mark it private if we're creating the privroot
* or something under it.
*/
- if (IS_PRIVATE(dir) || dentry == REISERFS_SB(sb)->priv_root) {
- inode->i_flags |= S_PRIVATE;
- inode->i_opflags &= ~IOP_XATTR;
- }
+ if (IS_PRIVATE(dir) || dentry == REISERFS_SB(sb)->priv_root)
+ reiserfs_init_priv_inode(inode);
if (reiserfs_posixacl(inode->i_sb)) {
reiserfs_write_unlock(inode->i_sb);
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
index 0b8aa99749f1..2f0c721c8ac9 100644
--- a/fs/reiserfs/namei.c
+++ b/fs/reiserfs/namei.c
@@ -378,13 +378,11 @@ static struct dentry *reiserfs_lookup(struct inode *dir, struct dentry *dentry,
/*
* Propagate the private flag so we know we're
- * in the priv tree. Also clear IOP_XATTR
+ * in the priv tree. Also clear xattr support
* since we don't have xattrs on xattr files.
*/
- if (IS_PRIVATE(dir)) {
- inode->i_flags |= S_PRIVATE;
- inode->i_opflags &= ~IOP_XATTR;
- }
+ if (IS_PRIVATE(dir))
+ reiserfs_init_priv_inode(inode);
}
reiserfs_write_unlock(dir->i_sb);
if (retval == IO_ERROR) {
@@ -1649,6 +1647,48 @@ static int reiserfs_rename(struct user_namespace *mnt_userns,
return retval;
}
+static const struct inode_operations reiserfs_priv_dir_inode_operations = {
+ .create = reiserfs_create,
+ .lookup = reiserfs_lookup,
+ .link = reiserfs_link,
+ .unlink = reiserfs_unlink,
+ .symlink = reiserfs_symlink,
+ .mkdir = reiserfs_mkdir,
+ .rmdir = reiserfs_rmdir,
+ .mknod = reiserfs_mknod,
+ .rename = reiserfs_rename,
+ .setattr = reiserfs_setattr,
+ .permission = reiserfs_permission,
+ .fileattr_get = reiserfs_fileattr_get,
+ .fileattr_set = reiserfs_fileattr_set,
+};
+
+static const struct inode_operations reiserfs_priv_symlink_inode_operations = {
+ .get_link = page_get_link,
+ .setattr = reiserfs_setattr,
+ .permission = reiserfs_permission,
+};
+
+static const struct inode_operations reiserfs_priv_special_inode_operations = {
+ .setattr = reiserfs_setattr,
+ .permission = reiserfs_permission,
+};
+
+void reiserfs_init_priv_inode(struct inode *inode)
+{
+ inode->i_flags |= S_PRIVATE;
+ inode->i_opflags &= ~IOP_XATTR;
+
+ if (S_ISREG(inode->i_mode))
+ inode->i_op = &reiserfs_priv_file_inode_operations;
+ else if (S_ISDIR(inode->i_mode))
+ inode->i_op = &reiserfs_priv_dir_inode_operations;
+ else if (S_ISLNK(inode->i_mode))
+ inode->i_op = &reiserfs_priv_symlink_inode_operations;
+ else
+ inode->i_op = &reiserfs_priv_special_inode_operations;
+}
+
/* directories can handle most operations... */
const struct inode_operations reiserfs_dir_inode_operations = {
.create = reiserfs_create,
diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
index 3aa928ec527a..d4dd39a66d80 100644
--- a/fs/reiserfs/reiserfs.h
+++ b/fs/reiserfs/reiserfs.h
@@ -3106,6 +3106,7 @@ int reiserfs_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len);
/* namei.c */
+void reiserfs_init_priv_inode(struct inode *inode);
void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
int search_by_entry_key(struct super_block *sb, const struct cpu_key *key,
struct treepath *path, struct reiserfs_dir_entry *de);
@@ -3175,6 +3176,7 @@ void reiserfs_unmap_buffer(struct buffer_head *);
/* file.c */
extern const struct inode_operations reiserfs_file_inode_operations;
+extern const struct inode_operations reiserfs_priv_file_inode_operations;
extern const struct file_operations reiserfs_file_operations;
extern const struct address_space_operations reiserfs_address_space_operations;
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index 0b949dc45484..11b32bbd656d 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -896,8 +896,7 @@ static int create_privroot(struct dentry *dentry)
return -EOPNOTSUPP;
}
- d_inode(dentry)->i_flags |= S_PRIVATE;
- d_inode(dentry)->i_opflags &= ~IOP_XATTR;
+ reiserfs_init_priv_inode(d_inode(dentry));
reiserfs_info(dentry->d_sb, "Created %s - reserved for xattr "
"storage.\n", PRIVROOT_NAME);
@@ -979,10 +978,8 @@ int reiserfs_lookup_privroot(struct super_block *s)
if (!IS_ERR(dentry)) {
REISERFS_SB(s)->priv_root = dentry;
d_set_d_op(dentry, &xattr_lookup_poison_ops);
- if (d_really_is_positive(dentry)) {
- d_inode(dentry)->i_flags |= S_PRIVATE;
- d_inode(dentry)->i_opflags &= ~IOP_XATTR;
- }
+ if (d_really_is_positive(dentry))
+ reiserfs_init_priv_inode(d_inode(dentry));
} else
err = PTR_ERR(dentry);
inode_unlock(d_inode(s->s_root));
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH v3 00/10] acl: drop posix acl handlers from xattr handlers
2023-02-01 13:14 [PATCH v3 00/10] acl: drop posix acl handlers from xattr handlers Christian Brauner
2023-02-01 13:14 ` [PATCH v3 06/10] reiserfs: rework ->listxattr() implementation Christian Brauner
2023-02-01 13:14 ` [PATCH v3 08/10] reiserfs: rework priv inode handling Christian Brauner
@ 2023-02-01 13:30 ` Christoph Hellwig
2023-02-01 13:42 ` Christian Brauner
2023-03-06 9:23 ` Christian Brauner
2023-04-26 23:07 ` [f2fs-dev] " patchwork-bot+f2fs
4 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2023-02-01 13:30 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-unionfs, reiserfs-devel, linux-f2fs-devel, linux-mtd,
Seth Forshee, linux-fsdevel, linux-ext4, linux-erofs,
Christoph Hellwig, Al Viro
This version looks good to me, but I'd really prefer if a reiserfs
insider could look over the reiserfs patches.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 00/10] acl: drop posix acl handlers from xattr handlers
2023-02-01 13:30 ` [PATCH v3 00/10] acl: drop posix acl handlers from xattr handlers Christoph Hellwig
@ 2023-02-01 13:42 ` Christian Brauner
2023-03-06 9:26 ` Christian Brauner
0 siblings, 1 reply; 8+ messages in thread
From: Christian Brauner @ 2023-02-01 13:42 UTC (permalink / raw)
To: Christoph Hellwig
Cc: linux-fsdevel, Al Viro, Seth Forshee, linux-f2fs-devel,
linux-erofs, linux-ext4, linux-mtd, reiserfs-devel, linux-unionfs
On Wed, Feb 01, 2023 at 02:30:20PM +0100, Christoph Hellwig wrote:
> This version looks good to me, but I'd really prefer if a reiserfs
> insider could look over the reiserfs patches.
I consider this material for v6.4 even with an -rc8 for v6.3. So there's
time but we shouldn't block it on reiserfs. Especially, since it's
marked deprecated.
Fwiw, I've tested reiserfs with xfstests on a kernel with and without
this series applied and there's no regressions. But it's overall pretty
buggy at least according to xfstests. Which is expected, I guess.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 00/10] acl: drop posix acl handlers from xattr handlers
2023-02-01 13:42 ` Christian Brauner
@ 2023-03-06 9:26 ` Christian Brauner
0 siblings, 0 replies; 8+ messages in thread
From: Christian Brauner @ 2023-03-06 9:26 UTC (permalink / raw)
To: Christoph Hellwig
Cc: linux-fsdevel, Al Viro, Seth Forshee, linux-f2fs-devel,
linux-erofs, linux-ext4, linux-mtd, reiserfs-devel, linux-unionfs
On Wed, Feb 01, 2023 at 02:42:54PM +0100, Christian Brauner wrote:
> On Wed, Feb 01, 2023 at 02:30:20PM +0100, Christoph Hellwig wrote:
> > This version looks good to me, but I'd really prefer if a reiserfs
> > insider could look over the reiserfs patches.
>
> I consider this material for v6.4 even with an -rc8 for v6.3. So there's
> time but we shouldn't block it on reiserfs. Especially, since it's
> marked deprecated.
So I've applied this now. If there's still someone interested in
checking the reiserfs bits more than what we did with xfstests they
should please do so. But I don't want to hold up this series waiting for
that to happen.
>
> Fwiw, I've tested reiserfs with xfstests on a kernel with and without
> this series applied and there's no regressions. But it's overall pretty
> buggy at least according to xfstests. Which is expected, I guess.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 00/10] acl: drop posix acl handlers from xattr handlers
2023-02-01 13:14 [PATCH v3 00/10] acl: drop posix acl handlers from xattr handlers Christian Brauner
` (2 preceding siblings ...)
2023-02-01 13:30 ` [PATCH v3 00/10] acl: drop posix acl handlers from xattr handlers Christoph Hellwig
@ 2023-03-06 9:23 ` Christian Brauner
2023-04-26 23:07 ` [f2fs-dev] " patchwork-bot+f2fs
4 siblings, 0 replies; 8+ messages in thread
From: Christian Brauner @ 2023-03-06 9:23 UTC (permalink / raw)
To: linux-fsdevel, Christoph Hellwig, Christian Brauner
Cc: Al Viro, Seth Forshee, linux-f2fs-devel, linux-erofs, linux-ext4,
linux-mtd, reiserfs-devel, linux-unionfs
From: Christian Brauner (Microsoft) <brauner@kernel.org>
On Wed, 01 Feb 2023 14:14:51 +0100, Christian Brauner wrote:
> Hey everyone,
>
> After we finished the introduction of the new posix acl api last cycle
> we still left the generic POSIX ACL xattr handlers around in the
> filesystems xattr handlers for two reasons:
>
> (1) Because a few filesystems rely on the ->list() method of the generic
> POSIX ACL xattr handlers in their ->listxattr() inode operation.
> (2) POSIX ACLs are only available if IOP_XATTR is raised. The IOP_XATTR
> flag is raised in inode_init_always() based on whether the
> sb->s_xattr pointer is non-NULL. IOW, the registered xattr handlers
> of the filesystem are used to raise IOP_XATTR.
> If we were to remove the generic POSIX ACL xattr handlers from all
> filesystems we would risk regressing filesystems that only implement
> POSIX ACL support and no other xattrs (nfs3 comes to mind).
>
> [...]
With v6.3-rc1 out, I've applied this now. Please keep an eye out for any
regressions as this has been a delicate undertaking:
[01/10] xattr: simplify listxattr helpers
commit: f2620f166e2a4db08f016b7b30b904ab28c265e4
[02/10] xattr: add listxattr helper
commit: 2db8a948046cab3a2f707561592906a3d096972f
[03/10] xattr: remove unused argument
commit: 831be973aa21d1cf8948bf4b1d4e73e6d5d028c0
[04/10] fs: drop unused posix acl handlers
commit: 0c95c025a02e477b2d112350e1c78bb0cc994c51
[05/10] fs: simplify ->listxattr() implementation
commit: a5488f29835c0eb5561b46e71c23f6c39aab6c83
[06/10] reiserfs: rework ->listxattr() implementation
commit: 387b96a5891c075986afbf13e84cba357710068e
[07/10] fs: rename generic posix acl handlers
commit: d549b741740e63e87e661754e2d1b336fdc51d50
[08/10] reiserfs: rework priv inode handling
commit: d9f892b9bdc22b12bc960837a09f014d5a324975
[09/10] ovl: check for ->listxattr() support
commit: a1fbb607340d49f208e90cc0d7bdfff2141cce8d
[10/10] acl: don't depend on IOP_XATTR
commit: e499214ce3ef50c50522719e753a1ffc928c2ec1
Christian
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [f2fs-dev] [PATCH v3 00/10] acl: drop posix acl handlers from xattr handlers
2023-02-01 13:14 [PATCH v3 00/10] acl: drop posix acl handlers from xattr handlers Christian Brauner
` (3 preceding siblings ...)
2023-03-06 9:23 ` Christian Brauner
@ 2023-04-26 23:07 ` patchwork-bot+f2fs
4 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+f2fs @ 2023-04-26 23:07 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, hch, linux-unionfs, reiserfs-devel,
linux-f2fs-devel, linux-mtd, viro, linux-ext4, linux-erofs,
sforshee
Hello:
This patch was applied to jaegeuk/f2fs.git (dev)
by Christian Brauner (Microsoft) <brauner@kernel.org>:
On Wed, 01 Feb 2023 14:14:51 +0100 you wrote:
> Hey everyone,
>
> After we finished the introduction of the new posix acl api last cycle
> we still left the generic POSIX ACL xattr handlers around in the
> filesystems xattr handlers for two reasons:
>
> (1) Because a few filesystems rely on the ->list() method of the generic
> POSIX ACL xattr handlers in their ->listxattr() inode operation.
> (2) POSIX ACLs are only available if IOP_XATTR is raised. The IOP_XATTR
> flag is raised in inode_init_always() based on whether the
> sb->s_xattr pointer is non-NULL. IOW, the registered xattr handlers
> of the filesystem are used to raise IOP_XATTR.
> If we were to remove the generic POSIX ACL xattr handlers from all
> filesystems we would risk regressing filesystems that only implement
> POSIX ACL support and no other xattrs (nfs3 comes to mind).
>
> [...]
Here is the summary with links:
- [f2fs-dev,v3,05/10] fs: simplify ->listxattr() implementation
https://git.kernel.org/jaegeuk/f2fs/c/a5488f29835c
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 8+ messages in thread