Whamcloud - gitweb
LU-6142 llite: move acl code into separate file. 29/40829/6
authorMr NeilBrown <neilb@suse.de>
Mon, 2 Nov 2020 00:44:02 +0000 (11:44 +1100)
committerOleg Drokin <green@whamcloud.com>
Wed, 10 Mar 2021 08:02:05 +0000 (08:02 +0000)
acl code is subject to conditional compilation (only if fs acls are
enabled), so move it to a separate file.

Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I472fa80193ee47abbab857bcc6dd021ed42ae9a5
Reviewed-on: https://review.whamcloud.com/40829
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/Makefile.in
lustre/llite/acl.c [new file with mode: 0644]
lustre/llite/file.c
lustre/llite/llite_internal.h

index edc2dd7..75c97ac 100644 (file)
@@ -10,7 +10,10 @@ lustre-objs += vvp_dev.o vvp_page.o vvp_io.o vvp_object.o
 lustre-objs += pcc.o crypto.o
 lustre-objs += llite_foreign.o llite_foreign_symlink.o
 
-EXTRA_DIST := $(lustre-objs:.o=.c) xattr.c rw26.c super25.c
+lustre-$(CONFIG_FS_POSIX_ACL) += acl.o
+lustre-objs += $(lustre-y)
+
+EXTRA_DIST := $(lustre-objs:.o=.c) xattr.c rw26.c super25.c acl.c
 EXTRA_DIST += llite_internal.h vvp_internal.h pcc.h
 EXTRA_DIST += foreign_symlink.h
 
diff --git a/lustre/llite/acl.c b/lustre/llite/acl.c
new file mode 100644 (file)
index 0000000..515ac72
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * GPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.gnu.org/licenses/gpl-2.0.html
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, 2017, Intel Corporation.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lustre/llite/acl.c
+ *
+ * Author: Peter Braam <braam@clusterfs.com>
+ * Author: Phil Schwan <phil@clusterfs.com>
+ * Author: Andreas Dilger <adilger@clusterfs.com>
+ */
+
+#include "llite_internal.h"
+
+struct posix_acl *ll_get_acl(struct inode *inode, int type)
+{
+       struct ll_inode_info *lli = ll_i2info(inode);
+       struct posix_acl *acl = NULL;
+       ENTRY;
+
+       spin_lock(&lli->lli_lock);
+       /* VFS' acl_permission_check->check_acl will release the refcount */
+       acl = posix_acl_dup(lli->lli_posix_acl);
+       spin_unlock(&lli->lli_lock);
+
+       RETURN(acl);
+}
+
+#ifdef HAVE_IOP_SET_ACL
+int ll_set_acl(struct inode *inode, struct posix_acl *acl, int type)
+{
+       struct ll_sb_info *sbi = ll_i2sbi(inode);
+       struct ptlrpc_request *req = NULL;
+       const char *name = NULL;
+       char *value = NULL;
+       size_t value_size = 0;
+       int rc = 0;
+       ENTRY;
+
+       switch (type) {
+       case ACL_TYPE_ACCESS:
+               name = XATTR_NAME_POSIX_ACL_ACCESS;
+               if (acl)
+                       rc = posix_acl_update_mode(inode, &inode->i_mode, &acl);
+               break;
+
+       case ACL_TYPE_DEFAULT:
+               name = XATTR_NAME_POSIX_ACL_DEFAULT;
+               if (!S_ISDIR(inode->i_mode))
+                       rc = acl ? -EACCES : 0;
+               break;
+
+       default:
+               rc = -EINVAL;
+               break;
+       }
+       if (rc)
+               return rc;
+
+       if (acl) {
+               value_size = posix_acl_xattr_size(acl->a_count);
+               value = kmalloc(value_size, GFP_NOFS);
+               if (value == NULL)
+                       GOTO(out, rc = -ENOMEM);
+
+               rc = posix_acl_to_xattr(&init_user_ns, acl, value, value_size);
+               if (rc < 0)
+                       GOTO(out_value, rc);
+       }
+
+       rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode),
+                        value ? OBD_MD_FLXATTR : OBD_MD_FLXATTRRM,
+                        name, value, value_size, 0, 0, &req);
+
+       ptlrpc_req_finished(req);
+out_value:
+       kfree(value);
+out:
+       if (rc)
+               forget_cached_acl(inode, type);
+       else
+               set_cached_acl(inode, type, acl);
+       RETURN(rc);
+}
+#endif /* HAVE_IOP_SET_ACL */
index 1e01323..7844800 100644 (file)
@@ -5163,80 +5163,6 @@ out:
        return rc;
 }
 
