xref: /openbmc/linux/fs/nfs/nfs3proc.c (revision cc6f3298)
1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds  *  linux/fs/nfs/nfs3proc.c
41da177e4SLinus Torvalds  *
51da177e4SLinus Torvalds  *  Client-side NFSv3 procedures stubs.
61da177e4SLinus Torvalds  *
71da177e4SLinus Torvalds  *  Copyright (C) 1997, Olaf Kirch
81da177e4SLinus Torvalds  */
91da177e4SLinus Torvalds 
101da177e4SLinus Torvalds #include <linux/mm.h>
111da177e4SLinus Torvalds #include <linux/errno.h>
121da177e4SLinus Torvalds #include <linux/string.h>
131da177e4SLinus Torvalds #include <linux/sunrpc/clnt.h>
145a0e3ad6STejun Heo #include <linux/slab.h>
151da177e4SLinus Torvalds #include <linux/nfs.h>
161da177e4SLinus Torvalds #include <linux/nfs3.h>
171da177e4SLinus Torvalds #include <linux/nfs_fs.h>
181da177e4SLinus Torvalds #include <linux/nfs_page.h>
191da177e4SLinus Torvalds #include <linux/lockd/bind.h>
20b7fa0554SAndreas Gruenbacher #include <linux/nfs_mount.h>
21d310310cSJeff Layton #include <linux/freezer.h>
220a6be655STejun Heo #include <linux/xattr.h>
231da177e4SLinus Torvalds 
24006ea73eSChuck Lever #include "iostat.h"
25f7b422b1SDavid Howells #include "internal.h"
2600a36a10SAnna Schumaker #include "nfs3_fs.h"
27006ea73eSChuck Lever 
281da177e4SLinus Torvalds #define NFSDBG_FACILITY		NFSDBG_PROC
291da177e4SLinus Torvalds 
30eb96d5c9SAndy Adamson /* A wrapper to handle the EJUKEBOX error messages */
311da177e4SLinus Torvalds static int
321da177e4SLinus Torvalds nfs3_rpc_wrapper(struct rpc_clnt *clnt, struct rpc_message *msg, int flags)
331da177e4SLinus Torvalds {
341da177e4SLinus Torvalds 	int res;
351da177e4SLinus Torvalds 	do {
361da177e4SLinus Torvalds 		res = rpc_call_sync(clnt, msg, flags);
37eb96d5c9SAndy Adamson 		if (res != -EJUKEBOX)
381da177e4SLinus Torvalds 			break;
39416ad3c9SColin Cross 		freezable_schedule_timeout_killable_unsafe(NFS_JUKEBOX_RETRY_TIME);
401da177e4SLinus Torvalds 		res = -ERESTARTSYS;
41150030b7SMatthew Wilcox 	} while (!fatal_signal_pending(current));
421da177e4SLinus Torvalds 	return res;
431da177e4SLinus Torvalds }
441da177e4SLinus Torvalds 
45dead28daSChuck Lever #define rpc_call_sync(clnt, msg, flags)	nfs3_rpc_wrapper(clnt, msg, flags)
461da177e4SLinus Torvalds 
471da177e4SLinus Torvalds static int
48006ea73eSChuck Lever nfs3_async_handle_jukebox(struct rpc_task *task, struct inode *inode)
491da177e4SLinus Torvalds {
50eb96d5c9SAndy Adamson 	if (task->tk_status != -EJUKEBOX)
511da177e4SLinus Torvalds 		return 0;
52006ea73eSChuck Lever 	nfs_inc_stats(inode, NFSIOS_DELAY);
531da177e4SLinus Torvalds 	task->tk_status = 0;
541da177e4SLinus Torvalds 	rpc_restart_call(task);
551da177e4SLinus Torvalds 	rpc_delay(task, NFS_JUKEBOX_RETRY_TIME);
561da177e4SLinus Torvalds 	return 1;
571da177e4SLinus Torvalds }
581da177e4SLinus Torvalds 
5903c21733SJ. Bruce Fields static int
6003c21733SJ. Bruce Fields do_proc_get_root(struct rpc_clnt *client, struct nfs_fh *fhandle,
6103c21733SJ. Bruce Fields 		 struct nfs_fsinfo *info)
6203c21733SJ. Bruce Fields {
63dead28daSChuck Lever 	struct rpc_message msg = {
64dead28daSChuck Lever 		.rpc_proc	= &nfs3_procedures[NFS3PROC_FSINFO],
65dead28daSChuck Lever 		.rpc_argp	= fhandle,
66dead28daSChuck Lever 		.rpc_resp	= info,
67dead28daSChuck Lever 	};
6803c21733SJ. Bruce Fields 	int	status;
6903c21733SJ. Bruce Fields 
703110ff80SHarvey Harrison 	dprintk("%s: call  fsinfo\n", __func__);
7103c21733SJ. Bruce Fields 	nfs_fattr_init(info->fattr);
72dead28daSChuck Lever 	status = rpc_call_sync(client, &msg, 0);
733110ff80SHarvey Harrison 	dprintk("%s: reply fsinfo: %d\n", __func__, status);
7408660043STrond Myklebust 	if (status == 0 && !(info->fattr->valid & NFS_ATTR_FATTR)) {
75dead28daSChuck Lever 		msg.rpc_proc = &nfs3_procedures[NFS3PROC_GETATTR];
76dead28daSChuck Lever 		msg.rpc_resp = info->fattr;
77dead28daSChuck Lever 		status = rpc_call_sync(client, &msg, 0);
783110ff80SHarvey Harrison 		dprintk("%s: reply getattr: %d\n", __func__, status);
7903c21733SJ. Bruce Fields 	}
8003c21733SJ. Bruce Fields 	return status;
8103c21733SJ. Bruce Fields }
8203c21733SJ. Bruce Fields 
831da177e4SLinus Torvalds /*
8454ceac45SDavid Howells  * Bare-bones access to getattr: this is for nfs_get_root/nfs_get_sb
851da177e4SLinus Torvalds  */
861da177e4SLinus Torvalds static int
871da177e4SLinus Torvalds nfs3_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
881da177e4SLinus Torvalds 		   struct nfs_fsinfo *info)
891da177e4SLinus Torvalds {
901da177e4SLinus Torvalds 	int	status;
911da177e4SLinus Torvalds 
9203c21733SJ. Bruce Fields 	status = do_proc_get_root(server->client, fhandle, info);
935006a76cSDavid Howells 	if (status && server->nfs_client->cl_rpcclient != server->client)
945006a76cSDavid Howells 		status = do_proc_get_root(server->nfs_client->cl_rpcclient, fhandle, info);
951da177e4SLinus Torvalds 	return status;
961da177e4SLinus Torvalds }
971da177e4SLinus Torvalds 
981da177e4SLinus Torvalds /*
991da177e4SLinus Torvalds  * One function for each procedure in the NFS protocol.
1001da177e4SLinus Torvalds  */
1011da177e4SLinus Torvalds static int
1021da177e4SLinus Torvalds nfs3_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
1032ef61e0eSAnna Schumaker 		struct nfs_fattr *fattr, struct inode *inode)
1041da177e4SLinus Torvalds {
105dead28daSChuck Lever 	struct rpc_message msg = {
106dead28daSChuck Lever 		.rpc_proc	= &nfs3_procedures[NFS3PROC_GETATTR],
107dead28daSChuck Lever 		.rpc_argp	= fhandle,
108dead28daSChuck Lever 		.rpc_resp	= fattr,
109dead28daSChuck Lever 	};
1101da177e4SLinus Torvalds 	int	status;
111c74dfe97STrond Myklebust 	unsigned short task_flags = 0;
112c74dfe97STrond Myklebust 
113c74dfe97STrond Myklebust 	/* Is this is an attribute revalidation, subject to softreval? */
114c74dfe97STrond Myklebust 	if (inode && (server->flags & NFS_MOUNT_SOFTREVAL))
115c74dfe97STrond Myklebust 		task_flags |= RPC_TASK_TIMEOUT;
1161da177e4SLinus Torvalds 
1171da177e4SLinus Torvalds 	dprintk("NFS call  getattr\n");
1180e574af1STrond Myklebust 	nfs_fattr_init(fattr);
119c74dfe97STrond Myklebust 	status = rpc_call_sync(server->client, &msg, task_flags);
1201da177e4SLinus Torvalds 	dprintk("NFS reply getattr: %d\n", status);
1211da177e4SLinus Torvalds 	return status;
1221da177e4SLinus Torvalds }
1231da177e4SLinus Torvalds 
1241da177e4SLinus Torvalds static int
1251da177e4SLinus Torvalds nfs3_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
1261da177e4SLinus Torvalds 			struct iattr *sattr)
1271da177e4SLinus Torvalds {
1282b0143b5SDavid Howells 	struct inode *inode = d_inode(dentry);
1291da177e4SLinus Torvalds 	struct nfs3_sattrargs	arg = {
1301da177e4SLinus Torvalds 		.fh		= NFS_FH(inode),
1311da177e4SLinus Torvalds 		.sattr		= sattr,
1321da177e4SLinus Torvalds 	};
133dead28daSChuck Lever 	struct rpc_message msg = {
134dead28daSChuck Lever 		.rpc_proc	= &nfs3_procedures[NFS3PROC_SETATTR],
135dead28daSChuck Lever 		.rpc_argp	= &arg,
136dead28daSChuck Lever 		.rpc_resp	= fattr,
137dead28daSChuck Lever 	};
1381da177e4SLinus Torvalds 	int	status;
1391da177e4SLinus Torvalds 
1401da177e4SLinus Torvalds 	dprintk("NFS call  setattr\n");
141659bfcd6STrond Myklebust 	if (sattr->ia_valid & ATTR_FILE)
142659bfcd6STrond Myklebust 		msg.rpc_cred = nfs_file_cred(sattr->ia_file);
1430e574af1STrond Myklebust 	nfs_fattr_init(fattr);
144dead28daSChuck Lever 	status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
145dbc898aeSchendt 	if (status == 0) {
146fe1e8dbeSSu Yanjun 		nfs_setattr_update_inode(inode, sattr, fattr);
147dbc898aeSchendt 		if (NFS_I(inode)->cache_validity & NFS_INO_INVALID_ACL)
148dbc898aeSchendt 			nfs_zap_acl_cache(inode);
149dbc898aeSchendt 	}
1501da177e4SLinus Torvalds 	dprintk("NFS reply setattr: %d\n", status);
1511da177e4SLinus Torvalds 	return status;
1521da177e4SLinus Torvalds }
1531da177e4SLinus Torvalds 
1541da177e4SLinus Torvalds static int
1555f447cb8STrond Myklebust __nfs3_proc_lookup(struct inode *dir, const char *name, size_t len,
1561775fd3eSDavid Quigley 		   struct nfs_fh *fhandle, struct nfs_fattr *fattr,
1575f447cb8STrond Myklebust 		   unsigned short task_flags)
1581da177e4SLinus Torvalds {
1591da177e4SLinus Torvalds 	struct nfs3_diropargs	arg = {
1601da177e4SLinus Torvalds 		.fh		= NFS_FH(dir),
1615f447cb8STrond Myklebust 		.name		= name,
1625f447cb8STrond Myklebust 		.len		= len
1631da177e4SLinus Torvalds 	};
1641da177e4SLinus Torvalds 	struct nfs3_diropres	res = {
1651da177e4SLinus Torvalds 		.fh		= fhandle,
1661da177e4SLinus Torvalds 		.fattr		= fattr
1671da177e4SLinus Torvalds 	};
168dead28daSChuck Lever 	struct rpc_message msg = {
169dead28daSChuck Lever 		.rpc_proc	= &nfs3_procedures[NFS3PROC_LOOKUP],
170dead28daSChuck Lever 		.rpc_argp	= &arg,
171dead28daSChuck Lever 		.rpc_resp	= &res,
172dead28daSChuck Lever 	};
1731da177e4SLinus Torvalds 	int			status;
174f7b37b8bSTrond Myklebust 
175e1fb4d05STrond Myklebust 	res.dir_attr = nfs_alloc_fattr();
176e1fb4d05STrond Myklebust 	if (res.dir_attr == NULL)
177e1fb4d05STrond Myklebust 		return -ENOMEM;
178e1fb4d05STrond Myklebust 
1790e574af1STrond Myklebust 	nfs_fattr_init(fattr);
180f7b37b8bSTrond Myklebust 	status = rpc_call_sync(NFS_CLIENT(dir), &msg, task_flags);
181e1fb4d05STrond Myklebust 	nfs_refresh_inode(dir, res.dir_attr);
182dead28daSChuck Lever 	if (status >= 0 && !(fattr->valid & NFS_ATTR_FATTR)) {
183dead28daSChuck Lever 		msg.rpc_proc = &nfs3_procedures[NFS3PROC_GETATTR];
184dead28daSChuck Lever 		msg.rpc_argp = fhandle;
185dead28daSChuck Lever 		msg.rpc_resp = fattr;
186f7b37b8bSTrond Myklebust 		status = rpc_call_sync(NFS_CLIENT(dir), &msg, task_flags);
187dead28daSChuck Lever 	}
188e1fb4d05STrond Myklebust 	nfs_free_fattr(res.dir_attr);
1891da177e4SLinus Torvalds 	dprintk("NFS reply lookup: %d\n", status);
1901da177e4SLinus Torvalds 	return status;
1911da177e4SLinus Torvalds }
1921da177e4SLinus Torvalds 
1935f447cb8STrond Myklebust static int
1945f447cb8STrond Myklebust nfs3_proc_lookup(struct inode *dir, struct dentry *dentry,
1959558a007SAnna Schumaker 		 struct nfs_fh *fhandle, struct nfs_fattr *fattr)
1965f447cb8STrond Myklebust {
1975f447cb8STrond Myklebust 	unsigned short task_flags = 0;
1985f447cb8STrond Myklebust 
1995f447cb8STrond Myklebust 	/* Is this is an attribute revalidation, subject to softreval? */
2005f447cb8STrond Myklebust 	if (nfs_lookup_is_soft_revalidate(dentry))
2015f447cb8STrond Myklebust 		task_flags |= RPC_TASK_TIMEOUT;
2025f447cb8STrond Myklebust 
2035f447cb8STrond Myklebust 	dprintk("NFS call  lookup %pd2\n", dentry);
2045f447cb8STrond Myklebust 	return __nfs3_proc_lookup(dir, dentry->d_name.name,
2055f447cb8STrond Myklebust 				  dentry->d_name.len, fhandle, fattr,
2065f447cb8STrond Myklebust 				  task_flags);
2075f447cb8STrond Myklebust }
2085f447cb8STrond Myklebust 
2093c5e9a59STrond Myklebust static int nfs3_proc_lookupp(struct inode *inode, struct nfs_fh *fhandle,
210ba4bc8dcSAnna Schumaker 			     struct nfs_fattr *fattr)
2113c5e9a59STrond Myklebust {
2123c5e9a59STrond Myklebust 	const char dotdot[] = "..";
2133c5e9a59STrond Myklebust 	const size_t len = strlen(dotdot);
2143c5e9a59STrond Myklebust 	unsigned short task_flags = 0;
2153c5e9a59STrond Myklebust 
2163c5e9a59STrond Myklebust 	if (NFS_SERVER(inode)->flags & NFS_MOUNT_SOFTREVAL)
2173c5e9a59STrond Myklebust 		task_flags |= RPC_TASK_TIMEOUT;
2183c5e9a59STrond Myklebust 
2193c5e9a59STrond Myklebust 	return __nfs3_proc_lookup(inode, dotdot, len, fhandle, fattr,
2203c5e9a59STrond Myklebust 				  task_flags);
2213c5e9a59STrond Myklebust }
2223c5e9a59STrond Myklebust 
2231da177e4SLinus Torvalds static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry)
2241da177e4SLinus Torvalds {
2251da177e4SLinus Torvalds 	struct nfs3_accessargs	arg = {
2261da177e4SLinus Torvalds 		.fh		= NFS_FH(inode),
2271750d929SAnna Schumaker 		.access		= entry->mask,
2281da177e4SLinus Torvalds 	};
229c407d41aSTrond Myklebust 	struct nfs3_accessres	res;
2301da177e4SLinus Torvalds 	struct rpc_message msg = {
2311da177e4SLinus Torvalds 		.rpc_proc	= &nfs3_procedures[NFS3PROC_ACCESS],
2321da177e4SLinus Torvalds 		.rpc_argp	= &arg,
2331da177e4SLinus Torvalds 		.rpc_resp	= &res,
234a52458b4SNeilBrown 		.rpc_cred	= entry->cred,
2351da177e4SLinus Torvalds 	};
236c407d41aSTrond Myklebust 	int status = -ENOMEM;
2371da177e4SLinus Torvalds 
2381da177e4SLinus Torvalds 	dprintk("NFS call  access\n");
239c407d41aSTrond Myklebust 	res.fattr = nfs_alloc_fattr();
240c407d41aSTrond Myklebust 	if (res.fattr == NULL)
241c407d41aSTrond Myklebust 		goto out;
242c407d41aSTrond Myklebust 
2431da177e4SLinus Torvalds 	status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
244c407d41aSTrond Myklebust 	nfs_refresh_inode(inode, res.fattr);
245eda3e208STrond Myklebust 	if (status == 0)
246eda3e208STrond Myklebust 		nfs_access_set_mask(entry, res.access);
247c407d41aSTrond Myklebust 	nfs_free_fattr(res.fattr);
248c407d41aSTrond Myklebust out:
2491da177e4SLinus Torvalds 	dprintk("NFS reply access: %d\n", status);
2501da177e4SLinus Torvalds 	return status;
2511da177e4SLinus Torvalds }
2521da177e4SLinus Torvalds 
2531da177e4SLinus Torvalds static int nfs3_proc_readlink(struct inode *inode, struct page *page,
2541da177e4SLinus Torvalds 		unsigned int pgbase, unsigned int pglen)
2551da177e4SLinus Torvalds {
2563b14d654STrond Myklebust 	struct nfs_fattr	*fattr;
2571da177e4SLinus Torvalds 	struct nfs3_readlinkargs args = {
2581da177e4SLinus Torvalds 		.fh		= NFS_FH(inode),
2591da177e4SLinus Torvalds 		.pgbase		= pgbase,
2601da177e4SLinus Torvalds 		.pglen		= pglen,
2611da177e4SLinus Torvalds 		.pages		= &page
2621da177e4SLinus Torvalds 	};
263dead28daSChuck Lever 	struct rpc_message msg = {
264dead28daSChuck Lever 		.rpc_proc	= &nfs3_procedures[NFS3PROC_READLINK],
265dead28daSChuck Lever 		.rpc_argp	= &args,
266dead28daSChuck Lever 	};
2673b14d654STrond Myklebust 	int status = -ENOMEM;
2681da177e4SLinus Torvalds 
2691da177e4SLinus Torvalds 	dprintk("NFS call  readlink\n");
2703b14d654STrond Myklebust 	fattr = nfs_alloc_fattr();
2713b14d654STrond Myklebust 	if (fattr == NULL)
2723b14d654STrond Myklebust 		goto out;
2733b14d654STrond Myklebust 	msg.rpc_resp = fattr;
2743b14d654STrond Myklebust 
275dead28daSChuck Lever 	status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
2763b14d654STrond Myklebust 	nfs_refresh_inode(inode, fattr);
2773b14d654STrond Myklebust 	nfs_free_fattr(fattr);
2783b14d654STrond Myklebust out:
2791da177e4SLinus Torvalds 	dprintk("NFS reply readlink: %d\n", status);
2801da177e4SLinus Torvalds 	return status;
2811da177e4SLinus Torvalds }
2821da177e4SLinus Torvalds 
2830b4aae7aSTrond Myklebust struct nfs3_createdata {
2840b4aae7aSTrond Myklebust 	struct rpc_message msg;
2850b4aae7aSTrond Myklebust 	union {
2860b4aae7aSTrond Myklebust 		struct nfs3_createargs create;
2870b4aae7aSTrond Myklebust 		struct nfs3_mkdirargs mkdir;
2880b4aae7aSTrond Myklebust 		struct nfs3_symlinkargs symlink;
2890b4aae7aSTrond Myklebust 		struct nfs3_mknodargs mknod;
2900b4aae7aSTrond Myklebust 	} arg;
2910b4aae7aSTrond Myklebust 	struct nfs3_diropres res;
2920b4aae7aSTrond Myklebust 	struct nfs_fh fh;
2930b4aae7aSTrond Myklebust 	struct nfs_fattr fattr;
2940b4aae7aSTrond Myklebust 	struct nfs_fattr dir_attr;
2950b4aae7aSTrond Myklebust };
2960b4aae7aSTrond Myklebust 
2970b4aae7aSTrond Myklebust static struct nfs3_createdata *nfs3_alloc_createdata(void)
2980b4aae7aSTrond Myklebust {
2990b4aae7aSTrond Myklebust 	struct nfs3_createdata *data;
3000b4aae7aSTrond Myklebust 
3010b4aae7aSTrond Myklebust 	data = kzalloc(sizeof(*data), GFP_KERNEL);
3020b4aae7aSTrond Myklebust 	if (data != NULL) {
3030b4aae7aSTrond Myklebust 		data->msg.rpc_argp = &data->arg;
3040b4aae7aSTrond Myklebust 		data->msg.rpc_resp = &data->res;
3050b4aae7aSTrond Myklebust 		data->res.fh = &data->fh;
3060b4aae7aSTrond Myklebust 		data->res.fattr = &data->fattr;
3070b4aae7aSTrond Myklebust 		data->res.dir_attr = &data->dir_attr;
3080b4aae7aSTrond Myklebust 		nfs_fattr_init(data->res.fattr);
3090b4aae7aSTrond Myklebust 		nfs_fattr_init(data->res.dir_attr);
3100b4aae7aSTrond Myklebust 	}
3110b4aae7aSTrond Myklebust 	return data;
3120b4aae7aSTrond Myklebust }
3130b4aae7aSTrond Myklebust 
31417fd6e45SBenjamin Coddington static struct dentry *
31517fd6e45SBenjamin Coddington nfs3_do_create(struct inode *dir, struct dentry *dentry, struct nfs3_createdata *data)
3160b4aae7aSTrond Myklebust {
3170b4aae7aSTrond Myklebust 	int status;
3180b4aae7aSTrond Myklebust 
3190b4aae7aSTrond Myklebust 	status = rpc_call_sync(NFS_CLIENT(dir), &data->msg, 0);
3200b4aae7aSTrond Myklebust 	nfs_post_op_update_inode(dir, data->res.dir_attr);
32117fd6e45SBenjamin Coddington 	if (status != 0)
32217fd6e45SBenjamin Coddington 		return ERR_PTR(status);
32317fd6e45SBenjamin Coddington 
324*cc6f3298SAnna Schumaker 	return nfs_add_or_obtain(dentry, data->res.fh, data->res.fattr);
3250b4aae7aSTrond Myklebust }
3260b4aae7aSTrond Myklebust 
3270b4aae7aSTrond Myklebust static void nfs3_free_createdata(struct nfs3_createdata *data)
3280b4aae7aSTrond Myklebust {
3290b4aae7aSTrond Myklebust 	kfree(data);
3300b4aae7aSTrond Myklebust }
3310b4aae7aSTrond Myklebust 
3321da177e4SLinus Torvalds /*
3331da177e4SLinus Torvalds  * Create a regular file.
3341da177e4SLinus Torvalds  */
3351da177e4SLinus Torvalds static int
3361da177e4SLinus Torvalds nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
3378867fe58SMiklos Szeredi 		 int flags)
3381da177e4SLinus Torvalds {
339013cdf10SChristoph Hellwig 	struct posix_acl *default_acl, *acl;
3400b4aae7aSTrond Myklebust 	struct nfs3_createdata *data;
34117fd6e45SBenjamin Coddington 	struct dentry *d_alias;
3420b4aae7aSTrond Myklebust 	int status = -ENOMEM;
3431da177e4SLinus Torvalds 
3446de1472fSAl Viro 	dprintk("NFS call  create %pd\n", dentry);
3450b4aae7aSTrond Myklebust 
3460b4aae7aSTrond Myklebust 	data = nfs3_alloc_createdata();
3470b4aae7aSTrond Myklebust 	if (data == NULL)
3480b4aae7aSTrond Myklebust 		goto out;
3490b4aae7aSTrond Myklebust 
3500b4aae7aSTrond Myklebust 	data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_CREATE];
3510b4aae7aSTrond Myklebust 	data->arg.create.fh = NFS_FH(dir);
3520b4aae7aSTrond Myklebust 	data->arg.create.name = dentry->d_name.name;
3530b4aae7aSTrond Myklebust 	data->arg.create.len = dentry->d_name.len;
3540b4aae7aSTrond Myklebust 	data->arg.create.sattr = sattr;
3550b4aae7aSTrond Myklebust 
3560b4aae7aSTrond Myklebust 	data->arg.create.createmode = NFS3_CREATE_UNCHECKED;
3571da177e4SLinus Torvalds 	if (flags & O_EXCL) {
3580b4aae7aSTrond Myklebust 		data->arg.create.createmode  = NFS3_CREATE_EXCLUSIVE;
359a9943d11STrond Myklebust 		data->arg.create.verifier[0] = cpu_to_be32(jiffies);
360a9943d11STrond Myklebust 		data->arg.create.verifier[1] = cpu_to_be32(current->pid);
3611da177e4SLinus Torvalds 	}
3621da177e4SLinus Torvalds 
363013cdf10SChristoph Hellwig 	status = posix_acl_create(dir, &sattr->ia_mode, &default_acl, &acl);
364013cdf10SChristoph Hellwig 	if (status)
365013cdf10SChristoph Hellwig 		goto out;
366055ffbeaSAndreas Gruenbacher 
3670b4aae7aSTrond Myklebust 	for (;;) {
36817fd6e45SBenjamin Coddington 		d_alias = nfs3_do_create(dir, dentry, data);
36917fd6e45SBenjamin Coddington 		status = PTR_ERR_OR_ZERO(d_alias);
3701da177e4SLinus Torvalds 
3710b4aae7aSTrond Myklebust 		if (status != -ENOTSUPP)
3720b4aae7aSTrond Myklebust 			break;
3730b4aae7aSTrond Myklebust 		/* If the server doesn't support the exclusive creation
3740b4aae7aSTrond Myklebust 		 * semantics, try again with simple 'guarded' mode. */
3750b4aae7aSTrond Myklebust 		switch (data->arg.create.createmode) {
3761da177e4SLinus Torvalds 			case NFS3_CREATE_EXCLUSIVE:
3770b4aae7aSTrond Myklebust 				data->arg.create.createmode = NFS3_CREATE_GUARDED;
3781da177e4SLinus Torvalds 				break;
3791da177e4SLinus Torvalds 
3801da177e4SLinus Torvalds 			case NFS3_CREATE_GUARDED:
3810b4aae7aSTrond Myklebust 				data->arg.create.createmode = NFS3_CREATE_UNCHECKED;
3821da177e4SLinus Torvalds 				break;
3831da177e4SLinus Torvalds 
3841da177e4SLinus Torvalds 			case NFS3_CREATE_UNCHECKED:
3851fcb6fcdSGao Xiang 				goto out_release_acls;
3861da177e4SLinus Torvalds 		}
3870b4aae7aSTrond Myklebust 		nfs_fattr_init(data->res.dir_attr);
3880b4aae7aSTrond Myklebust 		nfs_fattr_init(data->res.fattr);
3891da177e4SLinus Torvalds 	}
3901da177e4SLinus Torvalds 
3911da177e4SLinus Torvalds 	if (status != 0)
392013cdf10SChristoph Hellwig 		goto out_release_acls;
3931da177e4SLinus Torvalds 
39417fd6e45SBenjamin Coddington 	if (d_alias)
39517fd6e45SBenjamin Coddington 		dentry = d_alias;
39617fd6e45SBenjamin Coddington 
3971da177e4SLinus Torvalds 	/* When we created the file with exclusive semantics, make
3981da177e4SLinus Torvalds 	 * sure we set the attributes afterwards. */
3990b4aae7aSTrond Myklebust 	if (data->arg.create.createmode == NFS3_CREATE_EXCLUSIVE) {
4001da177e4SLinus Torvalds 		dprintk("NFS call  setattr (post-create)\n");
4011da177e4SLinus Torvalds 
4021da177e4SLinus Torvalds 		if (!(sattr->ia_valid & ATTR_ATIME_SET))
4031da177e4SLinus Torvalds 			sattr->ia_valid |= ATTR_ATIME;
4041da177e4SLinus Torvalds 		if (!(sattr->ia_valid & ATTR_MTIME_SET))
4051da177e4SLinus Torvalds 			sattr->ia_valid |= ATTR_MTIME;
4061da177e4SLinus Torvalds 
4071da177e4SLinus Torvalds 		/* Note: we could use a guarded setattr here, but I'm
4081da177e4SLinus Torvalds 		 * not sure this buys us anything (and I'd have
4091da177e4SLinus Torvalds 		 * to revamp the NFSv3 XDR code) */
4100b4aae7aSTrond Myklebust 		status = nfs3_proc_setattr(dentry, data->res.fattr, sattr);
4112b0143b5SDavid Howells 		nfs_post_op_update_inode(d_inode(dentry), data->res.fattr);
4121da177e4SLinus Torvalds 		dprintk("NFS reply setattr (post-create): %d\n", status);
413055ffbeaSAndreas Gruenbacher 		if (status != 0)
41417fd6e45SBenjamin Coddington 			goto out_dput;
4150b4aae7aSTrond Myklebust 	}
416013cdf10SChristoph Hellwig 
4172b0143b5SDavid Howells 	status = nfs3_proc_setacls(d_inode(dentry), acl, default_acl);
418013cdf10SChristoph Hellwig 
41917fd6e45SBenjamin Coddington out_dput:
42017fd6e45SBenjamin Coddington 	dput(d_alias);
421013cdf10SChristoph Hellwig out_release_acls:
422013cdf10SChristoph Hellwig 	posix_acl_release(acl);
423013cdf10SChristoph Hellwig 	posix_acl_release(default_acl);
4241da177e4SLinus Torvalds out:
4250b4aae7aSTrond Myklebust 	nfs3_free_createdata(data);
4261da177e4SLinus Torvalds 	dprintk("NFS reply create: %d\n", status);
4271da177e4SLinus Torvalds 	return status;
4281da177e4SLinus Torvalds }
4291da177e4SLinus Torvalds 
4301da177e4SLinus Torvalds static int
431912678dbSTrond Myklebust nfs3_proc_remove(struct inode *dir, struct dentry *dentry)
4321da177e4SLinus Torvalds {
4334fdc17b2STrond Myklebust 	struct nfs_removeargs arg = {
4341da177e4SLinus Torvalds 		.fh = NFS_FH(dir),
435912678dbSTrond Myklebust 		.name = dentry->d_name,
4361da177e4SLinus Torvalds 	};
4374fdc17b2STrond Myklebust 	struct nfs_removeres res;
4381da177e4SLinus Torvalds 	struct rpc_message msg = {
4391da177e4SLinus Torvalds 		.rpc_proc = &nfs3_procedures[NFS3PROC_REMOVE],
4401da177e4SLinus Torvalds 		.rpc_argp = &arg,
4414fdc17b2STrond Myklebust 		.rpc_resp = &res,
4421da177e4SLinus Torvalds 	};
443d346890bSTrond Myklebust 	int status = -ENOMEM;
4441da177e4SLinus Torvalds 
445912678dbSTrond Myklebust 	dprintk("NFS call  remove %pd2\n", dentry);
446d346890bSTrond Myklebust 	res.dir_attr = nfs_alloc_fattr();
447d346890bSTrond Myklebust 	if (res.dir_attr == NULL)
448d346890bSTrond Myklebust 		goto out;
449d346890bSTrond Myklebust 
4501da177e4SLinus Torvalds 	status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
451d346890bSTrond Myklebust 	nfs_post_op_update_inode(dir, res.dir_attr);
452d346890bSTrond Myklebust 	nfs_free_fattr(res.dir_attr);
453d346890bSTrond Myklebust out:
4541da177e4SLinus Torvalds 	dprintk("NFS reply remove: %d\n", status);
4551da177e4SLinus Torvalds 	return status;
4561da177e4SLinus Torvalds }
4571da177e4SLinus Torvalds 
458e4eff1a6STrond Myklebust static void
459ed7e9ad0STrond Myklebust nfs3_proc_unlink_setup(struct rpc_message *msg,
460ed7e9ad0STrond Myklebust 		struct dentry *dentry,
461ed7e9ad0STrond Myklebust 		struct inode *inode)
4621da177e4SLinus Torvalds {
4631da177e4SLinus Torvalds 	msg->rpc_proc = &nfs3_procedures[NFS3PROC_REMOVE];
4641da177e4SLinus Torvalds }
4651da177e4SLinus Torvalds 
46634e137ccSBryan Schumaker static void nfs3_proc_unlink_rpc_prepare(struct rpc_task *task, struct nfs_unlinkdata *data)
46734e137ccSBryan Schumaker {
46834e137ccSBryan Schumaker 	rpc_call_start(task);
46934e137ccSBryan Schumaker }
47034e137ccSBryan Schumaker 
4711da177e4SLinus Torvalds static int
472e4eff1a6STrond Myklebust nfs3_proc_unlink_done(struct rpc_task *task, struct inode *dir)
4731da177e4SLinus Torvalds {
474e4eff1a6STrond Myklebust 	struct nfs_removeres *res;
475e4eff1a6STrond Myklebust 	if (nfs3_async_handle_jukebox(task, dir))
4761da177e4SLinus Torvalds 		return 0;
477e4eff1a6STrond Myklebust 	res = task->tk_msg.rpc_resp;
478d346890bSTrond Myklebust 	nfs_post_op_update_inode(dir, res->dir_attr);
479e4eff1a6STrond Myklebust 	return 1;
4801da177e4SLinus Torvalds }
4811da177e4SLinus Torvalds 
482d3d4152aSJeff Layton static void
483f2c2c552STrond Myklebust nfs3_proc_rename_setup(struct rpc_message *msg,
484f2c2c552STrond Myklebust 		struct dentry *old_dentry,
485f2c2c552STrond Myklebust 		struct dentry *new_dentry)
486d3d4152aSJeff Layton {
487d3d4152aSJeff Layton 	msg->rpc_proc = &nfs3_procedures[NFS3PROC_RENAME];
488d3d4152aSJeff Layton }
489d3d4152aSJeff Layton 
490c6bfa1a1SBryan Schumaker static void nfs3_proc_rename_rpc_prepare(struct rpc_task *task, struct nfs_renamedata *data)
491c6bfa1a1SBryan Schumaker {
492c6bfa1a1SBryan Schumaker 	rpc_call_start(task);
493c6bfa1a1SBryan Schumaker }
494c6bfa1a1SBryan Schumaker 
495d3d4152aSJeff Layton static int
496d3d4152aSJeff Layton nfs3_proc_rename_done(struct rpc_task *task, struct inode *old_dir,
497d3d4152aSJeff Layton 		      struct inode *new_dir)
498d3d4152aSJeff Layton {
499d3d4152aSJeff Layton 	struct nfs_renameres *res;
500d3d4152aSJeff Layton 
501d3d4152aSJeff Layton 	if (nfs3_async_handle_jukebox(task, old_dir))
502d3d4152aSJeff Layton 		return 0;
503d3d4152aSJeff Layton 	res = task->tk_msg.rpc_resp;
504d3d4152aSJeff Layton 
505d3d4152aSJeff Layton 	nfs_post_op_update_inode(old_dir, res->old_fattr);
506d3d4152aSJeff Layton 	nfs_post_op_update_inode(new_dir, res->new_fattr);
507d3d4152aSJeff Layton 	return 1;
508d3d4152aSJeff Layton }
509d3d4152aSJeff Layton 
5101da177e4SLinus Torvalds static int
511beffb8feSAl Viro nfs3_proc_link(struct inode *inode, struct inode *dir, const struct qstr *name)
5121da177e4SLinus Torvalds {
5131da177e4SLinus Torvalds 	struct nfs3_linkargs	arg = {
5141da177e4SLinus Torvalds 		.fromfh		= NFS_FH(inode),
5151da177e4SLinus Torvalds 		.tofh		= NFS_FH(dir),
5161da177e4SLinus Torvalds 		.toname		= name->name,
5171da177e4SLinus Torvalds 		.tolen		= name->len
5181da177e4SLinus Torvalds 	};
519136f2627STrond Myklebust 	struct nfs3_linkres	res;
520dead28daSChuck Lever 	struct rpc_message msg = {
521dead28daSChuck Lever 		.rpc_proc	= &nfs3_procedures[NFS3PROC_LINK],
522dead28daSChuck Lever 		.rpc_argp	= &arg,
523dead28daSChuck Lever 		.rpc_resp	= &res,
524dead28daSChuck Lever 	};
525136f2627STrond Myklebust 	int status = -ENOMEM;
5261da177e4SLinus Torvalds 
5271da177e4SLinus Torvalds 	dprintk("NFS call  link %s\n", name->name);
528136f2627STrond Myklebust 	res.fattr = nfs_alloc_fattr();
529136f2627STrond Myklebust 	res.dir_attr = nfs_alloc_fattr();
530136f2627STrond Myklebust 	if (res.fattr == NULL || res.dir_attr == NULL)
531136f2627STrond Myklebust 		goto out;
532136f2627STrond Myklebust 
533dead28daSChuck Lever 	status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
534136f2627STrond Myklebust 	nfs_post_op_update_inode(dir, res.dir_attr);
535136f2627STrond Myklebust 	nfs_post_op_update_inode(inode, res.fattr);
536136f2627STrond Myklebust out:
537136f2627STrond Myklebust 	nfs_free_fattr(res.dir_attr);
538136f2627STrond Myklebust 	nfs_free_fattr(res.fattr);
5391da177e4SLinus Torvalds 	dprintk("NFS reply link: %d\n", status);
5401da177e4SLinus Torvalds 	return status;
5411da177e4SLinus Torvalds }
5421da177e4SLinus Torvalds 
5431da177e4SLinus Torvalds static int
54494a6d753SChuck Lever nfs3_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page,
54594a6d753SChuck Lever 		  unsigned int len, struct iattr *sattr)
5461da177e4SLinus Torvalds {
5470b4aae7aSTrond Myklebust 	struct nfs3_createdata *data;
54817fd6e45SBenjamin Coddington 	struct dentry *d_alias;
5490b4aae7aSTrond Myklebust 	int status = -ENOMEM;
5501da177e4SLinus Torvalds 
55194a6d753SChuck Lever 	if (len > NFS3_MAXPATHLEN)
5521da177e4SLinus Torvalds 		return -ENAMETOOLONG;
5534f390c15SChuck Lever 
5546de1472fSAl Viro 	dprintk("NFS call  symlink %pd\n", dentry);
55594a6d753SChuck Lever 
5560b4aae7aSTrond Myklebust 	data = nfs3_alloc_createdata();
5570b4aae7aSTrond Myklebust 	if (data == NULL)
5584f390c15SChuck Lever 		goto out;
5590b4aae7aSTrond Myklebust 	data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_SYMLINK];
5600b4aae7aSTrond Myklebust 	data->arg.symlink.fromfh = NFS_FH(dir);
5610b4aae7aSTrond Myklebust 	data->arg.symlink.fromname = dentry->d_name.name;
5620b4aae7aSTrond Myklebust 	data->arg.symlink.fromlen = dentry->d_name.len;
5630b4aae7aSTrond Myklebust 	data->arg.symlink.pages = &page;
5640b4aae7aSTrond Myklebust 	data->arg.symlink.pathlen = len;
5650b4aae7aSTrond Myklebust 	data->arg.symlink.sattr = sattr;
5660b4aae7aSTrond Myklebust 
56717fd6e45SBenjamin Coddington 	d_alias = nfs3_do_create(dir, dentry, data);
56817fd6e45SBenjamin Coddington 	status = PTR_ERR_OR_ZERO(d_alias);
56917fd6e45SBenjamin Coddington 
57017fd6e45SBenjamin Coddington 	if (status == 0)
57117fd6e45SBenjamin Coddington 		dput(d_alias);
5720b4aae7aSTrond Myklebust 
5730b4aae7aSTrond Myklebust 	nfs3_free_createdata(data);
5744f390c15SChuck Lever out:
5751da177e4SLinus Torvalds 	dprintk("NFS reply symlink: %d\n", status);
5761da177e4SLinus Torvalds 	return status;
5771da177e4SLinus Torvalds }
5781da177e4SLinus Torvalds 
5791da177e4SLinus Torvalds static int
5801da177e4SLinus Torvalds nfs3_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr)
5811da177e4SLinus Torvalds {
582013cdf10SChristoph Hellwig 	struct posix_acl *default_acl, *acl;
5830b4aae7aSTrond Myklebust 	struct nfs3_createdata *data;
58417fd6e45SBenjamin Coddington 	struct dentry *d_alias;
5850b4aae7aSTrond Myklebust 	int status = -ENOMEM;
5861da177e4SLinus Torvalds 
5876de1472fSAl Viro 	dprintk("NFS call  mkdir %pd\n", dentry);
588055ffbeaSAndreas Gruenbacher 
5890b4aae7aSTrond Myklebust 	data = nfs3_alloc_createdata();
5900b4aae7aSTrond Myklebust 	if (data == NULL)
5910b4aae7aSTrond Myklebust 		goto out;
5920b4aae7aSTrond Myklebust 
593013cdf10SChristoph Hellwig 	status = posix_acl_create(dir, &sattr->ia_mode, &default_acl, &acl);
594013cdf10SChristoph Hellwig 	if (status)
595013cdf10SChristoph Hellwig 		goto out;
596013cdf10SChristoph Hellwig 
5970b4aae7aSTrond Myklebust 	data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_MKDIR];
5980b4aae7aSTrond Myklebust 	data->arg.mkdir.fh = NFS_FH(dir);
5990b4aae7aSTrond Myklebust 	data->arg.mkdir.name = dentry->d_name.name;
6000b4aae7aSTrond Myklebust 	data->arg.mkdir.len = dentry->d_name.len;
6010b4aae7aSTrond Myklebust 	data->arg.mkdir.sattr = sattr;
6020b4aae7aSTrond Myklebust 
60317fd6e45SBenjamin Coddington 	d_alias = nfs3_do_create(dir, dentry, data);
60417fd6e45SBenjamin Coddington 	status = PTR_ERR_OR_ZERO(d_alias);
60517fd6e45SBenjamin Coddington 
606055ffbeaSAndreas Gruenbacher 	if (status != 0)
607013cdf10SChristoph Hellwig 		goto out_release_acls;
6080b4aae7aSTrond Myklebust 
60917fd6e45SBenjamin Coddington 	if (d_alias)
61017fd6e45SBenjamin Coddington 		dentry = d_alias;
61117fd6e45SBenjamin Coddington 
6122b0143b5SDavid Howells 	status = nfs3_proc_setacls(d_inode(dentry), acl, default_acl);
613013cdf10SChristoph Hellwig 
61417fd6e45SBenjamin Coddington 	dput(d_alias);
615013cdf10SChristoph Hellwig out_release_acls:
616013cdf10SChristoph Hellwig 	posix_acl_release(acl);
617013cdf10SChristoph Hellwig 	posix_acl_release(default_acl);
618055ffbeaSAndreas Gruenbacher out:
6190b4aae7aSTrond Myklebust 	nfs3_free_createdata(data);
6201da177e4SLinus Torvalds 	dprintk("NFS reply mkdir: %d\n", status);
6211da177e4SLinus Torvalds 	return status;
6221da177e4SLinus Torvalds }
6231da177e4SLinus Torvalds 
6241da177e4SLinus Torvalds static int
625beffb8feSAl Viro nfs3_proc_rmdir(struct inode *dir, const struct qstr *name)
6261da177e4SLinus Torvalds {
62739967ddfSTrond Myklebust 	struct nfs_fattr	*dir_attr;
6281da177e4SLinus Torvalds 	struct nfs3_diropargs	arg = {
6291da177e4SLinus Torvalds 		.fh		= NFS_FH(dir),
6301da177e4SLinus Torvalds 		.name		= name->name,
6311da177e4SLinus Torvalds 		.len		= name->len
6321da177e4SLinus Torvalds 	};
633dead28daSChuck Lever 	struct rpc_message msg = {
634dead28daSChuck Lever 		.rpc_proc	= &nfs3_procedures[NFS3PROC_RMDIR],
635dead28daSChuck Lever 		.rpc_argp	= &arg,
636dead28daSChuck Lever 	};
63739967ddfSTrond Myklebust 	int status = -ENOMEM;
6381da177e4SLinus Torvalds 
6391da177e4SLinus Torvalds 	dprintk("NFS call  rmdir %s\n", name->name);
64039967ddfSTrond Myklebust 	dir_attr = nfs_alloc_fattr();
64139967ddfSTrond Myklebust 	if (dir_attr == NULL)
64239967ddfSTrond Myklebust 		goto out;
64339967ddfSTrond Myklebust 
64439967ddfSTrond Myklebust 	msg.rpc_resp = dir_attr;
645dead28daSChuck Lever 	status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
64639967ddfSTrond Myklebust 	nfs_post_op_update_inode(dir, dir_attr);
64739967ddfSTrond Myklebust 	nfs_free_fattr(dir_attr);
64839967ddfSTrond Myklebust out:
6491da177e4SLinus Torvalds 	dprintk("NFS reply rmdir: %d\n", status);
6501da177e4SLinus Torvalds 	return status;
6511da177e4SLinus Torvalds }
6521da177e4SLinus Torvalds 
6531da177e4SLinus Torvalds /*
6541da177e4SLinus Torvalds  * The READDIR implementation is somewhat hackish - we pass the user buffer
6551da177e4SLinus Torvalds  * to the encode function, which installs it in the receive iovec.
6561da177e4SLinus Torvalds  * The decode function itself doesn't perform any decoding, it just makes
6571da177e4SLinus Torvalds  * sure the reply is syntactically correct.
6581da177e4SLinus Torvalds  *
6591da177e4SLinus Torvalds  * Also note that this implementation handles both plain readdir and
6601da177e4SLinus Torvalds  * readdirplus.
6611da177e4SLinus Torvalds  */
66282e22a5eSTrond Myklebust static int nfs3_proc_readdir(struct nfs_readdir_arg *nr_arg,
66382e22a5eSTrond Myklebust 			     struct nfs_readdir_res *nr_res)
6641da177e4SLinus Torvalds {
66582e22a5eSTrond Myklebust 	struct inode		*dir = d_inode(nr_arg->dentry);
6661da177e4SLinus Torvalds 	struct nfs3_readdirargs	arg = {
6671da177e4SLinus Torvalds 		.fh		= NFS_FH(dir),
66882e22a5eSTrond Myklebust 		.cookie		= nr_arg->cookie,
66982e22a5eSTrond Myklebust 		.plus		= nr_arg->plus,
67082e22a5eSTrond Myklebust 		.count		= nr_arg->page_len,
67182e22a5eSTrond Myklebust 		.pages		= nr_arg->pages
6721da177e4SLinus Torvalds 	};
6731da177e4SLinus Torvalds 	struct nfs3_readdirres	res = {
67482e22a5eSTrond Myklebust 		.verf		= nr_res->verf,
67582e22a5eSTrond Myklebust 		.plus		= nr_arg->plus,
6761da177e4SLinus Torvalds 	};
6771da177e4SLinus Torvalds 	struct rpc_message	msg = {
6781da177e4SLinus Torvalds 		.rpc_proc	= &nfs3_procedures[NFS3PROC_READDIR],
6791da177e4SLinus Torvalds 		.rpc_argp	= &arg,
6801da177e4SLinus Torvalds 		.rpc_resp	= &res,
68182e22a5eSTrond Myklebust 		.rpc_cred	= nr_arg->cred,
6821da177e4SLinus Torvalds 	};
683aa49b4cfSTrond Myklebust 	int status = -ENOMEM;
6841da177e4SLinus Torvalds 
68582e22a5eSTrond Myklebust 	if (nr_arg->plus)
6861da177e4SLinus Torvalds 		msg.rpc_proc = &nfs3_procedures[NFS3PROC_READDIRPLUS];
68782e22a5eSTrond Myklebust 	if (arg.cookie)
68882e22a5eSTrond Myklebust 		memcpy(arg.verf, nr_arg->verf, sizeof(arg.verf));
6891da177e4SLinus Torvalds 
69082e22a5eSTrond Myklebust 	dprintk("NFS call  readdir%s %llu\n", nr_arg->plus ? "plus" : "",
69182e22a5eSTrond Myklebust 		(unsigned long long)nr_arg->cookie);
6921da177e4SLinus Torvalds 
693aa49b4cfSTrond Myklebust 	res.dir_attr = nfs_alloc_fattr();
694aa49b4cfSTrond Myklebust 	if (res.dir_attr == NULL)
695aa49b4cfSTrond Myklebust 		goto out;
696aa49b4cfSTrond Myklebust 
6971da177e4SLinus Torvalds 	status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
698c4812998STrond Myklebust 
699c4812998STrond Myklebust 	nfs_invalidate_atime(dir);
700aa49b4cfSTrond Myklebust 	nfs_refresh_inode(dir, res.dir_attr);
701c4812998STrond Myklebust 
702aa49b4cfSTrond Myklebust 	nfs_free_fattr(res.dir_attr);
703aa49b4cfSTrond Myklebust out:
70482e22a5eSTrond Myklebust 	dprintk("NFS reply readdir%s: %d\n", nr_arg->plus ? "plus" : "",
70582e22a5eSTrond Myklebust 		status);
7061da177e4SLinus Torvalds 	return status;
7071da177e4SLinus Torvalds }
7081da177e4SLinus Torvalds 
7091da177e4SLinus Torvalds static int
7101da177e4SLinus Torvalds nfs3_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
7111da177e4SLinus Torvalds 		dev_t rdev)
7121da177e4SLinus Torvalds {
713013cdf10SChristoph Hellwig 	struct posix_acl *default_acl, *acl;
7140b4aae7aSTrond Myklebust 	struct nfs3_createdata *data;
71517fd6e45SBenjamin Coddington 	struct dentry *d_alias;
7160b4aae7aSTrond Myklebust 	int status = -ENOMEM;
7171da177e4SLinus Torvalds 
7186de1472fSAl Viro 	dprintk("NFS call  mknod %pd %u:%u\n", dentry,
7191da177e4SLinus Torvalds 			MAJOR(rdev), MINOR(rdev));
720055ffbeaSAndreas Gruenbacher 
7210b4aae7aSTrond Myklebust 	data = nfs3_alloc_createdata();
7220b4aae7aSTrond Myklebust 	if (data == NULL)
723055ffbeaSAndreas Gruenbacher 		goto out;
7240b4aae7aSTrond Myklebust 
725013cdf10SChristoph Hellwig 	status = posix_acl_create(dir, &sattr->ia_mode, &default_acl, &acl);
726013cdf10SChristoph Hellwig 	if (status)
727013cdf10SChristoph Hellwig 		goto out;
728013cdf10SChristoph Hellwig 
7290b4aae7aSTrond Myklebust 	data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_MKNOD];
7300b4aae7aSTrond Myklebust 	data->arg.mknod.fh = NFS_FH(dir);
7310b4aae7aSTrond Myklebust 	data->arg.mknod.name = dentry->d_name.name;
7320b4aae7aSTrond Myklebust 	data->arg.mknod.len = dentry->d_name.len;
7330b4aae7aSTrond Myklebust 	data->arg.mknod.sattr = sattr;
7340b4aae7aSTrond Myklebust 	data->arg.mknod.rdev = rdev;
7350b4aae7aSTrond Myklebust 
7360b4aae7aSTrond Myklebust 	switch (sattr->ia_mode & S_IFMT) {
7370b4aae7aSTrond Myklebust 	case S_IFBLK:
7380b4aae7aSTrond Myklebust 		data->arg.mknod.type = NF3BLK;
7390b4aae7aSTrond Myklebust 		break;
7400b4aae7aSTrond Myklebust 	case S_IFCHR:
7410b4aae7aSTrond Myklebust 		data->arg.mknod.type = NF3CHR;
7420b4aae7aSTrond Myklebust 		break;
7430b4aae7aSTrond Myklebust 	case S_IFIFO:
7440b4aae7aSTrond Myklebust 		data->arg.mknod.type = NF3FIFO;
7450b4aae7aSTrond Myklebust 		break;
7460b4aae7aSTrond Myklebust 	case S_IFSOCK:
7470b4aae7aSTrond Myklebust 		data->arg.mknod.type = NF3SOCK;
7480b4aae7aSTrond Myklebust 		break;
7490b4aae7aSTrond Myklebust 	default:
7500b4aae7aSTrond Myklebust 		status = -EINVAL;
7511fcb6fcdSGao Xiang 		goto out_release_acls;
7520b4aae7aSTrond Myklebust 	}
7530b4aae7aSTrond Myklebust 
75417fd6e45SBenjamin Coddington 	d_alias = nfs3_do_create(dir, dentry, data);
75517fd6e45SBenjamin Coddington 	status = PTR_ERR_OR_ZERO(d_alias);
756055ffbeaSAndreas Gruenbacher 	if (status != 0)
757013cdf10SChristoph Hellwig 		goto out_release_acls;
758013cdf10SChristoph Hellwig 
75917fd6e45SBenjamin Coddington 	if (d_alias)
76017fd6e45SBenjamin Coddington 		dentry = d_alias;
76117fd6e45SBenjamin Coddington 
7622b0143b5SDavid Howells 	status = nfs3_proc_setacls(d_inode(dentry), acl, default_acl);
763013cdf10SChristoph Hellwig 
76417fd6e45SBenjamin Coddington 	dput(d_alias);
765013cdf10SChristoph Hellwig out_release_acls:
766013cdf10SChristoph Hellwig 	posix_acl_release(acl);
767013cdf10SChristoph Hellwig 	posix_acl_release(default_acl);
768055ffbeaSAndreas Gruenbacher out:
7690b4aae7aSTrond Myklebust 	nfs3_free_createdata(data);
7701da177e4SLinus Torvalds 	dprintk("NFS reply mknod: %d\n", status);
7711da177e4SLinus Torvalds 	return status;
7721da177e4SLinus Torvalds }
7731da177e4SLinus Torvalds 
7741da177e4SLinus Torvalds static int
7751da177e4SLinus Torvalds nfs3_proc_statfs(struct nfs_server *server, struct nfs_fh *fhandle,
7761da177e4SLinus Torvalds 		 struct nfs_fsstat *stat)
7771da177e4SLinus Torvalds {
778dead28daSChuck Lever 	struct rpc_message msg = {
779dead28daSChuck Lever 		.rpc_proc	= &nfs3_procedures[NFS3PROC_FSSTAT],
780dead28daSChuck Lever 		.rpc_argp	= fhandle,
781dead28daSChuck Lever 		.rpc_resp	= stat,
782dead28daSChuck Lever 	};
7831da177e4SLinus Torvalds 	int	status;
7841da177e4SLinus Torvalds 
7851da177e4SLinus Torvalds 	dprintk("NFS call  fsstat\n");
7860e574af1STrond Myklebust 	nfs_fattr_init(stat->fattr);
787dead28daSChuck Lever 	status = rpc_call_sync(server->client, &msg, 0);
788d141d974SChuck Lever 	dprintk("NFS reply fsstat: %d\n", status);
7891da177e4SLinus Torvalds 	return status;
7901da177e4SLinus Torvalds }
7911da177e4SLinus Torvalds 
7921da177e4SLinus Torvalds static int
79337ca8f5cSEG Keizer do_proc_fsinfo(struct rpc_clnt *client, struct nfs_fh *fhandle,
7941da177e4SLinus Torvalds 		 struct nfs_fsinfo *info)
7951da177e4SLinus Torvalds {
796dead28daSChuck Lever 	struct rpc_message msg = {
797dead28daSChuck Lever 		.rpc_proc	= &nfs3_procedures[NFS3PROC_FSINFO],
798dead28daSChuck Lever 		.rpc_argp	= fhandle,
799dead28daSChuck Lever 		.rpc_resp	= info,
800dead28daSChuck Lever 	};
8011da177e4SLinus Torvalds 	int	status;
8021da177e4SLinus Torvalds 
8031da177e4SLinus Torvalds 	dprintk("NFS call  fsinfo\n");
8040e574af1STrond Myklebust 	nfs_fattr_init(info->fattr);
80537ca8f5cSEG Keizer 	status = rpc_call_sync(client, &msg, 0);
8061da177e4SLinus Torvalds 	dprintk("NFS reply fsinfo: %d\n", status);
8071da177e4SLinus Torvalds 	return status;
8081da177e4SLinus Torvalds }
8091da177e4SLinus Torvalds 
81037ca8f5cSEG Keizer /*
81137ca8f5cSEG Keizer  * Bare-bones access to fsinfo: this is for nfs_get_root/nfs_get_sb via
81237ca8f5cSEG Keizer  * nfs_create_server
81337ca8f5cSEG Keizer  */
81437ca8f5cSEG Keizer static int
81537ca8f5cSEG Keizer nfs3_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle,
81637ca8f5cSEG Keizer 		   struct nfs_fsinfo *info)
81737ca8f5cSEG Keizer {
81837ca8f5cSEG Keizer 	int	status;
81937ca8f5cSEG Keizer 
82037ca8f5cSEG Keizer 	status = do_proc_fsinfo(server->client, fhandle, info);
82137ca8f5cSEG Keizer 	if (status && server->nfs_client->cl_rpcclient != server->client)
82237ca8f5cSEG Keizer 		status = do_proc_fsinfo(server->nfs_client->cl_rpcclient, fhandle, info);
82337ca8f5cSEG Keizer 	return status;
82437ca8f5cSEG Keizer }
82537ca8f5cSEG Keizer 
8261da177e4SLinus Torvalds static int
8271da177e4SLinus Torvalds nfs3_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle,
8281da177e4SLinus Torvalds 		   struct nfs_pathconf *info)
8291da177e4SLinus Torvalds {
830dead28daSChuck Lever 	struct rpc_message msg = {
831dead28daSChuck Lever 		.rpc_proc	= &nfs3_procedures[NFS3PROC_PATHCONF],
832dead28daSChuck Lever 		.rpc_argp	= fhandle,
833dead28daSChuck Lever 		.rpc_resp	= info,
834dead28daSChuck Lever 	};
8351da177e4SLinus Torvalds 	int	status;
8361da177e4SLinus Torvalds 
8371da177e4SLinus Torvalds 	dprintk("NFS call  pathconf\n");
8380e574af1STrond Myklebust 	nfs_fattr_init(info->fattr);
839dead28daSChuck Lever 	status = rpc_call_sync(server->client, &msg, 0);
8401da177e4SLinus Torvalds 	dprintk("NFS reply pathconf: %d\n", status);
8411da177e4SLinus Torvalds 	return status;
8421da177e4SLinus Torvalds }
8431da177e4SLinus Torvalds 
844d45f60c6SWeston Andros Adamson static int nfs3_read_done(struct rpc_task *task, struct nfs_pgio_header *hdr)
8451da177e4SLinus Torvalds {
846d45f60c6SWeston Andros Adamson 	struct inode *inode = hdr->inode;
8478d8928d8STrond Myklebust 	struct nfs_server *server = NFS_SERVER(inode);
848cd841605SFred Isaman 
84916cecdf6STrond Myklebust 	if (hdr->pgio_done_cb != NULL)
85016cecdf6STrond Myklebust 		return hdr->pgio_done_cb(task, hdr);
85116cecdf6STrond Myklebust 
852cd841605SFred Isaman 	if (nfs3_async_handle_jukebox(task, inode))
853ec06c096STrond Myklebust 		return -EAGAIN;
8548850df99STrond Myklebust 
8558d8928d8STrond Myklebust 	if (task->tk_status >= 0 && !server->read_hdrsize)
8568d8928d8STrond Myklebust 		cmpxchg(&server->read_hdrsize, 0, hdr->res.replen);
8578d8928d8STrond Myklebust 
858cd841605SFred Isaman 	nfs_invalidate_atime(inode);
859d45f60c6SWeston Andros Adamson 	nfs_refresh_inode(inode, &hdr->fattr);
860ec06c096STrond Myklebust 	return 0;
8611da177e4SLinus Torvalds }
8621da177e4SLinus Torvalds 
863d45f60c6SWeston Andros Adamson static void nfs3_proc_read_setup(struct nfs_pgio_header *hdr,
864d45f60c6SWeston Andros Adamson 				 struct rpc_message *msg)
8651da177e4SLinus Torvalds {
866bdc7f021STrond Myklebust 	msg->rpc_proc = &nfs3_procedures[NFS3PROC_READ];
8678d8928d8STrond Myklebust 	hdr->args.replen = NFS_SERVER(hdr->inode)->read_hdrsize;
8681da177e4SLinus Torvalds }
8691da177e4SLinus Torvalds 
870d45f60c6SWeston Andros Adamson static int nfs3_proc_pgio_rpc_prepare(struct rpc_task *task,
871d45f60c6SWeston Andros Adamson 				      struct nfs_pgio_header *hdr)
872ea7c3303SBryan Schumaker {
873ea7c3303SBryan Schumaker 	rpc_call_start(task);
874ef1820f9SNeilBrown 	return 0;
875ea7c3303SBryan Schumaker }
876ea7c3303SBryan Schumaker 
877d45f60c6SWeston Andros Adamson static int nfs3_write_done(struct rpc_task *task, struct nfs_pgio_header *hdr)
8781da177e4SLinus Torvalds {
879d45f60c6SWeston Andros Adamson 	struct inode *inode = hdr->inode;
880cd841605SFred Isaman 
88116cecdf6STrond Myklebust 	if (hdr->pgio_done_cb != NULL)
88216cecdf6STrond Myklebust 		return hdr->pgio_done_cb(task, hdr);
88316cecdf6STrond Myklebust 
884cd841605SFred Isaman 	if (nfs3_async_handle_jukebox(task, inode))
885788e7a89STrond Myklebust 		return -EAGAIN;
8861da177e4SLinus Torvalds 	if (task->tk_status >= 0)
887a08a8cd3STrond Myklebust 		nfs_writeback_update_inode(hdr);
888788e7a89STrond Myklebust 	return 0;
8891da177e4SLinus Torvalds }
8901da177e4SLinus Torvalds 
891d45f60c6SWeston Andros Adamson static void nfs3_proc_write_setup(struct nfs_pgio_header *hdr,
892fb91fb0eSAnna Schumaker 				  struct rpc_message *msg,
893fb91fb0eSAnna Schumaker 				  struct rpc_clnt **clnt)
8941da177e4SLinus Torvalds {
895bdc7f021STrond Myklebust 	msg->rpc_proc = &nfs3_procedures[NFS3PROC_WRITE];
8961da177e4SLinus Torvalds }
8971da177e4SLinus Torvalds 
8980b7c0153SFred Isaman static void nfs3_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data)
8990b7c0153SFred Isaman {
9000b7c0153SFred Isaman 	rpc_call_start(task);
9010b7c0153SFred Isaman }
9020b7c0153SFred Isaman 
9030b7c0153SFred Isaman static int nfs3_commit_done(struct rpc_task *task, struct nfs_commit_data *data)
9041da177e4SLinus Torvalds {
90516cecdf6STrond Myklebust 	if (data->commit_done_cb != NULL)
90616cecdf6STrond Myklebust 		return data->commit_done_cb(task, data);
90716cecdf6STrond Myklebust 
908006ea73eSChuck Lever 	if (nfs3_async_handle_jukebox(task, data->inode))
909788e7a89STrond Myklebust 		return -EAGAIN;
9109e08a3c5STrond Myklebust 	nfs_refresh_inode(data->inode, data->res.fattr);
911788e7a89STrond Myklebust 	return 0;
9121da177e4SLinus Torvalds }
9131da177e4SLinus Torvalds 
914e9ae1ee2SAnna Schumaker static void nfs3_proc_commit_setup(struct nfs_commit_data *data, struct rpc_message *msg,
915e9ae1ee2SAnna Schumaker 				   struct rpc_clnt **clnt)
9161da177e4SLinus Torvalds {
917bdc7f021STrond Myklebust 	msg->rpc_proc = &nfs3_procedures[NFS3PROC_COMMIT];
9181da177e4SLinus Torvalds }
9191da177e4SLinus Torvalds 
920bb3393d5STrond Myklebust static void nfs3_nlm_alloc_call(void *data)
921f30cb757SBenjamin Coddington {
922f30cb757SBenjamin Coddington 	struct nfs_lock_context *l_ctx = data;
923f30cb757SBenjamin Coddington 	if (l_ctx && test_bit(NFS_CONTEXT_UNLOCK, &l_ctx->open_context->flags)) {
924f30cb757SBenjamin Coddington 		get_nfs_open_context(l_ctx->open_context);
925f30cb757SBenjamin Coddington 		nfs_get_lock_context(l_ctx->open_context);
926f30cb757SBenjamin Coddington 	}
927f30cb757SBenjamin Coddington }
928f30cb757SBenjamin Coddington 
929bb3393d5STrond Myklebust static bool nfs3_nlm_unlock_prepare(struct rpc_task *task, void *data)
930f30cb757SBenjamin Coddington {
931f30cb757SBenjamin Coddington 	struct nfs_lock_context *l_ctx = data;
932f30cb757SBenjamin Coddington 	if (l_ctx && test_bit(NFS_CONTEXT_UNLOCK, &l_ctx->open_context->flags))
933f30cb757SBenjamin Coddington 		return nfs_async_iocounter_wait(task, l_ctx);
934f30cb757SBenjamin Coddington 	return false;
935f30cb757SBenjamin Coddington 
936f30cb757SBenjamin Coddington }
937f30cb757SBenjamin Coddington 
938bb3393d5STrond Myklebust static void nfs3_nlm_release_call(void *data)
939f30cb757SBenjamin Coddington {
940f30cb757SBenjamin Coddington 	struct nfs_lock_context *l_ctx = data;
941f30cb757SBenjamin Coddington 	struct nfs_open_context *ctx;
942f30cb757SBenjamin Coddington 	if (l_ctx && test_bit(NFS_CONTEXT_UNLOCK, &l_ctx->open_context->flags)) {
943f30cb757SBenjamin Coddington 		ctx = l_ctx->open_context;
944f30cb757SBenjamin Coddington 		nfs_put_lock_context(l_ctx);
945f30cb757SBenjamin Coddington 		put_nfs_open_context(ctx);
946f30cb757SBenjamin Coddington 	}
947f30cb757SBenjamin Coddington }
948f30cb757SBenjamin Coddington 
9491b720406SColin Ian King static const struct nlmclnt_operations nlmclnt_fl_close_lock_ops = {
950f30cb757SBenjamin Coddington 	.nlmclnt_alloc_call = nfs3_nlm_alloc_call,
951f30cb757SBenjamin Coddington 	.nlmclnt_unlock_prepare = nfs3_nlm_unlock_prepare,
952f30cb757SBenjamin Coddington 	.nlmclnt_release_call = nfs3_nlm_release_call,
953f30cb757SBenjamin Coddington };
954f30cb757SBenjamin Coddington 
9551da177e4SLinus Torvalds static int
9561da177e4SLinus Torvalds nfs3_proc_lock(struct file *filp, int cmd, struct file_lock *fl)
9571da177e4SLinus Torvalds {
958496ad9aaSAl Viro 	struct inode *inode = file_inode(filp);
959f30cb757SBenjamin Coddington 	struct nfs_lock_context *l_ctx = NULL;
960f30cb757SBenjamin Coddington 	struct nfs_open_context *ctx = nfs_file_open_context(filp);
961f30cb757SBenjamin Coddington 	int status;
9621093a60eSChuck Lever 
963f30cb757SBenjamin Coddington 	if (fl->fl_flags & FL_CLOSE) {
964f30cb757SBenjamin Coddington 		l_ctx = nfs_get_lock_context(ctx);
965f30cb757SBenjamin Coddington 		if (IS_ERR(l_ctx))
966f30cb757SBenjamin Coddington 			l_ctx = NULL;
967f30cb757SBenjamin Coddington 		else
968f30cb757SBenjamin Coddington 			set_bit(NFS_CONTEXT_UNLOCK, &ctx->flags);
969f30cb757SBenjamin Coddington 	}
970f30cb757SBenjamin Coddington 
971f30cb757SBenjamin Coddington 	status = nlmclnt_proc(NFS_SERVER(inode)->nlm_host, cmd, fl, l_ctx);
972f30cb757SBenjamin Coddington 
973f30cb757SBenjamin Coddington 	if (l_ctx)
974f30cb757SBenjamin Coddington 		nfs_put_lock_context(l_ctx);
975f30cb757SBenjamin Coddington 
976f30cb757SBenjamin Coddington 	return status;
9771da177e4SLinus Torvalds }
9781da177e4SLinus Torvalds 
979011e2a7fSBryan Schumaker static int nfs3_have_delegation(struct inode *inode, fmode_t flags)
980011e2a7fSBryan Schumaker {
981011e2a7fSBryan Schumaker 	return 0;
982011e2a7fSBryan Schumaker }
983011e2a7fSBryan Schumaker 
984ab96291eSBryan Schumaker static const struct inode_operations nfs3_dir_inode_operations = {
985ab96291eSBryan Schumaker 	.create		= nfs_create,
986ab96291eSBryan Schumaker 	.lookup		= nfs_lookup,
987ab96291eSBryan Schumaker 	.link		= nfs_link,
988ab96291eSBryan Schumaker 	.unlink		= nfs_unlink,
989ab96291eSBryan Schumaker 	.symlink	= nfs_symlink,
990ab96291eSBryan Schumaker 	.mkdir		= nfs_mkdir,
991ab96291eSBryan Schumaker 	.rmdir		= nfs_rmdir,
992ab96291eSBryan Schumaker 	.mknod		= nfs_mknod,
993ab96291eSBryan Schumaker 	.rename		= nfs_rename,
994ab96291eSBryan Schumaker 	.permission	= nfs_permission,
995ab96291eSBryan Schumaker 	.getattr	= nfs_getattr,
996ab96291eSBryan Schumaker 	.setattr	= nfs_setattr,
9975f13ee9cSChristoph Hellwig #ifdef CONFIG_NFS_V3_ACL
99874adf83fSChristoph Hellwig 	.listxattr	= nfs3_listxattr,
999013cdf10SChristoph Hellwig 	.get_acl	= nfs3_get_acl,
1000013cdf10SChristoph Hellwig 	.set_acl	= nfs3_set_acl,
1001013cdf10SChristoph Hellwig #endif
1002ab96291eSBryan Schumaker };
1003ab96291eSBryan Schumaker 
1004ab96291eSBryan Schumaker static const struct inode_operations nfs3_file_inode_operations = {
1005ab96291eSBryan Schumaker 	.permission	= nfs_permission,
1006ab96291eSBryan Schumaker 	.getattr	= nfs_getattr,
1007ab96291eSBryan Schumaker 	.setattr	= nfs_setattr,
10085f13ee9cSChristoph Hellwig #ifdef CONFIG_NFS_V3_ACL
100974adf83fSChristoph Hellwig 	.listxattr	= nfs3_listxattr,
1010013cdf10SChristoph Hellwig 	.get_acl	= nfs3_get_acl,
1011013cdf10SChristoph Hellwig 	.set_acl	= nfs3_set_acl,
1012013cdf10SChristoph Hellwig #endif
1013ab96291eSBryan Schumaker };
1014ab96291eSBryan Schumaker 
1015509de811SDavid Howells const struct nfs_rpc_ops nfs_v3_clientops = {
10161da177e4SLinus Torvalds 	.version	= 3,			/* protocol version */
10171da177e4SLinus Torvalds 	.dentry_ops	= &nfs_dentry_operations,
1018b7fa0554SAndreas Gruenbacher 	.dir_inode_ops	= &nfs3_dir_inode_operations,
1019b7fa0554SAndreas Gruenbacher 	.file_inode_ops	= &nfs3_file_inode_operations,
10201788ea6eSJeff Layton 	.file_ops	= &nfs_file_operations,
1021f30cb757SBenjamin Coddington 	.nlmclnt_ops	= &nlmclnt_fl_close_lock_ops,
10221da177e4SLinus Torvalds 	.getroot	= nfs3_proc_get_root,
1023281cad46SBryan Schumaker 	.submount	= nfs_submount,
1024f2aedb71SDavid Howells 	.try_get_tree	= nfs_try_get_tree,
10251da177e4SLinus Torvalds 	.getattr	= nfs3_proc_getattr,
10261da177e4SLinus Torvalds 	.setattr	= nfs3_proc_setattr,
10271da177e4SLinus Torvalds 	.lookup		= nfs3_proc_lookup,
10283c5e9a59STrond Myklebust 	.lookupp	= nfs3_proc_lookupp,
10291da177e4SLinus Torvalds 	.access		= nfs3_proc_access,
10301da177e4SLinus Torvalds 	.readlink	= nfs3_proc_readlink,
10311da177e4SLinus Torvalds 	.create		= nfs3_proc_create,
10321da177e4SLinus Torvalds 	.remove		= nfs3_proc_remove,
10331da177e4SLinus Torvalds 	.unlink_setup	= nfs3_proc_unlink_setup,
103434e137ccSBryan Schumaker 	.unlink_rpc_prepare = nfs3_proc_unlink_rpc_prepare,
10351da177e4SLinus Torvalds 	.unlink_done	= nfs3_proc_unlink_done,
1036d3d4152aSJeff Layton 	.rename_setup	= nfs3_proc_rename_setup,
1037c6bfa1a1SBryan Schumaker 	.rename_rpc_prepare = nfs3_proc_rename_rpc_prepare,
1038d3d4152aSJeff Layton 	.rename_done	= nfs3_proc_rename_done,
10391da177e4SLinus Torvalds 	.link		= nfs3_proc_link,
10401da177e4SLinus Torvalds 	.symlink	= nfs3_proc_symlink,
10411da177e4SLinus Torvalds 	.mkdir		= nfs3_proc_mkdir,
10421da177e4SLinus Torvalds 	.rmdir		= nfs3_proc_rmdir,
10431da177e4SLinus Torvalds 	.readdir	= nfs3_proc_readdir,
10441da177e4SLinus Torvalds 	.mknod		= nfs3_proc_mknod,
10451da177e4SLinus Torvalds 	.statfs		= nfs3_proc_statfs,
10461da177e4SLinus Torvalds 	.fsinfo		= nfs3_proc_fsinfo,
10471da177e4SLinus Torvalds 	.pathconf	= nfs3_proc_pathconf,
10481da177e4SLinus Torvalds 	.decode_dirent	= nfs3_decode_dirent,
1049a4cdda59SAnna Schumaker 	.pgio_rpc_prepare = nfs3_proc_pgio_rpc_prepare,
10501da177e4SLinus Torvalds 	.read_setup	= nfs3_proc_read_setup,
1051ec06c096STrond Myklebust 	.read_done	= nfs3_read_done,
10521da177e4SLinus Torvalds 	.write_setup	= nfs3_proc_write_setup,
1053788e7a89STrond Myklebust 	.write_done	= nfs3_write_done,
10541da177e4SLinus Torvalds 	.commit_setup	= nfs3_proc_commit_setup,
10550b7c0153SFred Isaman 	.commit_rpc_prepare = nfs3_proc_commit_rpc_prepare,
1056788e7a89STrond Myklebust 	.commit_done	= nfs3_commit_done,
10571da177e4SLinus Torvalds 	.lock		= nfs3_proc_lock,
1058013cdf10SChristoph Hellwig 	.clear_acl_cache = forget_all_cached_acls,
10597fe5c398STrond Myklebust 	.close_context	= nfs_close_context,
1060011e2a7fSBryan Schumaker 	.have_delegation = nfs3_have_delegation,
10616663ee7fSBryan Schumaker 	.alloc_client	= nfs_alloc_client,
106245a52a02SAndy Adamson 	.init_client	= nfs_init_client,
1063cdb7ecedSBryan Schumaker 	.free_client	= nfs_free_client,
10641179acc6SBryan Schumaker 	.create_server	= nfs3_create_server,
10651179acc6SBryan Schumaker 	.clone_server	= nfs3_clone_server,
10661da177e4SLinus Torvalds };
1067