Linux-2.6.12-rc2

Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.

Let it rip!
This commit is contained in:
Linus Torvalds
2005-04-16 15:20:36 -07:00
commit 1da177e4c3
17291 changed files with 6718755 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
/*
* 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;
/*
* This is the set of functions for lockd->nfsd communication
*/
struct nlmsvc_binding {
u32 (*fopen)(struct svc_rqst *,
struct nfs_fh *,
struct file **);
void (*fclose)(struct file *);
};
extern struct nlmsvc_binding * nlmsvc_ops;
/*
* Functions exported by the lockd module
*/
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 */

View File

@@ -0,0 +1,57 @@
/*
* 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 (unlikely(nlm_debug & NLMDBG_##flag))
#else
# define ifdebug(flag) if (0)
#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_XDR 0x0100
#define NLMDBG_ALL 0x7fff
/*
* Support for printing NLM cookies in dprintk()
*/
#ifdef RPC_DEBUG
struct nlm_cookie;
/* Call this function with the BKL held (it uses a static buffer) */
extern const char *nlmdbg_cookie2a(const struct nlm_cookie *);
#endif
#endif /* LINUX_LOCKD_DEBUG_H */

224
include/linux/lockd/lockd.h Normal file
View File

@@ -0,0 +1,224 @@
/*
* 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/config.h>
#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>
#ifdef CONFIG_LOCKD_V4
#include <linux/lockd/xdr4.h>
#endif
#include <linux/lockd/debug.h>
/*
* Version string
*/
#define LOCKD_VERSION "0.5"
/*
* 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 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_reclaiming : 1,
h_server : 1, /* server side, not client side */
h_inuse : 1,
h_killed : 1,
h_monitored : 1;
wait_queue_head_t h_gracewait; /* wait while reclaiming */
u32 h_state; /* pseudo-state counter */
u32 h_nsmstate; /* true remote NSM state */
u32 h_pidcount; /* Pseudopids */
atomic_t 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 */
struct list_head h_lockowners; /* Lockowners for the client */
spinlock_t h_lock;
};
/*
* Map an fl_owner_t into a unique 32-bit "pid"
*/
struct nlm_lockowner {
struct list_head list;
atomic_t count;
struct nlm_host *host;
fl_owner_t owner;
uint32_t pid;
};
/*
* 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 nfs_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 */
int f_hash; /* hash of f_handle */
};
/*
* 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[];
#ifdef CONFIG_LOCKD_V4
extern struct svc_procedure nlmsvc_procedures4[];
#endif
extern int nlmsvc_grace_period;
extern unsigned long nlmsvc_timeout;
/*
* Lockd client functions
*/
struct nlm_rqst * nlmclnt_alloc_call(void);
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(int server, struct sockaddr_in *, int, int);
struct rpc_clnt * nlm_bind_host(struct nlm_host *);
void nlm_rebind_host(struct nlm_host *);
struct nlm_host * nlm_get_host(struct nlm_host *);
void nlm_release_host(struct nlm_host *);
void nlm_shutdown_hosts(void);
extern struct nlm_host *nlm_find_client(void);
/*
* Server-side lock handling
*/
int nlmsvc_async_call(struct nlm_rqst *, u32, rpc_action);
u32 nlmsvc_lock(struct svc_rqst *, struct nlm_file *,
struct nlm_lock *, int, struct nlm_cookie *);
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);
void nlmsvc_grant_reply(struct svc_rqst *, struct nlm_cookie *, u32);
/*
* 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 *);
void nlmsvc_invalidate_all(void);
static __inline__ struct inode *
nlmsvc_file_inode(struct nlm_file *file)
{
return file->f_file->f_dentry->d_inode;
}
/*
* Compare two host addresses (needs modifying for ipv6)
*/
static __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.
*/
static __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);
}
extern struct lock_manager_operations nlmsvc_lock_operations;
#endif /* __KERNEL__ */
#endif /* LINUX_LOCKD_LOCKD_H */

58
include/linux/lockd/nlm.h Normal file
View File

@@ -0,0 +1,58 @@
/*
* 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
#include <linux/config.h>
/* Maximum file offset in file_lock.fl_end */
# define NLM_OFFSET_MAX ((s32) 0x7fffffff)
# define NLM4_OFFSET_MAX ((s64) ((~(u64)0) >> 1))
/* Return states for NLM */
enum {
NLM_LCK_GRANTED = 0,
NLM_LCK_DENIED = 1,
NLM_LCK_DENIED_NOLOCKS = 2,
NLM_LCK_BLOCKED = 3,
NLM_LCK_DENIED_GRACE_PERIOD = 4,
#ifdef CONFIG_LOCKD_V4
NLM_DEADLCK = 5,
NLM_ROFS = 6,
NLM_STALE_FH = 7,
NLM_FBIG = 8,
NLM_FAILED = 9,
#endif
};
#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_NSM_NOTIFY 16 /* statd callback */
#define NLMPROC_SHARE 20
#define NLMPROC_UNSHARE 21
#define NLMPROC_NM_LOCK 22
#define NLMPROC_FREE_ALL 23
#endif /* LINUX_LOCKD_NLM_H */

