blob: 0520c0cd73f42ef33c67c97fbad3ca277be67f48 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * linux/include/linux/lockd/bind.h
4 *
5 * This is the part of lockd visible to nfsd and the nfs client.
6 *
7 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
8 */
9
10#ifndef LINUX_LOCKD_BIND_H
11#define LINUX_LOCKD_BIND_H
12
13#include <linux/lockd/nlm.h>
NeilBrownd343fce2006-10-17 00:10:18 -070014/* need xdr-encoded error codes too, so... */
15#include <linux/lockd/xdr.h>
16#ifdef CONFIG_LOCKD_V4
17#include <linux/lockd/xdr4.h>
18#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
20/* Dummy declarations */
21struct svc_rqst;
Benjamin Coddingtonb1ece732017-04-11 12:50:11 -040022struct rpc_task;
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
24/*
25 * This is the set of functions for lockd->nfsd communication
26 */
27struct nlmsvc_binding {
Al Viroe8c5c042006-12-13 00:35:03 -080028 __be32 (*fopen)(struct svc_rqst *,
Linus Torvalds1da177e2005-04-16 15:20:36 -070029 struct nfs_fh *,
30 struct file **);
31 void (*fclose)(struct file *);
32};
33
Julia Lawall2a297452015-12-23 22:25:13 +010034extern const struct nlmsvc_binding *nlmsvc_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
36/*
Chuck Lever883bb162008-01-15 16:04:20 -050037 * Similar to nfs_client_initdata, but without the NFS-specific
38 * rpc_ops field.
39 */
40struct nlmclnt_initdata {
41 const char *hostname;
42 const struct sockaddr *address;
43 size_t addrlen;
44 unsigned short protocol;
45 u32 nfs_version;
Chuck Lever0cb26592008-12-23 15:21:38 -050046 int noresvport;
Stanislav Kinsbursky66697bf2012-01-31 15:08:13 +040047 struct net *net;
Benjamin Coddingtonb1ece732017-04-11 12:50:11 -040048 const struct nlmclnt_operations *nlmclnt_ops;
Trond Myklebust40373b12019-04-09 12:13:39 -040049 const struct cred *cred;
Chuck Lever883bb162008-01-15 16:04:20 -050050};
51
52/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 * Functions exported by the lockd module
54 */
Chuck Lever883bb162008-01-15 16:04:20 -050055
56extern struct nlm_host *nlmclnt_init(const struct nlmclnt_initdata *nlm_init);
Chuck Lever52c40442008-01-11 17:09:44 -050057extern void nlmclnt_done(struct nlm_host *host);
58
Benjamin Coddingtonb1ece732017-04-11 12:50:11 -040059/*
60 * NLM client operations provide a means to modify RPC processing of NLM
61 * requests. Callbacks receive a pointer to data passed into the call to
62 * nlmclnt_proc().
63 */
64struct nlmclnt_operations {
65 /* Called on successful allocation of nlm_rqst, use for allocation or
66 * reference counting. */
67 void (*nlmclnt_alloc_call)(void *);
68
69 /* Called in rpc_task_prepare for unlock. A return value of true
70 * indicates the callback has put the task to sleep on a waitqueue
71 * and NLM should not call rpc_call_start(). */
72 bool (*nlmclnt_unlock_prepare)(struct rpc_task*, void *);
73
74 /* Called when the nlm_rqst is freed, callbacks should clean up here */
75 void (*nlmclnt_release_call)(void *);
76};
77
78extern int nlmclnt_proc(struct nlm_host *host, int cmd, struct file_lock *fl, void *data);
Trond Myklebust40373b12019-04-09 12:13:39 -040079extern int lockd_up(struct net *net, const struct cred *cred);
Stanislav Kinsburskye3f70ea2012-03-29 18:54:33 +040080extern void lockd_down(struct net *net);
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
Linus Torvalds1da177e2005-04-16 15:20:36 -070082#endif /* LINUX_LOCKD_BIND_H */