@@ -3049,6 +3049,16 @@ extern struct mutex ext4__aio_mutex[EXT4_WQ_HASH_SZ];
extern int ext4_resize_begin(struct super_block *sb);
extern void ext4_resize_end(struct super_block *sb);
+struct ext4_acl_ops {
+ int (*chmod)(struct inode *, umode_t);
+ int (*init_acl)(handle_t *, struct inode *, struct inode *);
+};
+
+static inline const struct ext4_acl_ops *ACL_OPS(struct inode *inode)
+{
+ return inode->i_sb->s_private;
+}
+
#endif /* __KERNEL__ */
#endif /* _EXT4_H */
@@ -27,7 +27,6 @@
#include "ext4_jbd2.h"
#include "xattr.h"
#include "acl.h"
-#include "richacl.h"
#include <trace/events/ext4.h>
@@ -698,14 +697,6 @@ out:
return ret;
}
-static inline int
-ext4_new_acl(handle_t *handle, struct inode *inode, struct inode *dir)
-{
- if (IS_RICHACL(dir))
- return ext4_init_richacl(handle, inode, dir);
- return ext4_init_acl(handle, inode, dir);
-}
-
/*
* There are two policies for allocating an inode. If the new inode is
* a directory, then a forward search is made for a block group with both
@@ -1061,7 +1052,7 @@ got:
if (err)
goto fail_drop;
- err = ext4_new_acl(handle, inode, dir);
+ err = ACL_OPS(inode)->init_acl(handle, inode, dir);
if (err)
goto fail_free_drop;
@@ -42,7 +42,6 @@
#include "xattr.h"
#include "acl.h"
#include "truncate.h"
-#include "richacl.h"
#include <trace/events/ext4.h>
@@ -4639,14 +4638,6 @@ static void ext4_wait_for_tail_page_commit(struct inode *inode)
}
}
-static inline int
-ext4_acl_chmod(struct inode *inode, umode_t mode)
-{
- if (IS_RICHACL(inode))
- return richacl_chmod(inode, inode->i_mode);
- return posix_acl_chmod(inode, inode->i_mode);
-}
-
/*
* ext4_setattr()
*
@@ -4815,7 +4806,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
ext4_orphan_del(NULL, inode);
if (!rc && (ia_valid & ATTR_MODE))
- rc = ext4_acl_chmod(inode, inode->i_mode);
+ rc = ACL_OPS(inode)->chmod(inode, inode->i_mode);
err_out:
ext4_std_error(inode->i_sb, error);
if (!error)
@@ -49,6 +49,7 @@
#include "ext4_jbd2.h"
#include "xattr.h"
#include "acl.h"
+#include "richacl.h"
#include "mballoc.h"
#define CREATE_TRACE_POINTS
@@ -1270,25 +1271,54 @@ static ext4_fsblk_t get_sb_block(void **data)
return sb_block;
}
+static int no_chmod_acl(struct inode *inode, umode_t mode)
+{
+ return 0;
+}
+
+static int no_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
+{
+ return 0;
+}
+
+struct ext4_acl_ops no_acl_ops = {
+ .chmod = no_chmod_acl,
+ .init_acl = no_init_acl,
+};
+
+struct ext4_acl_ops ext4_posix_acl_ops = {
+ .chmod = posix_acl_chmod,
+ .init_acl = ext4_init_acl,
+};
+
+struct ext4_acl_ops ext4_richacl_ops = {
+ .chmod = richacl_chmod,
+ .init_acl = ext4_init_richacl,
+};
+
static int enable_acl(struct super_block *sb)
{
sb->s_flags &= ~(MS_POSIXACL | MS_RICHACL);
+ sb->s_private = &no_acl_ops;
if (test_opt(sb, ACL)) {
if (EXT4_HAS_INCOMPAT_FEATURE(sb,
EXT4_FEATURE_INCOMPAT_RICHACL)) {
#ifdef CONFIG_EXT4_FS_RICHACL
sb->s_flags |= MS_RICHACL;
+ sb->s_private = &ext4_richacl_ops;
#else
return -EOPNOTSUPP;
#endif
} else {
#ifdef CONFIG_EXT4_FS_POSIX_ACL
sb->s_flags |= MS_POSIXACL;
+ sb->s_private = &ext4_posix_acl_ops;
#else
return -EOPNOTSUPP;
#endif
}
}
+
return 0;
}
@@ -1324,6 +1324,7 @@ struct super_block {
void *s_security;
#endif
const struct xattr_handler **s_xattr;
+ const void *s_private;
struct hlist_bl_head s_anon; /* anonymous dentries for (nfs) exporting */
struct list_head s_mounts; /* list of mounts; _not_ for fs use */