diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1997-04-29 21:13:14 +0000 |
---|---|---|
committer | <ralf@linux-mips.org> | 1997-04-29 21:13:14 +0000 |
commit | 19c9bba94152148523ba0f7ef7cffe3d45656b11 (patch) | |
tree | 40b1cb534496a7f1ca0f5c314a523c69f1fee464 /include/linux/lockd | |
parent | 7206675c40394c78a90e74812bbdbf8cf3cca1be (diff) |
Import of Linux/MIPS 2.1.36
Diffstat (limited to 'include/linux/lockd')
-rw-r--r-- | include/linux/lockd/bind.h | 43 | ||||
-rw-r--r-- | include/linux/lockd/debug.h | 51 | ||||
-rw-r--r-- | include/linux/lockd/lockd.h | 196 | ||||
-rw-r--r-- | include/linux/lockd/nlm.h | 52 | ||||
-rw-r--r-- | include/linux/lockd/share.h | 30 | ||||
-rw-r--r-- | include/linux/lockd/sm_inter.h | 45 | ||||
-rw-r--r-- | include/linux/lockd/xdr.h | 86 |
7 files changed, 503 insertions, 0 deletions
diff --git a/include/linux/lockd/bind.h b/include/linux/lockd/bind.h new file mode 100644 index 000000000..4e0aebedb --- /dev/null +++ b/include/linux/lockd/bind.h @@ -0,0 +1,43 @@ +/* + * linux/include/linux/lockd/bind.h + * + * This is the part of lockd visible to nfsd and the nfs client. + * + * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de> + */ + +#ifndef LINUX_LOCKD_BIND_H +#define LINUX_LOCKD_BIND_H + +#include <linux/lockd/nlm.h> + +/* Dummy declarations */ +struct svc_rqst; +struct knfs_fh; +struct svc_client; /* opaque type */ + +/* + * This is the set of functions for lockd->nfsd communication + */ +struct nlmsvc_binding { + void (*exp_readlock)(void); + void (*exp_unlock)(void); + struct svc_client * (*exp_getclient)(struct sockaddr_in *); + u32 (*fopen)(struct svc_rqst *, + struct knfs_fh *, + struct file *); + void (*fclose)(struct file *); + void (*detach)(void); +}; + +extern struct nlmsvc_binding * nlmsvc_ops; + +/* + * Functions exported by the lockd module + */ +extern void nlmsvc_invalidate_client(struct svc_client *clnt); +extern int nlmclnt_proc(struct inode *, int, struct file_lock *); +extern int lockd_up(void); +extern void lockd_down(void); + +#endif /* LINUX_LOCKD_BIND_H */ diff --git a/include/linux/lockd/debug.h b/include/linux/lockd/debug.h new file mode 100644 index 000000000..2a2f97a1f --- /dev/null +++ b/include/linux/lockd/debug.h @@ -0,0 +1,51 @@ +/* + * linux/include/linux/lockd/debug.h + * + * Debugging stuff. + * + * Copyright (C) 1996 Olaf Kirch <okir@monad.swb.de> + */ + +#ifndef LINUX_LOCKD_DEBUG_H +#define LINUX_LOCKD_DEBUG_H + +#ifdef __KERNEL__ + +#include <linux/sunrpc/debug.h> + +/* + * Enable lockd debugging. + * Requires RPC_DEBUG. + */ +#ifdef RPC_DEBUG +# define LOCKD_DEBUG 1 +#endif + +#undef ifdebug +#if defined(RPC_DEBUG) && defined(LOCKD_DEBUG) +# define ifdebug(flag) if (nlm_debug & NLMDBG_##flag) +#else +# define ifdebug(flag) if (0) +#endif + +#ifdef LOCKD_DEBUG +char * nlm_procname(u32); +#endif + +#endif /* __KERNEL__ */ + +/* + * Debug flags + */ +#define NLMDBG_SVC 0x0001 +#define NLMDBG_CLIENT 0x0002 +#define NLMDBG_CLNTLOCK 0x0004 +#define NLMDBG_SVCLOCK 0x0008 +#define NLMDBG_MONITOR 0x0010 +#define NLMDBG_CLNTSUBS 0x0020 +#define NLMDBG_SVCSUBS 0x0040 +#define NLMDBG_HOSTCACHE 0x0080 +#define NLMDBG_ALL 0x7fff + + +#endif /* LINUX_LOCKD_DEBUG_H */ diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h new file mode 100644 index 000000000..72035cc5c --- /dev/null +++ b/include/linux/lockd/lockd.h @@ -0,0 +1,196 @@ +/* + * linux/include/linux/lockd/lockd.h + * + * General-purpose lockd include file. + * + * Copyright (C) 1996 Olaf Kirch <okir@monad.swb.de> + */ + +#ifndef LINUX_LOCKD_LOCKD_H +#define LINUX_LOCKD_LOCKD_H + +#ifdef __KERNEL__ + +#include <linux/in.h> +#include <linux/fs.h> +#include <linux/utsname.h> +#include <linux/nfsd/nfsfh.h> +#include <linux/lockd/bind.h> +#include <linux/lockd/xdr.h> +#include <linux/lockd/debug.h> + +/* + * Version string + */ +#define LOCKD_VERSION "0.4" + +/* + * Default timeout for RPC calls (seconds) + */ +#define LOCKD_DFLT_TIMEO 10 + +/* + * Lockd host handle (used both by the client and server personality). + */ +struct nlm_host { + struct nlm_host * h_next; /* linked list (hash table) */ + struct sockaddr_in h_addr; /* peer address */ + struct svc_client * h_exportent; /* NFS client */ + struct rpc_clnt * h_rpcclnt; /* RPC client to talk to peer */ + char h_name[20]; /* remote hostname */ + u32 h_version; /* interface version */ + unsigned short h_proto; /* transport proto */ + unsigned short h_authflavor; /* RPC authentication type */ + unsigned short h_reclaiming : 1, + h_inuse : 1, + h_monitored : 1; + struct wait_queue * h_gracewait; /* wait while reclaiming */ + u32 h_state; /* pseudo-state counter */ + u32 h_nsmstate; /* true remote NSM state */ + unsigned int h_count; /* reference count */ + struct semaphore h_sema; /* mutex for pmap binding */ + unsigned long h_nextrebind; /* next portmap call */ + unsigned long h_expires; /* eligible for GC */ +}; + +/* + * Memory chunk for NLM client RPC request. + */ +#define NLMCLNT_OHSIZE (sizeof(system_utsname.nodename)+10) +struct nlm_rqst { + unsigned int a_flags; /* initial RPC task flags */ + struct nlm_host * a_host; /* host handle */ + struct nlm_args a_args; /* arguments */ + struct nlm_res a_res; /* result */ + char a_owner[NLMCLNT_OHSIZE]; +}; + +/* + * This struct describes a file held open by lockd on behalf of + * an NFS client. + */ +struct nlm_file { + struct nlm_file * f_next; /* linked list */ + struct knfs_fh f_handle; /* NFS file handle */ + struct file f_file; /* VFS file pointer */ + struct nlm_share * f_shares; /* DOS shares */ + struct nlm_block * f_blocks; /* blocked locks */ + unsigned int f_locks; /* guesstimate # of locks */ + unsigned int f_count; /* reference count */ + struct semaphore f_sema; /* avoid concurrent access */ +}; + +/* + * This is a server block (i.e. a lock requested by some client which + * couldn't be granted because of a conflicting lock). + */ +#define NLM_NEVER (~(unsigned long) 0) +struct nlm_block { + struct nlm_block * b_next; /* linked list (all blocks) */ + struct nlm_block * b_fnext; /* linked list (per file) */ + struct nlm_rqst b_call; /* RPC args & callback info */ + struct svc_serv * b_daemon; /* NLM service */ + struct nlm_host * b_host; /* host handle for RPC clnt */ + unsigned long b_when; /* next re-xmit */ + unsigned int b_id; /* block id */ + unsigned char b_queued; /* re-queued */ + unsigned char b_granted; /* VFS granted lock */ + unsigned char b_incall; /* doing callback */ + unsigned char b_done; /* callback complete */ + struct nlm_file * b_file; /* file in question */ +}; + +/* + * Valid actions for nlmsvc_traverse_files + */ +#define NLM_ACT_CHECK 0 /* check for locks */ +#define NLM_ACT_MARK 1 /* mark & sweep */ +#define NLM_ACT_UNLOCK 2 /* release all locks */ + +/* + * Global variables + */ +extern struct rpc_program nlm_program; +extern struct svc_procedure nlmsvc_procedures[]; +extern unsigned long nlmsvc_grace_period; +extern unsigned long nlmsvc_timeout; + +/* + * Lockd client functions + */ +struct nlm_rqst * nlmclnt_alloc_call(void); +int nlmclnt_call(struct nlm_rqst *, u32); +int nlmclnt_async_call(struct nlm_rqst *, u32, rpc_action); +int nlmclnt_block(struct nlm_host *, struct file_lock *, u32 *); +int nlmclnt_cancel(struct nlm_host *, struct file_lock *); +u32 nlmclnt_grant(struct nlm_lock *); +void nlmclnt_recovery(struct nlm_host *, u32); +int nlmclnt_reclaim(struct nlm_host *, struct file_lock *); +int nlmclnt_setgrantargs(struct nlm_rqst *, struct nlm_lock *); +void nlmclnt_freegrantargs(struct nlm_rqst *); + +/* + * Host cache + */ +struct nlm_host * nlmclnt_lookup_host(struct sockaddr_in *, int, int); +struct nlm_host * nlmsvc_lookup_host(struct svc_rqst *); +struct nlm_host * nlm_lookup_host(struct svc_client *, + struct sockaddr_in *, int, int); +struct rpc_clnt * nlm_bind_host(struct nlm_host *); +void nlm_rebind_host(struct nlm_host *); +void nlm_release_host(struct nlm_host *); +void nlm_shutdown_hosts(void); + +/* + * Server-side lock handling + */ +u32 nlmsvc_lock(struct svc_rqst *, struct nlm_file *, + struct nlm_lock *, int, u32); +u32 nlmsvc_unlock(struct nlm_file *, struct nlm_lock *); +u32 nlmsvc_testlock(struct nlm_file *, struct nlm_lock *, + struct nlm_lock *); +u32 nlmsvc_cancel_blocked(struct nlm_file *, struct nlm_lock *); +unsigned long nlmsvc_retry_blocked(void); +int nlmsvc_traverse_blocks(struct nlm_host *, struct nlm_file *, + int action); + +/* + * File handling for the server personality + */ +u32 nlm_lookup_file(struct svc_rqst *, struct nlm_file **, + struct nfs_fh *); +void nlm_release_file(struct nlm_file *); +void nlmsvc_mark_resources(void); +void nlmsvc_free_host_resources(struct nlm_host *); + +extern __inline__ struct inode * +nlmsvc_file_inode(struct nlm_file *file) +{ + return file->f_file.f_inode; +} + +/* + * Compare two host addresses (needs modifying for ipv6) + */ +extern __inline__ int +nlm_cmp_addr(struct sockaddr_in *sin1, struct sockaddr_in *sin2) +{ + return sin1->sin_addr.s_addr == sin2->sin_addr.s_addr; +} + +/* + * Compare two NLM locks. + * When the second lock is of type F_UNLCK, this acts like a wildcard. + */ +extern __inline__ int +nlm_compare_locks(struct file_lock *fl1, struct file_lock *fl2) +{ + return fl1->fl_pid == fl2->fl_pid + && fl1->fl_start == fl2->fl_start + && fl1->fl_end == fl2->fl_end + &&(fl1->fl_type == fl2->fl_type || fl2->fl_type == F_UNLCK); +} + +#endif /* __KERNEL__ */ + +#endif /* LINUX_LOCKD_LOCKD_H */ diff --git a/include/linux/lockd/nlm.h b/include/linux/lockd/nlm.h new file mode 100644 index 000000000..ca606fca2 --- /dev/null +++ b/include/linux/lockd/nlm.h @@ -0,0 +1,52 @@ +/* + * linux/include/linux/lockd/nlm.h + * + * Declarations for the Network Lock Manager protocol. + * + * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de> + */ + +#ifndef LINUX_LOCKD_NLM_H +#define LINUX_LOCKD_NLM_H + +/* Maximum file offset in file_lock.fl_end */ +#ifdef OFFSET_MAX +# define NLM_OFFSET_MAX OFFSET_MAX +#else +# define NLM_OFFSET_MAX ((off_t) 0x7fffffff) +#endif + +/* Return states for NLM */ +enum { + NLM_LCK_GRANTED = 0, + NLM_LCK_DENIED, + NLM_LCK_DENIED_NOLOCKS, + NLM_LCK_BLOCKED, + NLM_LCK_DENIED_GRACE_PERIOD, +}; + +#define NLM_PROGRAM 100021 + +#define NLMPROC_NULL 0 +#define NLMPROC_TEST 1 +#define NLMPROC_LOCK 2 +#define NLMPROC_CANCEL 3 +#define NLMPROC_UNLOCK 4 +#define NLMPROC_GRANTED 5 +#define NLMPROC_TEST_MSG 6 +#define NLMPROC_LOCK_MSG 7 +#define NLMPROC_CANCEL_MSG 8 +#define NLMPROC_UNLOCK_MSG 9 +#define NLMPROC_GRANTED_MSG 10 +#define NLMPROC_TEST_RES 11 +#define NLMPROC_LOCK_RES 12 +#define NLMPROC_CANCEL_RES 13 +#define NLMPROC_UNLOCK_RES 14 +#define NLMPROC_GRANTED_RES 15 +#define NLMPROC_SHARE 20 +#define NLMPROC_UNSHARE 21 +#define NLMPROC_NM_LOCK 22 +#define NLMPROC_FREE_ALL 23 +#define NLMPROC_NSM_NOTIFY 24 /* statd callback */ + +#endif /* LINUX_LOCKD_NLM_H */ diff --git a/include/linux/lockd/share.h b/include/linux/lockd/share.h new file mode 100644 index 000000000..5d8aa325f --- /dev/null +++ b/include/linux/lockd/share.h @@ -0,0 +1,30 @@ +/* + * linux/include/linux/lockd/share.h + * + * DOS share management for lockd. + * + * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de> + */ + +#ifndef LINUX_LOCKD_SHARE_H +#define LINUX_LOCKD_SHARE_H + +/* + * DOS share for a specific file + */ +struct nlm_share { + struct nlm_share * s_next; /* linked list */ + struct nlm_host * s_host; /* client host */ + struct nlm_file * s_file; /* shared file */ + struct xdr_netobj s_owner; /* owner handle */ + u32 s_access; /* access mode */ + u32 s_mode; /* deny mode */ +}; + +u32 nlmsvc_share_file(struct nlm_host *, struct nlm_file *, + struct nlm_args *); +u32 nlmsvc_unshare_file(struct nlm_host *, struct nlm_file *, + struct nlm_args *); +int nlmsvc_traverse_shares(struct nlm_host *, struct nlm_file *, int); + +#endif /* LINUX_LOCKD_SHARE_H */ diff --git a/include/linux/lockd/sm_inter.h b/include/linux/lockd/sm_inter.h new file mode 100644 index 000000000..d93b07466 --- /dev/null +++ b/include/linux/lockd/sm_inter.h @@ -0,0 +1,45 @@ +/* + * linux/include/linux/lockd/sm_inter.h + * + * Declarations for the kernel statd client. + * + * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de> + */ + +#ifndef LINUX_LOCKD_SM_INTER_H +#define LINUX_LOCKD_SM_INTER_H + +#define SM_PROGRAM 100024 +#define SM_VERSION 1 +#define SM_STAT 1 +#define SM_MON 2 +#define SM_UNMON 3 +#define SM_UNMON_ALL 4 +#define SM_SIMU_CRASH 5 +#define SM_NOTIFY 6 + +#define SM_MAXSTRLEN 1024 + +/* + * Arguments for all calls to statd + */ +struct nsm_args { + u32 addr; /* remote address */ + u32 prog; /* RPC callback info */ + u32 vers; + u32 proc; +}; + +/* + * Result returned by statd + */ +struct nsm_res { + u32 status; + u32 state; +}; + +int nsm_monitor(struct nlm_host *); +int nsm_unmonitor(struct nlm_host *); +extern u32 nsm_local_state; + +#endif /* LINUX_LOCKD_SM_INTER_H */ diff --git a/include/linux/lockd/xdr.h b/include/linux/lockd/xdr.h new file mode 100644 index 000000000..631a8fba8 --- /dev/null +++ b/include/linux/lockd/xdr.h @@ -0,0 +1,86 @@ +/* + * linux/include/linux/lockd/xdr.h + * + * XDR types for the NLM protocol + * + * Copyright (C) 1996 Olaf Kirch <okir@monad.swb.de> + */ + +#ifndef LOCKD_XDR_H +#define LOCKD_XDR_H + +#include <linux/fs.h> +#include <linux/nfs.h> +#include <linux/sunrpc/xdr.h> + +extern u32 nlm_granted, nlm_lck_denied, nlm_lck_denied_nolocks, + nlm_lck_blocked, nlm_lck_denied_grace_period; + +/* Lock info passed via NLM */ +struct nlm_lock { + char * caller; + struct nfs_fh fh; + struct xdr_netobj oh; + struct file_lock fl; +}; + +/* + * Generic lockd arguments for all but sm_notify + */ +struct nlm_args { + u32 cookie; + struct nlm_lock lock; + u32 block; + u32 reclaim; + u32 state; + u32 monitor; + u32 fsm_access; + u32 fsm_mode; +}; + +/* + * Generic lockd result + */ +struct nlm_res { + u32 cookie; + u32 status; + struct nlm_lock lock; +}; + +/* + * statd callback when client has rebooted + */ +struct nlm_reboot { + char * mon; + int len; + u32 state; + u32 addr; +}; + +/* + * Contents of statd callback when monitored host rebooted + */ +#define NLMSVC_XDRSIZE sizeof(struct nlm_args) + +void nlmxdr_init(void); +int nlmsvc_decode_testargs(struct svc_rqst *, u32 *, struct nlm_args *); +int nlmsvc_encode_testres(struct svc_rqst *, u32 *, struct nlm_res *); +int nlmsvc_decode_lockargs(struct svc_rqst *, u32 *, struct nlm_args *); +int nlmsvc_decode_cancargs(struct svc_rqst *, u32 *, struct nlm_args *); +int nlmsvc_decode_unlockargs(struct svc_rqst *, u32 *, struct nlm_args *); +int nlmsvc_encode_res(struct svc_rqst *, u32 *, struct nlm_res *); +int nlmsvc_decode_res(struct svc_rqst *, u32 *, struct nlm_res *); +int nlmsvc_encode_void(struct svc_rqst *, u32 *, void *); +int nlmsvc_decode_void(struct svc_rqst *, u32 *, void *); +int nlmsvc_decode_shareargs(struct svc_rqst *, u32 *, struct nlm_args *); +int nlmsvc_encode_shareres(struct svc_rqst *, u32 *, struct nlm_res *); +int nlmsvc_decode_notify(struct svc_rqst *, u32 *, struct nlm_args *); +int nlmsvc_decode_reboot(struct svc_rqst *, u32 *, struct nlm_reboot *); +/* +int nlmclt_encode_testargs(struct rpc_rqst *, u32 *, struct nlm_args *); +int nlmclt_encode_lockargs(struct rpc_rqst *, u32 *, struct nlm_args *); +int nlmclt_encode_cancargs(struct rpc_rqst *, u32 *, struct nlm_args *); +int nlmclt_encode_unlockargs(struct rpc_rqst *, u32 *, struct nlm_args *); + */ + +#endif /* LOCKD_XDR_H */ |