Whamcloud - gitweb
LU-14291 lustre: further cleanup of acl code.
[fs/lustre-release.git] / lustre / mdd / mdd_internal.h
index b06c021..bdb6e6d 100644 (file)
@@ -39,7 +39,6 @@
 
 #include <lustre_acl.h>
 #include <lustre_compat.h>
-#include <lustre_eacl.h>
 #include <md_object.h>
 #include <dt_object.h>
 #include <lustre_lfsck.h>
@@ -424,9 +423,11 @@ int mdd_acl_set(const struct lu_env *env, struct mdd_object *obj,
 int __mdd_fix_mode_acl(const struct lu_env *env, struct lu_buf *buf,
                       __u32 *mode);
 int __mdd_permission_internal(const struct lu_env *env, struct mdd_object *obj,
-                             const struct lu_attr *la, int mask, int role);
+                             const struct lu_attr *la, unsigned int may_mask,
+                             int role);
 int mdd_permission(const struct lu_env *env, struct md_object *pobj,
-                  struct md_object *cobj, struct md_attr *ma, int mask);
+                  struct md_object *cobj, struct md_attr *ma,
+                  unsigned int may_mask);
 int mdd_generic_thread_start(struct mdd_generic_thread *thread,
                             int (*func)(void *), void *data, char *name);
 void mdd_generic_thread_stop(struct mdd_generic_thread *thread);
@@ -436,6 +437,19 @@ int mdd_changelog_user_purge(const struct lu_env *env, struct mdd_device *mdd,
 /* mdd_prepare.c */
 int mdd_compat_fixes(const struct lu_env *env, struct mdd_device *mdd);
 
+/* acl.c */
+extern int lustre_posix_acl_permission(struct lu_ucred *mu,
+                                      const struct lu_attr *la,
+                                      unsigned int may_mask,
+                                      posix_acl_xattr_entry *entry,
+                                      int count);
+extern int lustre_posix_acl_chmod_masq(posix_acl_xattr_entry *entry,
+                                      __u32 mode, int count);
+extern int lustre_posix_acl_create_masq(posix_acl_xattr_entry *entry,
+                                       __u32 *pmode, int count);
+extern int lustre_posix_acl_equiv_mode(posix_acl_xattr_entry *entry,
+                                      mode_t *mode_p, int count);
+
 /* inline functions */
 static inline int lu_device_is_mdd(struct lu_device *d)
 {
@@ -546,18 +560,19 @@ static inline const char *mdd_obj_dev_name(const struct mdd_object *mdd_obj)
 
 static inline int mdd_permission_internal(const struct lu_env *env,
                                          struct mdd_object *obj,
-                                         const struct lu_attr *la, int mask)
+                                         const struct lu_attr *la,
+                                         unsigned int may_mask)
 {
-       return __mdd_permission_internal(env, obj, la, mask, -1);
+       return __mdd_permission_internal(env, obj, la, may_mask, -1);
 }
 
 static inline int mdd_permission_internal_locked(const struct lu_env *env,
                                                struct mdd_object *obj,
                                                const struct lu_attr *la,
-                                               int mask,
+                                               unsigned int may_mask,
                                                enum dt_object_role role)
 {
-       return __mdd_permission_internal(env, obj, la, mask, role);
+       return __mdd_permission_internal(env, obj, la, may_mask, role);
 }
 
 /* mdd inline func for calling osd_dt_object ops */
@@ -627,8 +642,19 @@ static inline int mdo_xattr_set(const struct lu_env *env,struct mdd_object *obj,
        if (!mdd_object_exists(obj))
                return -ENOENT;
 
+       /* If we are about to set the LL_XATTR_NAME_ENCRYPTION_CONTEXT
+        * xattr, it means the file/dir is encrypted. In that case we want
+        * to set the LUSTRE_ENCRYPT_FL flag as well: it will be stored
+        * into the LMA, making it more efficient to recognise we are
+        * dealing with an encrypted file/dir, as LMA info is cached upon
+        * object init.
+        * However, marking a dir as encrypted is only possible if it is
+        * being created or migrated (LU_XATTR_CREATE flag not set), or
+        * if it is empty.
+        */
        if ((strcmp(name, LL_XATTR_NAME_ENCRYPTION_CONTEXT) == 0) &&
            (!S_ISDIR(mdd_object_type(obj)) ||
+            !(fl & LU_XATTR_CREATE) ||
             (rc = mdd_dir_is_empty(env, obj)) == 0)) {
                struct lu_attr la = { 0 };