Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  *  linux/fs/nfs/nfs3proc.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  *  Client-side NFSv3 procedures stubs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7)  *  Copyright (C) 1997, Olaf Kirch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13) #include <linux/sunrpc/clnt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15) #include <linux/nfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16) #include <linux/nfs3.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17) #include <linux/nfs_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18) #include <linux/nfs_page.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19) #include <linux/lockd/bind.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20) #include <linux/nfs_mount.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) #include <linux/freezer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) #include <linux/xattr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) #include "iostat.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) #include "internal.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) #include "nfs3_fs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) #define NFSDBG_FACILITY		NFSDBG_PROC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) /* A wrapper to handle the EJUKEBOX error messages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) nfs3_rpc_wrapper(struct rpc_clnt *clnt, struct rpc_message *msg, int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) 	int res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) 	do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) 		res = rpc_call_sync(clnt, msg, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) 		if (res != -EJUKEBOX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) 		freezable_schedule_timeout_killable_unsafe(NFS_JUKEBOX_RETRY_TIME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) 		res = -ERESTARTSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) 	} while (!fatal_signal_pending(current));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) 	return res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) #define rpc_call_sync(clnt, msg, flags)	nfs3_rpc_wrapper(clnt, msg, flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) nfs3_async_handle_jukebox(struct rpc_task *task, struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) 	if (task->tk_status != -EJUKEBOX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) 	if (task->tk_status == -EJUKEBOX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) 		nfs_inc_stats(inode, NFSIOS_DELAY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) 	task->tk_status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) 	rpc_restart_call(task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) 	rpc_delay(task, NFS_JUKEBOX_RETRY_TIME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) do_proc_get_root(struct rpc_clnt *client, struct nfs_fh *fhandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) 		 struct nfs_fsinfo *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) 		.rpc_proc	= &nfs3_procedures[NFS3PROC_FSINFO],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) 		.rpc_argp	= fhandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) 		.rpc_resp	= info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) 	int	status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) 	dprintk("%s: call  fsinfo\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) 	nfs_fattr_init(info->fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) 	status = rpc_call_sync(client, &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) 	dprintk("%s: reply fsinfo: %d\n", __func__, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) 	if (status == 0 && !(info->fattr->valid & NFS_ATTR_FATTR)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) 		msg.rpc_proc = &nfs3_procedures[NFS3PROC_GETATTR];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) 		msg.rpc_resp = info->fattr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) 		status = rpc_call_sync(client, &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) 		dprintk("%s: reply getattr: %d\n", __func__, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85)  * Bare-bones access to getattr: this is for nfs_get_root/nfs_get_sb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) nfs3_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) 		   struct nfs_fsinfo *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) 	int	status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) 	status = do_proc_get_root(server->client, fhandle, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) 	if (status && server->nfs_client->cl_rpcclient != server->client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) 		status = do_proc_get_root(server->nfs_client->cl_rpcclient, fhandle, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100)  * One function for each procedure in the NFS protocol.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) nfs3_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) 		struct nfs_fattr *fattr, struct nfs4_label *label,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) 		struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) 		.rpc_proc	= &nfs3_procedures[NFS3PROC_GETATTR],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) 		.rpc_argp	= fhandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) 		.rpc_resp	= fattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) 	int	status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) 	unsigned short task_flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) 	/* Is this is an attribute revalidation, subject to softreval? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) 	if (inode && (server->flags & NFS_MOUNT_SOFTREVAL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 		task_flags |= RPC_TASK_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) 	dprintk("NFS call  getattr\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) 	nfs_fattr_init(fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) 	status = rpc_call_sync(server->client, &msg, task_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) 	dprintk("NFS reply getattr: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) nfs3_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) 			struct iattr *sattr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) 	struct inode *inode = d_inode(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) 	struct nfs3_sattrargs	arg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) 		.fh		= NFS_FH(inode),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) 		.sattr		= sattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) 		.rpc_proc	= &nfs3_procedures[NFS3PROC_SETATTR],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) 		.rpc_argp	= &arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) 		.rpc_resp	= fattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) 	int	status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) 	dprintk("NFS call  setattr\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) 	if (sattr->ia_valid & ATTR_FILE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) 		msg.rpc_cred = nfs_file_cred(sattr->ia_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) 	nfs_fattr_init(fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) 	status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) 	if (status == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) 		nfs_setattr_update_inode(inode, sattr, fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) 		if (NFS_I(inode)->cache_validity & NFS_INO_INVALID_ACL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) 			nfs_zap_acl_cache(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) 	dprintk("NFS reply setattr: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) nfs3_proc_lookup(struct inode *dir, struct dentry *dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) 		 struct nfs_fh *fhandle, struct nfs_fattr *fattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 		 struct nfs4_label *label)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) 	struct nfs3_diropargs	arg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) 		.fh		= NFS_FH(dir),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) 		.name		= dentry->d_name.name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) 		.len		= dentry->d_name.len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) 	struct nfs3_diropres	res = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) 		.fh		= fhandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) 		.fattr		= fattr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) 		.rpc_proc	= &nfs3_procedures[NFS3PROC_LOOKUP],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) 		.rpc_argp	= &arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) 		.rpc_resp	= &res,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) 	int			status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) 	unsigned short task_flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) 	/* Is this is an attribute revalidation, subject to softreval? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 	if (nfs_lookup_is_soft_revalidate(dentry))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) 		task_flags |= RPC_TASK_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) 	res.dir_attr = nfs_alloc_fattr();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) 	if (res.dir_attr == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) 	dprintk("NFS call  lookup %pd2\n", dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) 	nfs_fattr_init(fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) 	status = rpc_call_sync(NFS_CLIENT(dir), &msg, task_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) 	nfs_refresh_inode(dir, res.dir_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) 	if (status >= 0 && !(fattr->valid & NFS_ATTR_FATTR)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 		msg.rpc_proc = &nfs3_procedures[NFS3PROC_GETATTR];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 		msg.rpc_argp = fhandle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) 		msg.rpc_resp = fattr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) 		status = rpc_call_sync(NFS_CLIENT(dir), &msg, task_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) 	nfs_free_fattr(res.dir_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) 	dprintk("NFS reply lookup: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) 	struct nfs3_accessargs	arg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) 		.fh		= NFS_FH(inode),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) 		.access		= entry->mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) 	struct nfs3_accessres	res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) 		.rpc_proc	= &nfs3_procedures[NFS3PROC_ACCESS],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) 		.rpc_argp	= &arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) 		.rpc_resp	= &res,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) 		.rpc_cred	= entry->cred,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 	int status = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) 	dprintk("NFS call  access\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) 	res.fattr = nfs_alloc_fattr();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) 	if (res.fattr == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) 	status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) 	nfs_refresh_inode(inode, res.fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) 	if (status == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) 		nfs_access_set_mask(entry, res.access);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 	nfs_free_fattr(res.fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 	dprintk("NFS reply access: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) static int nfs3_proc_readlink(struct inode *inode, struct page *page,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 		unsigned int pgbase, unsigned int pglen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 	struct nfs_fattr	*fattr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) 	struct nfs3_readlinkargs args = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 		.fh		= NFS_FH(inode),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) 		.pgbase		= pgbase,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 		.pglen		= pglen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) 		.pages		= &page
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) 		.rpc_proc	= &nfs3_procedures[NFS3PROC_READLINK],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) 		.rpc_argp	= &args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 	int status = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 	dprintk("NFS call  readlink\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) 	fattr = nfs_alloc_fattr();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 	if (fattr == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 	msg.rpc_resp = fattr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 	status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 	nfs_refresh_inode(inode, fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 	nfs_free_fattr(fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 	dprintk("NFS reply readlink: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) struct nfs3_createdata {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) 	struct rpc_message msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) 		struct nfs3_createargs create;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) 		struct nfs3_mkdirargs mkdir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) 		struct nfs3_symlinkargs symlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 		struct nfs3_mknodargs mknod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) 	} arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) 	struct nfs3_diropres res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) 	struct nfs_fh fh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) 	struct nfs_fattr fattr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) 	struct nfs_fattr dir_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) static struct nfs3_createdata *nfs3_alloc_createdata(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) 	struct nfs3_createdata *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) 	data = kzalloc(sizeof(*data), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) 	if (data != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) 		data->msg.rpc_argp = &data->arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) 		data->msg.rpc_resp = &data->res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 		data->res.fh = &data->fh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) 		data->res.fattr = &data->fattr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) 		data->res.dir_attr = &data->dir_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) 		nfs_fattr_init(data->res.fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) 		nfs_fattr_init(data->res.dir_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) 	return data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) static struct dentry *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) nfs3_do_create(struct inode *dir, struct dentry *dentry, struct nfs3_createdata *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 	status = rpc_call_sync(NFS_CLIENT(dir), &data->msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) 	nfs_post_op_update_inode(dir, data->res.dir_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 	if (status != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) 		return ERR_PTR(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) 	return nfs_add_or_obtain(dentry, data->res.fh, data->res.fattr, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) static void nfs3_free_createdata(struct nfs3_createdata *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) 	kfree(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311)  * Create a regular file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 		 int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) 	struct posix_acl *default_acl, *acl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 	struct nfs3_createdata *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) 	struct dentry *d_alias;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 	int status = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) 	dprintk("NFS call  create %pd\n", dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) 	data = nfs3_alloc_createdata();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 	if (data == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 	data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_CREATE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 	data->arg.create.fh = NFS_FH(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 	data->arg.create.name = dentry->d_name.name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) 	data->arg.create.len = dentry->d_name.len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 	data->arg.create.sattr = sattr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) 	data->arg.create.createmode = NFS3_CREATE_UNCHECKED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 	if (flags & O_EXCL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 		data->arg.create.createmode  = NFS3_CREATE_EXCLUSIVE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 		data->arg.create.verifier[0] = cpu_to_be32(jiffies);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) 		data->arg.create.verifier[1] = cpu_to_be32(current->pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 	status = posix_acl_create(dir, &sattr->ia_mode, &default_acl, &acl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 	for (;;) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 		d_alias = nfs3_do_create(dir, dentry, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 		status = PTR_ERR_OR_ZERO(d_alias);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 		if (status != -ENOTSUPP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 		/* If the server doesn't support the exclusive creation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) 		 * semantics, try again with simple 'guarded' mode. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 		switch (data->arg.create.createmode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 			case NFS3_CREATE_EXCLUSIVE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 				data->arg.create.createmode = NFS3_CREATE_GUARDED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 			case NFS3_CREATE_GUARDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) 				data->arg.create.createmode = NFS3_CREATE_UNCHECKED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 			case NFS3_CREATE_UNCHECKED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) 				goto out_release_acls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) 		nfs_fattr_init(data->res.dir_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) 		nfs_fattr_init(data->res.fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) 	if (status != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 		goto out_release_acls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) 	if (d_alias)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) 		dentry = d_alias;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 	/* When we created the file with exclusive semantics, make
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 	 * sure we set the attributes afterwards. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 	if (data->arg.create.createmode == NFS3_CREATE_EXCLUSIVE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 		dprintk("NFS call  setattr (post-create)\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 		if (!(sattr->ia_valid & ATTR_ATIME_SET))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) 			sattr->ia_valid |= ATTR_ATIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) 		if (!(sattr->ia_valid & ATTR_MTIME_SET))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) 			sattr->ia_valid |= ATTR_MTIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 		/* Note: we could use a guarded setattr here, but I'm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 		 * not sure this buys us anything (and I'd have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) 		 * to revamp the NFSv3 XDR code) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 		status = nfs3_proc_setattr(dentry, data->res.fattr, sattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) 		nfs_post_op_update_inode(d_inode(dentry), data->res.fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) 		dprintk("NFS reply setattr (post-create): %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) 		if (status != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) 			goto out_dput;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 	status = nfs3_proc_setacls(d_inode(dentry), acl, default_acl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) out_dput:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) 	dput(d_alias);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) out_release_acls:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) 	posix_acl_release(acl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) 	posix_acl_release(default_acl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) 	nfs3_free_createdata(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 	dprintk("NFS reply create: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) nfs3_proc_remove(struct inode *dir, struct dentry *dentry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 	struct nfs_removeargs arg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 		.fh = NFS_FH(dir),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 		.name = dentry->d_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 	struct nfs_removeres res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 		.rpc_proc = &nfs3_procedures[NFS3PROC_REMOVE],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) 		.rpc_argp = &arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) 		.rpc_resp = &res,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 	int status = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) 	dprintk("NFS call  remove %pd2\n", dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 	res.dir_attr = nfs_alloc_fattr();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 	if (res.dir_attr == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 	status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 	nfs_post_op_update_inode(dir, res.dir_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) 	nfs_free_fattr(res.dir_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) 	dprintk("NFS reply remove: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) nfs3_proc_unlink_setup(struct rpc_message *msg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) 		struct dentry *dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) 		struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 	msg->rpc_proc = &nfs3_procedures[NFS3PROC_REMOVE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) static void nfs3_proc_unlink_rpc_prepare(struct rpc_task *task, struct nfs_unlinkdata *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) 	rpc_call_start(task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) nfs3_proc_unlink_done(struct rpc_task *task, struct inode *dir)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) 	struct nfs_removeres *res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) 	if (nfs3_async_handle_jukebox(task, dir))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) 	res = task->tk_msg.rpc_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) 	nfs_post_op_update_inode(dir, res->dir_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) nfs3_proc_rename_setup(struct rpc_message *msg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 		struct dentry *old_dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 		struct dentry *new_dentry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 	msg->rpc_proc = &nfs3_procedures[NFS3PROC_RENAME];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) static void nfs3_proc_rename_rpc_prepare(struct rpc_task *task, struct nfs_renamedata *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) 	rpc_call_start(task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) nfs3_proc_rename_done(struct rpc_task *task, struct inode *old_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) 		      struct inode *new_dir)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 	struct nfs_renameres *res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) 	if (nfs3_async_handle_jukebox(task, old_dir))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) 	res = task->tk_msg.rpc_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) 	nfs_post_op_update_inode(old_dir, res->old_fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) 	nfs_post_op_update_inode(new_dir, res->new_fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) nfs3_proc_link(struct inode *inode, struct inode *dir, const struct qstr *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 	struct nfs3_linkargs	arg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 		.fromfh		= NFS_FH(inode),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 		.tofh		= NFS_FH(dir),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 		.toname		= name->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 		.tolen		= name->len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 	struct nfs3_linkres	res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 		.rpc_proc	= &nfs3_procedures[NFS3PROC_LINK],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 		.rpc_argp	= &arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 		.rpc_resp	= &res,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 	int status = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 	dprintk("NFS call  link %s\n", name->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) 	res.fattr = nfs_alloc_fattr();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) 	res.dir_attr = nfs_alloc_fattr();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) 	if (res.fattr == NULL || res.dir_attr == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 	status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 	nfs_post_op_update_inode(dir, res.dir_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 	nfs_post_op_update_inode(inode, res.fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 	nfs_free_fattr(res.dir_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 	nfs_free_fattr(res.fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 	dprintk("NFS reply link: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) nfs3_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 		  unsigned int len, struct iattr *sattr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 	struct nfs3_createdata *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) 	struct dentry *d_alias;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 	int status = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) 	if (len > NFS3_MAXPATHLEN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) 		return -ENAMETOOLONG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 	dprintk("NFS call  symlink %pd\n", dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 	data = nfs3_alloc_createdata();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 	if (data == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 	data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_SYMLINK];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) 	data->arg.symlink.fromfh = NFS_FH(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 	data->arg.symlink.fromname = dentry->d_name.name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 	data->arg.symlink.fromlen = dentry->d_name.len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 	data->arg.symlink.pages = &page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) 	data->arg.symlink.pathlen = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 	data->arg.symlink.sattr = sattr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 	d_alias = nfs3_do_create(dir, dentry, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 	status = PTR_ERR_OR_ZERO(d_alias);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) 	if (status == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) 		dput(d_alias);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) 	nfs3_free_createdata(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) 	dprintk("NFS reply symlink: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) nfs3_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) 	struct posix_acl *default_acl, *acl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) 	struct nfs3_createdata *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 	struct dentry *d_alias;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 	int status = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 	dprintk("NFS call  mkdir %pd\n", dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 	data = nfs3_alloc_createdata();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 	if (data == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 	status = posix_acl_create(dir, &sattr->ia_mode, &default_acl, &acl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 	data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_MKDIR];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 	data->arg.mkdir.fh = NFS_FH(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 	data->arg.mkdir.name = dentry->d_name.name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 	data->arg.mkdir.len = dentry->d_name.len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 	data->arg.mkdir.sattr = sattr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 	d_alias = nfs3_do_create(dir, dentry, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 	status = PTR_ERR_OR_ZERO(d_alias);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 	if (status != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) 		goto out_release_acls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 	if (d_alias)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 		dentry = d_alias;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) 	status = nfs3_proc_setacls(d_inode(dentry), acl, default_acl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) 	dput(d_alias);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) out_release_acls:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) 	posix_acl_release(acl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) 	posix_acl_release(default_acl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 	nfs3_free_createdata(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 	dprintk("NFS reply mkdir: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) nfs3_proc_rmdir(struct inode *dir, const struct qstr *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 	struct nfs_fattr	*dir_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 	struct nfs3_diropargs	arg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 		.fh		= NFS_FH(dir),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 		.name		= name->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 		.len		= name->len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 		.rpc_proc	= &nfs3_procedures[NFS3PROC_RMDIR],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 		.rpc_argp	= &arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 	int status = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) 	dprintk("NFS call  rmdir %s\n", name->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) 	dir_attr = nfs_alloc_fattr();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 	if (dir_attr == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 	msg.rpc_resp = dir_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 	status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 	nfs_post_op_update_inode(dir, dir_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 	nfs_free_fattr(dir_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 	dprintk("NFS reply rmdir: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632)  * The READDIR implementation is somewhat hackish - we pass the user buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633)  * to the encode function, which installs it in the receive iovec.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634)  * The decode function itself doesn't perform any decoding, it just makes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635)  * sure the reply is syntactically correct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637)  * Also note that this implementation handles both plain readdir and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638)  * readdirplus.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) nfs3_proc_readdir(struct dentry *dentry, const struct cred *cred,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) 		  u64 cookie, struct page **pages, unsigned int count, bool plus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) 	struct inode		*dir = d_inode(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) 	__be32			*verf = NFS_I(dir)->cookieverf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 	struct nfs3_readdirargs	arg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 		.fh		= NFS_FH(dir),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) 		.cookie		= cookie,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 		.verf		= {verf[0], verf[1]},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) 		.plus		= plus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) 		.count		= count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 		.pages		= pages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) 	struct nfs3_readdirres	res = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) 		.verf		= verf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) 		.plus		= plus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) 	struct rpc_message	msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) 		.rpc_proc	= &nfs3_procedures[NFS3PROC_READDIR],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) 		.rpc_argp	= &arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) 		.rpc_resp	= &res,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) 		.rpc_cred	= cred,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) 	int status = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 	if (plus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 		msg.rpc_proc = &nfs3_procedures[NFS3PROC_READDIRPLUS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) 	dprintk("NFS call  readdir%s %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) 			plus? "plus" : "", (unsigned int) cookie);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 	res.dir_attr = nfs_alloc_fattr();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 	if (res.dir_attr == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 	status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 	nfs_invalidate_atime(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) 	nfs_refresh_inode(dir, res.dir_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) 	nfs_free_fattr(res.dir_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 	dprintk("NFS reply readdir%s: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 			plus? "plus" : "", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) nfs3_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 		dev_t rdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) 	struct posix_acl *default_acl, *acl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 	struct nfs3_createdata *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 	struct dentry *d_alias;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 	int status = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 	dprintk("NFS call  mknod %pd %u:%u\n", dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 			MAJOR(rdev), MINOR(rdev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 	data = nfs3_alloc_createdata();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 	if (data == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 	status = posix_acl_create(dir, &sattr->ia_mode, &default_acl, &acl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 	data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_MKNOD];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 	data->arg.mknod.fh = NFS_FH(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) 	data->arg.mknod.name = dentry->d_name.name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 	data->arg.mknod.len = dentry->d_name.len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) 	data->arg.mknod.sattr = sattr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) 	data->arg.mknod.rdev = rdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) 	switch (sattr->ia_mode & S_IFMT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) 	case S_IFBLK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 		data->arg.mknod.type = NF3BLK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) 	case S_IFCHR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) 		data->arg.mknod.type = NF3CHR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) 	case S_IFIFO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) 		data->arg.mknod.type = NF3FIFO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 	case S_IFSOCK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 		data->arg.mknod.type = NF3SOCK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) 		status = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) 		goto out_release_acls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) 	d_alias = nfs3_do_create(dir, dentry, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 	status = PTR_ERR_OR_ZERO(d_alias);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) 	if (status != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 		goto out_release_acls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 	if (d_alias)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 		dentry = d_alias;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 	status = nfs3_proc_setacls(d_inode(dentry), acl, default_acl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 	dput(d_alias);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) out_release_acls:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 	posix_acl_release(acl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 	posix_acl_release(default_acl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 	nfs3_free_createdata(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 	dprintk("NFS reply mknod: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) nfs3_proc_statfs(struct nfs_server *server, struct nfs_fh *fhandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 		 struct nfs_fsstat *stat)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 		.rpc_proc	= &nfs3_procedures[NFS3PROC_FSSTAT],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) 		.rpc_argp	= fhandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 		.rpc_resp	= stat,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 	int	status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) 	dprintk("NFS call  fsstat\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 	nfs_fattr_init(stat->fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 	status = rpc_call_sync(server->client, &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 	dprintk("NFS reply fsstat: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) do_proc_fsinfo(struct rpc_clnt *client, struct nfs_fh *fhandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 		 struct nfs_fsinfo *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 		.rpc_proc	= &nfs3_procedures[NFS3PROC_FSINFO],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 		.rpc_argp	= fhandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 		.rpc_resp	= info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 	int	status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 	dprintk("NFS call  fsinfo\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) 	nfs_fattr_init(info->fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 	status = rpc_call_sync(client, &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 	dprintk("NFS reply fsinfo: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790)  * Bare-bones access to fsinfo: this is for nfs_get_root/nfs_get_sb via
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791)  * nfs_create_server
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) nfs3_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) 		   struct nfs_fsinfo *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) 	int	status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) 	status = do_proc_fsinfo(server->client, fhandle, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) 	if (status && server->nfs_client->cl_rpcclient != server->client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 		status = do_proc_fsinfo(server->nfs_client->cl_rpcclient, fhandle, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) nfs3_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 		   struct nfs_pathconf *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 	struct rpc_message msg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 		.rpc_proc	= &nfs3_procedures[NFS3PROC_PATHCONF],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 		.rpc_argp	= fhandle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 		.rpc_resp	= info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 	int	status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 	dprintk("NFS call  pathconf\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) 	nfs_fattr_init(info->fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 	status = rpc_call_sync(server->client, &msg, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 	dprintk("NFS reply pathconf: %d\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) static int nfs3_read_done(struct rpc_task *task, struct nfs_pgio_header *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 	struct inode *inode = hdr->inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) 	struct nfs_server *server = NFS_SERVER(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 	if (hdr->pgio_done_cb != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 		return hdr->pgio_done_cb(task, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 	if (nfs3_async_handle_jukebox(task, inode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) 		return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 	if (task->tk_status >= 0 && !server->read_hdrsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 		cmpxchg(&server->read_hdrsize, 0, hdr->res.replen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 	nfs_invalidate_atime(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) 	nfs_refresh_inode(inode, &hdr->fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) static void nfs3_proc_read_setup(struct nfs_pgio_header *hdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 				 struct rpc_message *msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 	msg->rpc_proc = &nfs3_procedures[NFS3PROC_READ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 	hdr->args.replen = NFS_SERVER(hdr->inode)->read_hdrsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) static int nfs3_proc_pgio_rpc_prepare(struct rpc_task *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 				      struct nfs_pgio_header *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 	rpc_call_start(task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) static int nfs3_write_done(struct rpc_task *task, struct nfs_pgio_header *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) 	struct inode *inode = hdr->inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) 	if (hdr->pgio_done_cb != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 		return hdr->pgio_done_cb(task, hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 	if (nfs3_async_handle_jukebox(task, inode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 		return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 	if (task->tk_status >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) 		nfs_writeback_update_inode(hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) static void nfs3_proc_write_setup(struct nfs_pgio_header *hdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 				  struct rpc_message *msg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 				  struct rpc_clnt **clnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 	msg->rpc_proc = &nfs3_procedures[NFS3PROC_WRITE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) static void nfs3_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) 	rpc_call_start(task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) static int nfs3_commit_done(struct rpc_task *task, struct nfs_commit_data *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) 	if (data->commit_done_cb != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 		return data->commit_done_cb(task, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 	if (nfs3_async_handle_jukebox(task, data->inode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) 		return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 	nfs_refresh_inode(data->inode, data->res.fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) static void nfs3_proc_commit_setup(struct nfs_commit_data *data, struct rpc_message *msg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 				   struct rpc_clnt **clnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) 	msg->rpc_proc = &nfs3_procedures[NFS3PROC_COMMIT];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) static void nfs3_nlm_alloc_call(void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) 	struct nfs_lock_context *l_ctx = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) 	if (l_ctx && test_bit(NFS_CONTEXT_UNLOCK, &l_ctx->open_context->flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) 		get_nfs_open_context(l_ctx->open_context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) 		nfs_get_lock_context(l_ctx->open_context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) static bool nfs3_nlm_unlock_prepare(struct rpc_task *task, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) 	struct nfs_lock_context *l_ctx = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) 	if (l_ctx && test_bit(NFS_CONTEXT_UNLOCK, &l_ctx->open_context->flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) 		return nfs_async_iocounter_wait(task, l_ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) 	return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) static void nfs3_nlm_release_call(void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) 	struct nfs_lock_context *l_ctx = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) 	struct nfs_open_context *ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) 	if (l_ctx && test_bit(NFS_CONTEXT_UNLOCK, &l_ctx->open_context->flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 		ctx = l_ctx->open_context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) 		nfs_put_lock_context(l_ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) 		put_nfs_open_context(ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) static const struct nlmclnt_operations nlmclnt_fl_close_lock_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 	.nlmclnt_alloc_call = nfs3_nlm_alloc_call,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 	.nlmclnt_unlock_prepare = nfs3_nlm_unlock_prepare,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 	.nlmclnt_release_call = nfs3_nlm_release_call,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) nfs3_proc_lock(struct file *filp, int cmd, struct file_lock *fl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 	struct inode *inode = file_inode(filp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 	struct nfs_lock_context *l_ctx = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 	struct nfs_open_context *ctx = nfs_file_open_context(filp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) 	if (fl->fl_flags & FL_CLOSE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 		l_ctx = nfs_get_lock_context(ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 		if (IS_ERR(l_ctx))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) 			l_ctx = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 			set_bit(NFS_CONTEXT_UNLOCK, &ctx->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) 	status = nlmclnt_proc(NFS_SERVER(inode)->nlm_host, cmd, fl, l_ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 	if (l_ctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 		nfs_put_lock_context(l_ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) static int nfs3_have_delegation(struct inode *inode, fmode_t flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) static const struct inode_operations nfs3_dir_inode_operations = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 	.create		= nfs_create,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) 	.lookup		= nfs_lookup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) 	.link		= nfs_link,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) 	.unlink		= nfs_unlink,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 	.symlink	= nfs_symlink,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) 	.mkdir		= nfs_mkdir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 	.rmdir		= nfs_rmdir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 	.mknod		= nfs_mknod,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) 	.rename		= nfs_rename,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 	.permission	= nfs_permission,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) 	.getattr	= nfs_getattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) 	.setattr	= nfs_setattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) #ifdef CONFIG_NFS_V3_ACL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) 	.listxattr	= nfs3_listxattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 	.get_acl	= nfs3_get_acl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) 	.set_acl	= nfs3_set_acl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) static const struct inode_operations nfs3_file_inode_operations = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 	.permission	= nfs_permission,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 	.getattr	= nfs_getattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 	.setattr	= nfs_setattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) #ifdef CONFIG_NFS_V3_ACL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 	.listxattr	= nfs3_listxattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 	.get_acl	= nfs3_get_acl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) 	.set_acl	= nfs3_set_acl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) const struct nfs_rpc_ops nfs_v3_clientops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) 	.version	= 3,			/* protocol version */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) 	.dentry_ops	= &nfs_dentry_operations,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) 	.dir_inode_ops	= &nfs3_dir_inode_operations,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) 	.file_inode_ops	= &nfs3_file_inode_operations,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) 	.file_ops	= &nfs_file_operations,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) 	.nlmclnt_ops	= &nlmclnt_fl_close_lock_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) 	.getroot	= nfs3_proc_get_root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) 	.submount	= nfs_submount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) 	.try_get_tree	= nfs_try_get_tree,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) 	.getattr	= nfs3_proc_getattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) 	.setattr	= nfs3_proc_setattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) 	.lookup		= nfs3_proc_lookup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 	.access		= nfs3_proc_access,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 	.readlink	= nfs3_proc_readlink,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 	.create		= nfs3_proc_create,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) 	.remove		= nfs3_proc_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 	.unlink_setup	= nfs3_proc_unlink_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 	.unlink_rpc_prepare = nfs3_proc_unlink_rpc_prepare,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) 	.unlink_done	= nfs3_proc_unlink_done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 	.rename_setup	= nfs3_proc_rename_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) 	.rename_rpc_prepare = nfs3_proc_rename_rpc_prepare,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) 	.rename_done	= nfs3_proc_rename_done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) 	.link		= nfs3_proc_link,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) 	.symlink	= nfs3_proc_symlink,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 	.mkdir		= nfs3_proc_mkdir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) 	.rmdir		= nfs3_proc_rmdir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) 	.readdir	= nfs3_proc_readdir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) 	.mknod		= nfs3_proc_mknod,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) 	.statfs		= nfs3_proc_statfs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) 	.fsinfo		= nfs3_proc_fsinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) 	.pathconf	= nfs3_proc_pathconf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) 	.decode_dirent	= nfs3_decode_dirent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) 	.pgio_rpc_prepare = nfs3_proc_pgio_rpc_prepare,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 	.read_setup	= nfs3_proc_read_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 	.read_done	= nfs3_read_done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 	.write_setup	= nfs3_proc_write_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 	.write_done	= nfs3_write_done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 	.commit_setup	= nfs3_proc_commit_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 	.commit_rpc_prepare = nfs3_proc_commit_rpc_prepare,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) 	.commit_done	= nfs3_commit_done,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 	.lock		= nfs3_proc_lock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) 	.clear_acl_cache = forget_all_cached_acls,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 	.close_context	= nfs_close_context,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) 	.have_delegation = nfs3_have_delegation,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) 	.alloc_client	= nfs_alloc_client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) 	.init_client	= nfs_init_client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) 	.free_client	= nfs_free_client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) 	.create_server	= nfs3_create_server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) 	.clone_server	= nfs3_clone_server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) };