diff options
Diffstat (limited to 'fs/nfs/nfs3proc.c')
| -rw-r--r-- | fs/nfs/nfs3proc.c | 138 | 
1 files changed, 61 insertions, 77 deletions
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index 90cb10d7b69..f0afa291fd5 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c @@ -18,6 +18,7 @@  #include <linux/lockd/bind.h>  #include <linux/nfs_mount.h>  #include <linux/freezer.h> +#include <linux/xattr.h>  #include "iostat.h"  #include "internal.h" @@ -317,11 +318,11 @@ static int  nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,  		 int flags)  { +	struct posix_acl *default_acl, *acl;  	struct nfs3_createdata *data; -	umode_t mode = sattr->ia_mode;  	int status = -ENOMEM; -	dprintk("NFS call  create %s\n", dentry->d_name.name); +	dprintk("NFS call  create %pd\n", dentry);  	data = nfs3_alloc_createdata();  	if (data == NULL) @@ -340,7 +341,9 @@ nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,  		data->arg.create.verifier[1] = cpu_to_be32(current->pid);  	} -	sattr->ia_mode &= ~current_umask(); +	status = posix_acl_create(dir, &sattr->ia_mode, &default_acl, &acl); +	if (status) +		goto out;  	for (;;) {  		status = nfs3_do_create(dir, dentry, data); @@ -366,7 +369,7 @@ nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,  	}  	if (status != 0) -		goto out; +		goto out_release_acls;  	/* When we created the file with exclusive semantics, make  	 * sure we set the attributes afterwards. */ @@ -385,9 +388,14 @@ nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,  		nfs_post_op_update_inode(dentry->d_inode, data->res.fattr);  		dprintk("NFS reply setattr (post-create): %d\n", status);  		if (status != 0) -			goto out; +			goto out_release_acls;  	} -	status = nfs3_proc_set_default_acl(dir, dentry->d_inode, mode); + +	status = nfs3_proc_setacls(dentry->d_inode, acl, default_acl); + +out_release_acls: +	posix_acl_release(acl); +	posix_acl_release(default_acl);  out:  	nfs3_free_createdata(data);  	dprintk("NFS reply create: %d\n", status); @@ -471,41 +479,6 @@ nfs3_proc_rename_done(struct rpc_task *task, struct inode *old_dir,  }  static int -nfs3_proc_rename(struct inode *old_dir, struct qstr *old_name, -		 struct inode *new_dir, struct qstr *new_name) -{ -	struct nfs_renameargs	arg = { -		.old_dir	= NFS_FH(old_dir), -		.old_name	= old_name, -		.new_dir	= NFS_FH(new_dir), -		.new_name	= new_name, -	}; -	struct nfs_renameres res; -	struct rpc_message msg = { -		.rpc_proc	= &nfs3_procedures[NFS3PROC_RENAME], -		.rpc_argp	= &arg, -		.rpc_resp	= &res, -	}; -	int status = -ENOMEM; - -	dprintk("NFS call  rename %s -> %s\n", old_name->name, new_name->name); - -	res.old_fattr = nfs_alloc_fattr(); -	res.new_fattr = nfs_alloc_fattr(); -	if (res.old_fattr == NULL || res.new_fattr == NULL) -		goto out; - -	status = rpc_call_sync(NFS_CLIENT(old_dir), &msg, 0); -	nfs_post_op_update_inode(old_dir, res.old_fattr); -	nfs_post_op_update_inode(new_dir, res.new_fattr); -out: -	nfs_free_fattr(res.old_fattr); -	nfs_free_fattr(res.new_fattr); -	dprintk("NFS reply rename: %d\n", status); -	return status; -} - -static int  nfs3_proc_link(struct inode *inode, struct inode *dir, struct qstr *name)  {  	struct nfs3_linkargs	arg = { @@ -548,7 +521,7 @@ nfs3_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page,  	if (len > NFS3_MAXPATHLEN)  		return -ENAMETOOLONG; -	dprintk("NFS call  symlink %s\n", dentry->d_name.name); +	dprintk("NFS call  symlink %pd\n", dentry);  	data = nfs3_alloc_createdata();  	if (data == NULL) @@ -572,18 +545,20 @@ out:  static int  nfs3_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr)  { +	struct posix_acl *default_acl, *acl;  	struct nfs3_createdata *data; -	umode_t mode = sattr->ia_mode;  	int status = -ENOMEM; -	dprintk("NFS call  mkdir %s\n", dentry->d_name.name); - -	sattr->ia_mode &= ~current_umask(); +	dprintk("NFS call  mkdir %pd\n", dentry);  	data = nfs3_alloc_createdata();  	if (data == NULL)  		goto out; +	status = posix_acl_create(dir, &sattr->ia_mode, &default_acl, &acl); +	if (status) +		goto out; +  	data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_MKDIR];  	data->arg.mkdir.fh = NFS_FH(dir);  	data->arg.mkdir.name = dentry->d_name.name; @@ -592,9 +567,13 @@ nfs3_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr)  	status = nfs3_do_create(dir, dentry, data);  	if (status != 0) -		goto out; +		goto out_release_acls; -	status = nfs3_proc_set_default_acl(dir, dentry->d_inode, mode); +	status = nfs3_proc_setacls(dentry->d_inode, acl, default_acl); + +out_release_acls: +	posix_acl_release(acl); +	posix_acl_release(default_acl);  out:  	nfs3_free_createdata(data);  	dprintk("NFS reply mkdir: %d\n", status); @@ -691,19 +670,21 @@ static int  nfs3_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,  		dev_t rdev)  { +	struct posix_acl *default_acl, *acl;  	struct nfs3_createdata *data; -	umode_t mode = sattr->ia_mode;  	int status = -ENOMEM; -	dprintk("NFS call  mknod %s %u:%u\n", dentry->d_name.name, +	dprintk("NFS call  mknod %pd %u:%u\n", dentry,  			MAJOR(rdev), MINOR(rdev)); -	sattr->ia_mode &= ~current_umask(); -  	data = nfs3_alloc_createdata();  	if (data == NULL)  		goto out; +	status = posix_acl_create(dir, &sattr->ia_mode, &default_acl, &acl); +	if (status) +		goto out; +  	data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_MKNOD];  	data->arg.mknod.fh = NFS_FH(dir);  	data->arg.mknod.name = dentry->d_name.name; @@ -731,8 +712,13 @@ nfs3_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,  	status = nfs3_do_create(dir, dentry, data);  	if (status != 0) -		goto out; -	status = nfs3_proc_set_default_acl(dir, dentry->d_inode, mode); +		goto out_release_acls; + +	status = nfs3_proc_setacls(dentry->d_inode, acl, default_acl); + +out_release_acls: +	posix_acl_release(acl); +	posix_acl_release(default_acl);  out:  	nfs3_free_createdata(data);  	dprintk("NFS reply mknod: %d\n", status); @@ -809,7 +795,7 @@ nfs3_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle,  	return status;  } -static int nfs3_read_done(struct rpc_task *task, struct nfs_read_data *data) +static int nfs3_read_done(struct rpc_task *task, struct nfs_pgio_data *data)  {  	struct inode *inode = data->header->inode; @@ -821,18 +807,18 @@ static int nfs3_read_done(struct rpc_task *task, struct nfs_read_data *data)  	return 0;  } -static void nfs3_proc_read_setup(struct nfs_read_data *data, struct rpc_message *msg) +static void nfs3_proc_read_setup(struct nfs_pgio_data *data, struct rpc_message *msg)  {  	msg->rpc_proc = &nfs3_procedures[NFS3PROC_READ];  } -static int nfs3_proc_read_rpc_prepare(struct rpc_task *task, struct nfs_read_data *data) +static int nfs3_proc_pgio_rpc_prepare(struct rpc_task *task, struct nfs_pgio_data *data)  {  	rpc_call_start(task);  	return 0;  } -static int nfs3_write_done(struct rpc_task *task, struct nfs_write_data *data) +static int nfs3_write_done(struct rpc_task *task, struct nfs_pgio_data *data)  {  	struct inode *inode = data->header->inode; @@ -843,17 +829,11 @@ static int nfs3_write_done(struct rpc_task *task, struct nfs_write_data *data)  	return 0;  } -static void nfs3_proc_write_setup(struct nfs_write_data *data, struct rpc_message *msg) +static void nfs3_proc_write_setup(struct nfs_pgio_data *data, struct rpc_message *msg)  {  	msg->rpc_proc = &nfs3_procedures[NFS3PROC_WRITE];  } -static int nfs3_proc_write_rpc_prepare(struct rpc_task *task, struct nfs_write_data *data) -{ -	rpc_call_start(task); -	return 0; -} -  static void nfs3_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data)  {  	rpc_call_start(task); @@ -904,20 +884,28 @@ static const struct inode_operations nfs3_dir_inode_operations = {  	.permission	= nfs_permission,  	.getattr	= nfs_getattr,  	.setattr	= nfs_setattr, +#ifdef CONFIG_NFS_V3_ACL  	.listxattr	= nfs3_listxattr, -	.getxattr	= nfs3_getxattr, -	.setxattr	= nfs3_setxattr, -	.removexattr	= nfs3_removexattr, +	.getxattr	= generic_getxattr, +	.setxattr	= generic_setxattr, +	.removexattr	= generic_removexattr, +	.get_acl	= nfs3_get_acl, +	.set_acl	= nfs3_set_acl, +#endif  };  static const struct inode_operations nfs3_file_inode_operations = {  	.permission	= nfs_permission,  	.getattr	= nfs_getattr,  	.setattr	= nfs_setattr, +#ifdef CONFIG_NFS_V3_ACL  	.listxattr	= nfs3_listxattr, -	.getxattr	= nfs3_getxattr, -	.setxattr	= nfs3_setxattr, -	.removexattr	= nfs3_removexattr, +	.getxattr	= generic_getxattr, +	.setxattr	= generic_setxattr, +	.removexattr	= generic_removexattr, +	.get_acl	= nfs3_get_acl, +	.set_acl	= nfs3_set_acl, +#endif  };  const struct nfs_rpc_ops nfs_v3_clientops = { @@ -939,7 +927,6 @@ const struct nfs_rpc_ops nfs_v3_clientops = {  	.unlink_setup	= nfs3_proc_unlink_setup,  	.unlink_rpc_prepare = nfs3_proc_unlink_rpc_prepare,  	.unlink_done	= nfs3_proc_unlink_done, -	.rename		= nfs3_proc_rename,  	.rename_setup	= nfs3_proc_rename_setup,  	.rename_rpc_prepare = nfs3_proc_rename_rpc_prepare,  	.rename_done	= nfs3_proc_rename_done, @@ -953,19 +940,16 @@ const struct nfs_rpc_ops nfs_v3_clientops = {  	.fsinfo		= nfs3_proc_fsinfo,  	.pathconf	= nfs3_proc_pathconf,  	.decode_dirent	= nfs3_decode_dirent, +	.pgio_rpc_prepare = nfs3_proc_pgio_rpc_prepare,  	.read_setup	= nfs3_proc_read_setup, -	.read_pageio_init = nfs_pageio_init_read, -	.read_rpc_prepare = nfs3_proc_read_rpc_prepare,  	.read_done	= nfs3_read_done,  	.write_setup	= nfs3_proc_write_setup, -	.write_pageio_init = nfs_pageio_init_write, -	.write_rpc_prepare = nfs3_proc_write_rpc_prepare,  	.write_done	= nfs3_write_done,  	.commit_setup	= nfs3_proc_commit_setup,  	.commit_rpc_prepare = nfs3_proc_commit_rpc_prepare,  	.commit_done	= nfs3_commit_done,  	.lock		= nfs3_proc_lock, -	.clear_acl_cache = nfs3_forget_cached_acls, +	.clear_acl_cache = forget_all_cached_acls,  	.close_context	= nfs_close_context,  	.have_delegation = nfs3_have_delegation,  	.return_delegation = nfs3_return_delegation,  | 