View File

@@ -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 */

View File

@@ -0,0 +1,46 @@
/*
* 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;
u32 proto; /* protocol (udp/tcp) plus server/client flag */
};
/*
* 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 */

108
include/linux/lockd/xdr.h Normal file
View File

@@ -0,0 +1,108 @@
/*
* 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>
#define NLM_MAXCOOKIELEN 32
#define NLM_MAXSTRLEN 1024
#define nlm_granted __constant_htonl(NLM_LCK_GRANTED)
#define nlm_lck_denied __constant_htonl(NLM_LCK_DENIED)
#define nlm_lck_denied_nolocks __constant_htonl(NLM_LCK_DENIED_NOLOCKS)
#define nlm_lck_blocked __constant_htonl(NLM_LCK_BLOCKED)
#define nlm_lck_denied_grace_period __constant_htonl(NLM_LCK_DENIED_GRACE_PERIOD)
/* Lock info passed via NLM */
struct nlm_lock {
char * caller;
int len; /* length of "caller" */
struct nfs_fh fh;
struct xdr_netobj oh;
struct file_lock fl;
};
/*
* NLM cookies. Technically they can be 1K, but Linux only uses 8 bytes.
* FreeBSD uses 16, Apple Mac OS X 10.3 uses 20. Therefore we set it to
* 32 bytes.
*/
struct nlm_cookie
{
unsigned char data[NLM_MAXCOOKIELEN];
unsigned int len;
};
/*
* Generic lockd arguments for all but sm_notify
*/
struct nlm_args {
struct nlm_cookie cookie;
struct nlm_lock lock;
u32 block;
u32 reclaim;
u32 state;
u32 monitor;
u32 fsm_access;
u32 fsm_mode;
};
typedef struct nlm_args nlm_args;
/*
* Generic lockd result
*/
struct nlm_res {
struct nlm_cookie cookie;
u32 status;
struct nlm_lock lock;
};
/*
* statd callback when client has rebooted
*/
struct nlm_reboot {
char * mon;
int len;
u32 state;
u32 addr;
u32 vers;
u32 proto;
};
/*
* Contents of statd callback when monitored host rebooted
*/
#define NLMSVC_XDRSIZE sizeof(struct nlm_args)
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 */

View File

@@ -0,0 +1,46 @@
/*
* linux/include/linux/lockd/xdr.h
*
* XDR types for the NLM protocol
*
* Copyright (C) 1996 Olaf Kirch <okir@monad.swb.de>
*/
#ifndef LOCKD_XDR4_H
#define LOCKD_XDR4_H
#include <linux/fs.h>
#include <linux/nfs.h>
#include <linux/sunrpc/xdr.h>
#include <linux/lockd/xdr.h>
/* error codes new to NLMv4 */
#define nlm4_deadlock __constant_htonl(NLM_DEADLCK)
#define nlm4_rofs __constant_htonl(NLM_ROFS)
#define nlm4_stale_fh __constant_htonl(NLM_STALE_FH)
#define nlm4_fbig __constant_htonl(NLM_FBIG)
#define nlm4_failed __constant_htonl(NLM_FAILED)
int nlm4svc_decode_testargs(struct svc_rqst *, u32 *, struct nlm_args *);
int nlm4svc_encode_testres(struct svc_rqst *, u32 *, struct nlm_res *);
int nlm4svc_decode_lockargs(struct svc_rqst *, u32 *, struct nlm_args *);
int nlm4svc_decode_cancargs(struct svc_rqst *, u32 *, struct nlm_args *);
int nlm4svc_decode_unlockargs(struct svc_rqst *, u32 *, struct nlm_args *);
int nlm4svc_encode_res(struct svc_rqst *, u32 *, struct nlm_res *);
int nlm4svc_decode_res(struct svc_rqst *, u32 *, struct nlm_res *);
int nlm4svc_encode_void(struct svc_rqst *, u32 *, void *);
int nlm4svc_decode_void(struct svc_rqst *, u32 *, void *);
int nlm4svc_decode_shareargs(struct svc_rqst *, u32 *, struct nlm_args *);
int nlm4svc_encode_shareres(struct svc_rqst *, u32 *, struct nlm_res *);
int nlm4svc_decode_notify(struct svc_rqst *, u32 *, struct nlm_args *);
int nlm4svc_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_XDR4_H */