diff mbox series

[v3,4/7] nfs3: Only do posix acl setup/release operation under CONFIG_NFS_V3_ACL

Message ID 1650020543-24908-4-git-send-email-xuyang2018.jy@fujitsu.com (mailing list archive)
State New, archived
Headers show
Series [v3,1/7] fs/inode: move sgid strip operation from inode_init_owner into inode_sgid_strip | expand

Commit Message

Yang Xu (Fujitsu) April 15, 2022, 11:02 a.m. UTC
Usually, filesystem will use a function named as fs_init_acl function that belong
to acl.c and this function is externed in acl.h by using CONFIG_FS_POSIX_ACL.

If filesystem disable this switch, we should not call nfs3_proc_setacls also not
call posix_acl_create/posix_acl_release because it is useless(We have do umask
strip in vfs).

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 fs/nfs/nfs3proc.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index 1597eef40d54..55789a625d18 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -337,7 +337,9 @@  static int
 nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
 		 int flags)
 {
+#ifdef CONFIG_NFS_V3_ACL
 	struct posix_acl *default_acl, *acl;
+#endif
 	struct nfs3_createdata *data;
 	struct dentry *d_alias;
 	int status = -ENOMEM;
@@ -361,9 +363,11 @@  nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
 		data->arg.create.verifier[1] = cpu_to_be32(current->pid);
 	}
 
+#ifdef CONFIG_NFS_V3_ACL
 	status = posix_acl_create(dir, &sattr->ia_mode, &default_acl, &acl);
 	if (status)
 		goto out;
+#endif
 
 	for (;;) {
 		d_alias = nfs3_do_create(dir, dentry, data);
@@ -415,13 +419,18 @@  nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
 			goto out_dput;
 	}
 
+#ifdef CONFIG_NFS_V3_ACL
 	status = nfs3_proc_setacls(d_inode(dentry), acl, default_acl);
+#endif
 
 out_dput:
 	dput(d_alias);
+
 out_release_acls:
+#ifdef CONFIG_NFS_V3_ACL
 	posix_acl_release(acl);
 	posix_acl_release(default_acl);
+#endif
 out:
 	nfs3_free_createdata(data);
 	dprintk("NFS reply create: %d\n", status);
@@ -580,7 +589,9 @@  nfs3_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page,
 static int
 nfs3_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr)
 {
+#ifdef CONFIG_NFS_V3_ACL
 	struct posix_acl *default_acl, *acl;
+#endif
 	struct nfs3_createdata *data;
 	struct dentry *d_alias;
 	int status = -ENOMEM;
@@ -591,9 +602,11 @@  nfs3_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr)
 	if (data == NULL)
 		goto out;
 
+#ifdef CONFIG_NFS_V3_ACL
 	status = posix_acl_create(dir, &sattr->ia_mode, &default_acl, &acl);
 	if (status)
 		goto out;
+#endif
 
 	data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_MKDIR];
 	data->arg.mkdir.fh = NFS_FH(dir);
@@ -610,12 +623,16 @@  nfs3_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr)
 	if (d_alias)
 		dentry = d_alias;
 
+#ifdef CONFIG_NFS_V3_ACL
 	status = nfs3_proc_setacls(d_inode(dentry), acl, default_acl);
-
+#endif
 	dput(d_alias);
+
 out_release_acls:
+#ifdef CONFIG_NFS_V3_ACL
 	posix_acl_release(acl);
 	posix_acl_release(default_acl);
+#endif
 out:
 	nfs3_free_createdata(data);
 	dprintk("NFS reply mkdir: %d\n", status);
@@ -711,7 +728,9 @@  static int
 nfs3_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
 		dev_t rdev)
 {
+#ifdef CONFIG_NFS_V3_ACL
 	struct posix_acl *default_acl, *acl;
+#endif
 	struct nfs3_createdata *data;
 	struct dentry *d_alias;
 	int status = -ENOMEM;
@@ -723,9 +742,11 @@  nfs3_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
 	if (data == NULL)
 		goto out;
 
+#ifdef CONFIG_NFS_V3_ACL
 	status = posix_acl_create(dir, &sattr->ia_mode, &default_acl, &acl);
 	if (status)
 		goto out;
+#endif
 
 	data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_MKNOD];
 	data->arg.mknod.fh = NFS_FH(dir);
@@ -760,12 +781,16 @@  nfs3_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
 	if (d_alias)
 		dentry = d_alias;
 
+#ifdef CONFIG_NFS_V3_ACL
 	status = nfs3_proc_setacls(d_inode(dentry), acl, default_acl);
-
+#endif
 	dput(d_alias);
+
 out_release_acls:
+#ifdef CONFIG_NFS_V3_ACL
 	posix_acl_release(acl);
 	posix_acl_release(default_acl);
+#endif
 out:
 	nfs3_free_createdata(data);
 	dprintk("NFS reply mknod: %d\n", status);