aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/nfs/callback.c1
-rw-r--r--fs/nfs/callback_proc.c1
-rw-r--r--fs/nfs/callback_xdr.c1
-rw-r--r--fs/nfs/delegation.c1
-rw-r--r--fs/nfs/dir.c1
-rw-r--r--fs/nfs/idmap.c1
-rw-r--r--fs/nfs/inode.c1
-rw-r--r--fs/nfs/nfs4_fs.h250
-rw-r--r--fs/nfs/nfs4proc.c5
-rw-r--r--fs/nfs/nfs4renewd.c1
-rw-r--r--fs/nfs/nfs4state.c12
-rw-r--r--fs/nfs/nfs4xdr.c8
12 files changed, 264 insertions, 19 deletions
diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
index 560d6175dd58..f2ca782aba33 100644
--- a/fs/nfs/callback.c
+++ b/fs/nfs/callback.c
@@ -14,6 +14,7 @@
14#include <linux/sunrpc/svc.h> 14#include <linux/sunrpc/svc.h>
15#include <linux/sunrpc/svcsock.h> 15#include <linux/sunrpc/svcsock.h>
16#include <linux/nfs_fs.h> 16#include <linux/nfs_fs.h>
17#include "nfs4_fs.h"
17#include "callback.h" 18#include "callback.h"
18 19
19#define NFSDBG_FACILITY NFSDBG_CALLBACK 20#define NFSDBG_FACILITY NFSDBG_CALLBACK
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index ece27e42b93b..65f1e19e4d19 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -8,6 +8,7 @@
8#include <linux/config.h> 8#include <linux/config.h>
9#include <linux/nfs4.h> 9#include <linux/nfs4.h>
10#include <linux/nfs_fs.h> 10#include <linux/nfs_fs.h>
11#include "nfs4_fs.h"
11#include "callback.h" 12#include "callback.h"
12#include "delegation.h" 13#include "delegation.h"
13 14
diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
index d271df9df2b2..c99677ec58f8 100644
--- a/fs/nfs/callback_xdr.c
+++ b/fs/nfs/callback_xdr.c
@@ -10,6 +10,7 @@
10#include <linux/sunrpc/svc.h> 10#include <linux/sunrpc/svc.h>
11#include <linux/nfs4.h> 11#include <linux/nfs4.h>
12#include <linux/nfs_fs.h> 12#include <linux/nfs_fs.h>
13#include "nfs4_fs.h"
13#include "callback.h" 14#include "callback.h"
14 15
15#define CB_OP_TAGLEN_MAXSZ (512) 16#define CB_OP_TAGLEN_MAXSZ (512)
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index 5b9c60f97791..d7f7eb669d03 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -16,6 +16,7 @@
16#include <linux/nfs_fs.h> 16#include <linux/nfs_fs.h>
17#include <linux/nfs_xdr.h> 17#include <linux/nfs_xdr.h>
18 18
19#include "nfs4_fs.h"
19#include "delegation.h" 20#include "delegation.h"
20 21
21static struct nfs_delegation *nfs_alloc_delegation(void) 22static struct nfs_delegation *nfs_alloc_delegation(void)
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index ff6155f5e8d9..9ccb15e86967 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -32,6 +32,7 @@
32#include <linux/smp_lock.h> 32#include <linux/smp_lock.h>
33#include <linux/namei.h> 33#include <linux/namei.h>
34 34
35#include "nfs4_fs.h"
35#include "delegation.h" 36#include "delegation.h"
36 37
37#define NFS_PARANOIA 1 38#define NFS_PARANOIA 1
diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c
index 87f4f9aeac86..ffb8df91dc34 100644
--- a/fs/nfs/idmap.c
+++ b/fs/nfs/idmap.c
@@ -50,6 +50,7 @@
50#include <linux/nfs_fs.h> 50#include <linux/nfs_fs.h>
51 51
52#include <linux/nfs_idmap.h> 52#include <linux/nfs_idmap.h>
53#include "nfs4_fs.h"
53 54
54#define IDMAP_HASH_SZ 128 55#define IDMAP_HASH_SZ 128
55 56
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 32ddcf69e9ac..c80a81ff59c6 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -39,6 +39,7 @@
39#include <asm/system.h> 39#include <asm/system.h>
40#include <asm/uaccess.h> 40#include <asm/uaccess.h>
41 41
42#include "nfs4_fs.h"
42#include "delegation.h" 43#include "delegation.h"
43 44
44#define NFSDBG_FACILITY NFSDBG_VFS 45#define NFSDBG_FACILITY NFSDBG_VFS
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
new file mode 100644
index 000000000000..85cf3bd36921
--- /dev/null
+++ b/fs/nfs/nfs4_fs.h
@@ -0,0 +1,250 @@
1/*
2 * linux/fs/nfs/nfs4_fs.h
3 *
4 * Copyright (C) 2005 Trond Myklebust
5 *
6 * NFSv4-specific filesystem definitions and declarations
7 */
8
9#ifndef __LINUX_FS_NFS_NFS4_FS_H
10#define __LINUX_FS_NFS_NFS4_FS_H
11
12#ifdef CONFIG_NFS_V4
13
14struct idmap;
15
16/*
17 * In a seqid-mutating op, this macro controls which error return
18 * values trigger incrementation of the seqid.
19 *
20 * from rfc 3010:
21 * The client MUST monotonically increment the sequence number for the
22 * CLOSE, LOCK, LOCKU, OPEN, OPEN_CONFIRM, and OPEN_DOWNGRADE
23 * operations. This is true even in the event that the previous
24 * operation that used the sequence number received an error. The only
25 * exception to this rule is if the previous operation received one of
26 * the following errors: NFSERR_STALE_CLIENTID, NFSERR_STALE_STATEID,
27 * NFSERR_BAD_STATEID, NFSERR_BAD_SEQID, NFSERR_BADXDR,
28 * NFSERR_RESOURCE, NFSERR_NOFILEHANDLE.
29 *
30 */
31#define seqid_mutating_err(err) \
32(((err) != NFSERR_STALE_CLIENTID) && \
33 ((err) != NFSERR_STALE_STATEID) && \
34 ((err) != NFSERR_BAD_STATEID) && \
35 ((err) != NFSERR_BAD_SEQID) && \
36 ((err) != NFSERR_BAD_XDR) && \
37 ((err) != NFSERR_RESOURCE) && \
38 ((err) != NFSERR_NOFILEHANDLE))
39
40enum nfs4_client_state {
41 NFS4CLNT_OK = 0,
42};
43
44/*
45 * The nfs4_client identifies our client state to the server.
46 */
47struct nfs4_client {
48 struct list_head cl_servers; /* Global list of servers */
49 struct in_addr cl_addr; /* Server identifier */
50 u64 cl_clientid; /* constant */
51 nfs4_verifier cl_confirm;
52 unsigned long cl_state;
53
54 u32 cl_lockowner_id;
55
56 /*
57 * The following rwsem ensures exclusive access to the server
58 * while we recover the state following a lease expiration.
59 */
60 struct rw_semaphore cl_sem;
61
62 struct list_head cl_delegations;
63 struct list_head cl_state_owners;
64 struct list_head cl_unused;
65 int cl_nunused;
66 spinlock_t cl_lock;
67 atomic_t cl_count;
68
69 struct rpc_clnt * cl_rpcclient;
70 struct rpc_cred * cl_cred;
71
72 struct list_head cl_superblocks; /* List of nfs_server structs */
73
74 unsigned long cl_lease_time;
75 unsigned long cl_last_renewal;
76 struct work_struct cl_renewd;
77 struct work_struct cl_recoverd;
78
79 wait_queue_head_t cl_waitq;
80 struct rpc_wait_queue cl_rpcwaitq;
81
82 /* used for the setclientid verifier */
83 struct timespec cl_boot_time;
84
85 /* idmapper */
86 struct idmap * cl_idmap;
87
88 /* Our own IP address, as a null-terminated string.
89 * This is used to generate the clientid, and the callback address.
90 */
91 char cl_ipaddr[16];
92 unsigned char cl_id_uniquifier;
93};
94
95/*
96 * NFS4 state_owners and lock_owners are simply labels for ordered
97 * sequences of RPC calls. Their sole purpose is to provide once-only
98 * semantics by allowing the server to identify replayed requests.
99 *
100 * The ->so_sema is held during all state_owner seqid-mutating operations:
101 * OPEN, OPEN_DOWNGRADE, and CLOSE. Its purpose is to properly serialize
102 * so_seqid.
103 */
104struct nfs4_state_owner {
105 struct list_head so_list; /* per-clientid list of state_owners */
106 struct nfs4_client *so_client;
107 u32 so_id; /* 32-bit identifier, unique */
108 struct semaphore so_sema;
109 u32 so_seqid; /* protected by so_sema */
110 atomic_t so_count;
111
112 struct rpc_cred *so_cred; /* Associated cred */
113 struct list_head so_states;
114 struct list_head so_delegations;
115};
116
117/*
118 * struct nfs4_state maintains the client-side state for a given
119 * (state_owner,inode) tuple (OPEN) or state_owner (LOCK).
120 *
121 * OPEN:
122 * In order to know when to OPEN_DOWNGRADE or CLOSE the state on the server,
123 * we need to know how many files are open for reading or writing on a
124 * given inode. This information too is stored here.
125 *
126 * LOCK: one nfs4_state (LOCK) to hold the lock stateid nfs4_state(OPEN)
127 */
128
129struct nfs4_lock_state {
130 struct list_head ls_locks; /* Other lock stateids */
131 fl_owner_t ls_owner; /* POSIX lock owner */
132#define NFS_LOCK_INITIALIZED 1
133 int ls_flags;
134 u32 ls_seqid;
135 u32 ls_id;
136 nfs4_stateid ls_stateid;
137 atomic_t ls_count;
138};
139
140/* bits for nfs4_state->flags */
141enum {
142 LK_STATE_IN_USE,
143 NFS_DELEGATED_STATE,
144};
145
146struct nfs4_state {
147 struct list_head open_states; /* List of states for the same state_owner */
148 struct list_head inode_states; /* List of states for the same inode */
149 struct list_head lock_states; /* List of subservient lock stateids */
150
151 struct nfs4_state_owner *owner; /* Pointer to the open owner */
152 struct inode *inode; /* Pointer to the inode */
153
154 unsigned long flags; /* Do we hold any locks? */
155 struct semaphore lock_sema; /* Serializes file locking operations */
156 rwlock_t state_lock; /* Protects the lock_states list */
157
158 nfs4_stateid stateid;
159
160 unsigned int nreaders;
161 unsigned int nwriters;
162 int state; /* State on the server (R,W, or RW) */
163 atomic_t count;
164};
165
166
167struct nfs4_exception {
168 long timeout;
169 int retry;
170};
171
172struct nfs4_state_recovery_ops {
173 int (*recover_open)(struct nfs4_state_owner *, struct nfs4_state *);
174 int (*recover_lock)(struct nfs4_state *, struct file_lock *);
175};
176
177extern struct dentry_operations nfs4_dentry_operations;
178extern struct inode_operations nfs4_dir_inode_operations;
179
180/* nfs4proc.c */
181extern int nfs4_map_errors(int err);
182extern int nfs4_proc_setclientid(struct nfs4_client *, u32, unsigned short);
183extern int nfs4_proc_setclientid_confirm(struct nfs4_client *);
184extern int nfs4_proc_async_renew(struct nfs4_client *);
185extern int nfs4_proc_renew(struct nfs4_client *);
186extern int nfs4_do_close(struct inode *inode, struct nfs4_state *state, mode_t mode);
187extern struct inode *nfs4_atomic_open(struct inode *, struct dentry *, struct nameidata *);
188extern int nfs4_open_revalidate(struct inode *, struct dentry *, int);
189
190extern struct nfs4_state_recovery_ops nfs4_reboot_recovery_ops;
191extern struct nfs4_state_recovery_ops nfs4_network_partition_recovery_ops;
192
193extern const u32 nfs4_fattr_bitmap[2];
194extern const u32 nfs4_statfs_bitmap[2];
195extern const u32 nfs4_pathconf_bitmap[2];
196extern const u32 nfs4_fsinfo_bitmap[2];
197
198/* nfs4renewd.c */
199extern void nfs4_schedule_state_renewal(struct nfs4_client *);
200extern void nfs4_renewd_prepare_shutdown(struct nfs_server *);
201extern void nfs4_kill_renewd(struct nfs4_client *);
202extern void nfs4_renew_state(void *);
203
204/* nfs4state.c */
205extern void init_nfsv4_state(struct nfs_server *);
206extern void destroy_nfsv4_state(struct nfs_server *);
207extern struct nfs4_client *nfs4_get_client(struct in_addr *);
208extern void nfs4_put_client(struct nfs4_client *clp);
209extern int nfs4_init_client(struct nfs4_client *clp);
210extern struct nfs4_client *nfs4_find_client(struct in_addr *);
211extern u32 nfs4_alloc_lockowner_id(struct nfs4_client *);
212
213extern struct nfs4_state_owner * nfs4_get_state_owner(struct nfs_server *, struct rpc_cred *);
214extern void nfs4_put_state_owner(struct nfs4_state_owner *);
215extern void nfs4_drop_state_owner(struct nfs4_state_owner *);
216extern struct nfs4_state * nfs4_get_open_state(struct inode *, struct nfs4_state_owner *);
217extern void nfs4_put_open_state(struct nfs4_state *);
218extern void nfs4_close_state(struct nfs4_state *, mode_t);
219extern struct nfs4_state *nfs4_find_state(struct inode *, struct rpc_cred *, mode_t mode);
220extern void nfs4_increment_seqid(int status, struct nfs4_state_owner *sp);
221extern void nfs4_schedule_state_recovery(struct nfs4_client *);
222extern struct nfs4_lock_state *nfs4_find_lock_state(struct nfs4_state *state, fl_owner_t);
223extern struct nfs4_lock_state *nfs4_get_lock_state(struct nfs4_state *state, fl_owner_t);
224extern void nfs4_put_lock_state(struct nfs4_lock_state *state);
225extern void nfs4_increment_lock_seqid(int status, struct nfs4_lock_state *ls);
226extern void nfs4_notify_setlk(struct nfs4_state *, struct file_lock *, struct nfs4_lock_state *);
227extern void nfs4_notify_unlck(struct nfs4_state *, struct file_lock *, struct nfs4_lock_state *);
228extern void nfs4_copy_stateid(nfs4_stateid *, struct nfs4_state *, fl_owner_t);
229
230extern const nfs4_stateid zero_stateid;
231
232/* nfs4xdr.c */
233extern uint32_t *nfs4_decode_dirent(uint32_t *p, struct nfs_entry *entry, int plus);
234extern struct rpc_procinfo nfs4_procedures[];
235
236struct nfs4_mount_data;
237
238/* callback_xdr.c */
239extern struct svc_version nfs4_callback_version1;
240
241#else
242
243#define init_nfsv4_state(server) do { } while (0)
244#define destroy_nfsv4_state(server) do { } while (0)
245#define nfs4_put_state_owner(inode, owner) do { } while (0)
246#define nfs4_put_open_state(state) do { } while (0)
247#define nfs4_close_state(a, b) do { } while (0)
248
249#endif /* CONFIG_NFS_V4 */
250#endif /* __LINUX_FS_NFS_NFS4_FS.H */
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 1d5cb3e80c3e..a69c02b206c1 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -48,6 +48,7 @@
48#include <linux/smp_lock.h> 48#include <linux/smp_lock.h>
49#include <linux/namei.h> 49#include <linux/namei.h>
50 50
51#include "nfs4_fs.h"
51#include "delegation.h" 52#include "delegation.h"
52 53
53#define NFSDBG_FACILITY NFSDBG_PROC 54#define NFSDBG_FACILITY NFSDBG_PROC
@@ -62,8 +63,6 @@ static int nfs4_handle_exception(struct nfs_server *server, int errorcode, struc
62extern u32 *nfs4_decode_dirent(u32 *p, struct nfs_entry *entry, int plus); 63extern u32 *nfs4_decode_dirent(u32 *p, struct nfs_entry *entry, int plus);
63extern struct rpc_procinfo nfs4_procedures[]; 64extern struct rpc_procinfo nfs4_procedures[];
64 65
65extern nfs4_stateid zero_stateid;
66
67/* Prevent leaks of NFSv4 errors into userland */ 66/* Prevent leaks of NFSv4 errors into userland */
68int nfs4_map_errors(int err) 67int nfs4_map_errors(int err)
69{ 68{
@@ -104,7 +103,7 @@ const u32 nfs4_statfs_bitmap[2] = {
104 | FATTR4_WORD1_SPACE_TOTAL 103 | FATTR4_WORD1_SPACE_TOTAL
105}; 104};
106 105
107u32 nfs4_pathconf_bitmap[2] = { 106const u32 nfs4_pathconf_bitmap[2] = {
108 FATTR4_WORD0_MAXLINK 107 FATTR4_WORD0_MAXLINK
109 | FATTR4_WORD0_MAXNAME, 108 | FATTR4_WORD0_MAXNAME,
110 0 109 0
diff --git a/fs/nfs/nfs4renewd.c b/fs/nfs/nfs4renewd.c
index 667e06f1c647..a3001628ad32 100644
--- a/fs/nfs/nfs4renewd.c
+++ b/fs/nfs/nfs4renewd.c
@@ -53,6 +53,7 @@
53#include <linux/nfs.h> 53#include <linux/nfs.h>
54#include <linux/nfs4.h> 54#include <linux/nfs4.h>
55#include <linux/nfs_fs.h> 55#include <linux/nfs_fs.h>
56#include "nfs4_fs.h"
56 57
57#define NFSDBG_FACILITY NFSDBG_PROC 58#define NFSDBG_FACILITY NFSDBG_PROC
58 59
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 231cebce3c87..17b187f2d776 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -46,24 +46,18 @@
46#include <linux/workqueue.h> 46#include <linux/workqueue.h>
47#include <linux/bitops.h> 47#include <linux/bitops.h>
48 48
49#include "nfs4_fs.h"
49#include "callback.h" 50#include "callback.h"
50#include "delegation.h" 51#include "delegation.h"
51 52
52#define OPENOWNER_POOL_SIZE 8 53#define OPENOWNER_POOL_SIZE 8
53 54
54static DEFINE_SPINLOCK(state_spinlock); 55const nfs4_stateid zero_stateid;
55
56nfs4_stateid zero_stateid;
57
58#if 0
59nfs4_stateid one_stateid =
60 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
61#endif
62 56
57static DEFINE_SPINLOCK(state_spinlock);
63static LIST_HEAD(nfs4_clientid_list); 58static LIST_HEAD(nfs4_clientid_list);
64 59
65static void nfs4_recover_state(void *); 60static void nfs4_recover_state(void *);
66extern void nfs4_renew_state(void *);
67 61
68void 62void
69init_nfsv4_state(struct nfs_server *server) 63init_nfsv4_state(struct nfs_server *server)
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 5f4de05763c9..e86406eff0eb 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -51,6 +51,7 @@
51#include <linux/nfs4.h> 51#include <linux/nfs4.h>
52#include <linux/nfs_fs.h> 52#include <linux/nfs_fs.h>
53#include <linux/nfs_idmap.h> 53#include <linux/nfs_idmap.h>
54#include "nfs4_fs.h"
54 55
55#define NFSDBG_FACILITY NFSDBG_XDR 56#define NFSDBG_FACILITY NFSDBG_XDR
56 57
@@ -660,8 +661,6 @@ static int encode_getattr_two(struct xdr_stream *xdr, uint32_t bm0, uint32_t bm1
660 661
661static int encode_getfattr(struct xdr_stream *xdr, const u32* bitmask) 662static int encode_getfattr(struct xdr_stream *xdr, const u32* bitmask)
662{ 663{
663 extern u32 nfs4_fattr_bitmap[];
664
665 return encode_getattr_two(xdr, 664 return encode_getattr_two(xdr,
666 bitmask[0] & nfs4_fattr_bitmap[0], 665 bitmask[0] & nfs4_fattr_bitmap[0],
667 bitmask[1] & nfs4_fattr_bitmap[1]); 666 bitmask[1] & nfs4_fattr_bitmap[1]);
@@ -669,8 +668,6 @@ static int encode_getfattr(struct xdr_stream *xdr, const u32* bitmask)
669 668
670static int encode_fsinfo(struct xdr_stream *xdr, const u32* bitmask) 669static int encode_fsinfo(struct xdr_stream *xdr, const u32* bitmask)
671{ 670{
672 extern u32 nfs4_fsinfo_bitmap[];
673
674 return encode_getattr_two(xdr, bitmask[0] & nfs4_fsinfo_bitmap[0], 671 return encode_getattr_two(xdr, bitmask[0] & nfs4_fsinfo_bitmap[0],
675 bitmask[1] & nfs4_fsinfo_bitmap[1]); 672 bitmask[1] & nfs4_fsinfo_bitmap[1]);
676} 673}
@@ -969,7 +966,6 @@ static int encode_putrootfh(struct xdr_stream *xdr)
969 966
970static void encode_stateid(struct xdr_stream *xdr, const struct nfs_open_context *ctx) 967static void encode_stateid(struct xdr_stream *xdr, const struct nfs_open_context *ctx)
971{ 968{
972 extern nfs4_stateid zero_stateid;
973 nfs4_stateid stateid; 969 nfs4_stateid stateid;
974 uint32_t *p; 970 uint32_t *p;
975 971
@@ -1697,7 +1693,6 @@ static int nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, uint32_t *p, struct nfs4_fs
1697 */ 1693 */
1698static int nfs4_xdr_enc_pathconf(struct rpc_rqst *req, uint32_t *p, const struct nfs4_pathconf_arg *args) 1694static int nfs4_xdr_enc_pathconf(struct rpc_rqst *req, uint32_t *p, const struct nfs4_pathconf_arg *args)
1699{ 1695{
1700 extern u32 nfs4_pathconf_bitmap[2];
1701 struct xdr_stream xdr; 1696 struct xdr_stream xdr;
1702 struct compound_hdr hdr = { 1697 struct compound_hdr hdr = {
1703 .nops = 2, 1698 .nops = 2,
@@ -1718,7 +1713,6 @@ static int nfs4_xdr_enc_pathconf(struct rpc_rqst *req, uint32_t *p, const struct
1718 */ 1713 */
1719static int nfs4_xdr_enc_statfs(struct rpc_rqst *req, uint32_t *p, const struct nfs4_statfs_arg *args) 1714static int nfs4_xdr_enc_statfs(struct rpc_rqst *req, uint32_t *p, const struct nfs4_statfs_arg *args)
1720{ 1715{
1721 extern u32 nfs4_statfs_bitmap[];
1722 struct xdr_stream xdr; 1716 struct xdr_stream xdr;
1723 struct compound_hdr hdr = { 1717 struct compound_hdr hdr = {
1724 .nops = 2, 1718 .nops = 2,