-struct posix_acl *ll_get_acl(struct inode *inode, int type)
-{
-       struct ll_inode_info *lli = ll_i2info(inode);
-       struct posix_acl *acl = NULL;
-       ENTRY;
-
-       spin_lock(&lli->lli_lock);
-       /* VFS' acl_permission_check->check_acl will release the refcount */
-       acl = posix_acl_dup(lli->lli_posix_acl);
-       spin_unlock(&lli->lli_lock);
-
-       RETURN(acl);
-}
-
-#ifdef HAVE_IOP_SET_ACL
-#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
-int ll_set_acl(struct inode *inode, struct posix_acl *acl, int type)
-{
-       struct ll_sb_info *sbi = ll_i2sbi(inode);
-       struct ptlrpc_request *req = NULL;
-       const char *name = NULL;
-       char *value = NULL;
-       size_t value_size = 0;
-       int rc = 0;
-       ENTRY;
-
-       switch (type) {
-       case ACL_TYPE_ACCESS:
-               name = XATTR_NAME_POSIX_ACL_ACCESS;
-               if (acl)
-                       rc = posix_acl_update_mode(inode, &inode->i_mode, &acl);
-               break;
-
-       case ACL_TYPE_DEFAULT:
-               name = XATTR_NAME_POSIX_ACL_DEFAULT;
-               if (!S_ISDIR(inode->i_mode))
-                       rc = acl ? -EACCES : 0;
-               break;
-
-       default:
-               rc = -EINVAL;
-               break;
-       }
-       if (rc)
-               return rc;
-
-       if (acl) {
-               value_size = posix_acl_xattr_size(acl->a_count);
-               value = kmalloc(value_size, GFP_NOFS);
-               if (value == NULL)
-                       GOTO(out, rc = -ENOMEM);
-
-               rc = posix_acl_to_xattr(&init_user_ns, acl, value, value_size);
-               if (rc < 0)
-                       GOTO(out_value, rc);
-       }
-
-       rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode),
-                        value ? OBD_MD_FLXATTR : OBD_MD_FLXATTRRM,
-                        name, value, value_size, 0, 0, &req);
-
-       ptlrpc_req_finished(req);
-out_value:
-       kfree(value);
-out:
-       if (rc)
-               forget_cached_acl(inode, type);
-       else
-               set_cached_acl(inode, type, acl);
-       RETURN(rc);
-}
-#endif /* CONFIG_LUSTRE_FS_POSIX_ACL */
-#endif /* HAVE_IOP_SET_ACL */
-
 int ll_inode_permission(struct inode *inode, int mask)
 {
        int rc = 0;
index 69c6f79..163f78b 100644 (file)
@@ -1118,16 +1118,14 @@ int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat);
 #endif
 int ll_getattr_dentry(struct dentry *de, struct kstat *stat, u32 request_mask,
                      unsigned int flags, bool foreign);
-struct posix_acl *ll_get_acl(struct inode *inode, int type);
-#ifdef HAVE_IOP_SET_ACL
 #ifdef CONFIG_LUSTRE_FS_POSIX_ACL
+struct posix_acl *ll_get_acl(struct inode *inode, int type);
 int ll_set_acl(struct inode *inode, struct posix_acl *acl, int type);
 #else  /* !CONFIG_LUSTRE_FS_POSIX_ACL */
+#define ll_get_acl NULL
 #define ll_set_acl NULL
 #endif /* CONFIG_LUSTRE_FS_POSIX_ACL */
 
-#endif
-
 static inline int ll_xflags_to_inode_flags(int xflags)
 {
        return ((xflags & FS_XFLAG_SYNC)      ? S_SYNC      : 0) |