diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2005-06-22 13:16:21 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2005-06-22 16:07:06 -0400 |
commit | 4ce79717ce32a9f88c1ddce4b9658556cb59d37a (patch) | |
tree | 7f0c5e4bdbc2ee15b8e902b951d1be200b35411f /fs/nfs/nfs4_fs.h | |
parent | 9085bbcb76421a90bea28f4d3d03fa9977319c49 (diff) |
[PATCH] NFS: Header file cleanup...
- Move NFSv4 state definitions into a private header file.
- Clean up gunk in nfs_fs.h
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4_fs.h')
-rw-r--r-- | fs/nfs/nfs4_fs.h | 250 |
1 files changed, 250 insertions, 0 deletions
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 | |||
14 | struct 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 | |||
40 | enum nfs4_client_state { | ||
41 | NFS4CLNT_OK = 0, | ||
42 | }; | ||
43 | |||
44 | /* | ||
45 | * The nfs4_client identifies our client state to the server. | ||
46 | */ | ||
47 | struct 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 | */ | ||
104 | struct 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 | |||
129 | struct 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 */ | ||
141 | enum { | ||
142 | LK_STATE_IN_USE, | ||
143 | NFS_DELEGATED_STATE, | ||
144 | }; | ||
145 | |||
146 | struct 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 | |||
167 | struct nfs4_exception { | ||
168 | long timeout; | ||
169 | int retry; | ||
170 | }; | ||
171 | |||
172 | struct 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 | |||
177 | extern struct dentry_operations nfs4_dentry_operations; | ||
178 | extern struct inode_operations nfs4_dir_inode_operations; | ||
179 | |||
180 | /* nfs4proc.c */ | ||
181 | extern int nfs4_map_errors(int err); | ||
182 | extern int nfs4_proc_setclientid(struct nfs4_client *, u32, unsigned short); | ||
183 | extern int nfs4_proc_setclientid_confirm(struct nfs4_client *); | ||
184 | extern int nfs4_proc_async_renew(struct nfs4_client *); | ||
185 | extern int nfs4_proc_renew(struct nfs4_client *); | ||
186 | extern int nfs4_do_close(struct inode *inode, struct nfs4_state *state, mode_t mode); | ||
187 | extern struct inode *nfs4_atomic_open(struct inode *, struct dentry *, struct nameidata *); | ||
188 | extern int nfs4_open_revalidate(struct inode *, struct dentry *, int); | ||
189 | |||
190 | extern struct nfs4_state_recovery_ops nfs4_reboot_recovery_ops; | ||
191 | extern struct nfs4_state_recovery_ops nfs4_network_partition_recovery_ops; | ||
192 | |||
193 | extern const u32 nfs4_fattr_bitmap[2]; | ||
194 | extern const u32 nfs4_statfs_bitmap[2]; | ||
195 | extern const u32 nfs4_pathconf_bitmap[2]; | ||
196 | extern const u32 nfs4_fsinfo_bitmap[2]; | ||
197 | |||
198 | /* nfs4renewd.c */ | ||
199 | extern void nfs4_schedule_state_renewal(struct nfs4_client *); | ||
200 | extern void nfs4_renewd_prepare_shutdown(struct nfs_server *); | ||
201 | extern void nfs4_kill_renewd(struct nfs4_client *); | ||
202 | extern void nfs4_renew_state(void *); | ||
203 | |||
204 | /* nfs4state.c */ | ||
205 | extern void init_nfsv4_state(struct nfs_server *); | ||
206 | extern void destroy_nfsv4_state(struct nfs_server *); | ||
207 | extern struct nfs4_client *nfs4_get_client(struct in_addr *); | ||
208 | extern void nfs4_put_client(struct nfs4_client *clp); | ||
209 | extern int nfs4_init_client(struct nfs4_client *clp); | ||
210 | extern struct nfs4_client *nfs4_find_client(struct in_addr *); | ||
211 | extern u32 nfs4_alloc_lockowner_id(struct nfs4_client *); | ||
212 | |||
213 | extern struct nfs4_state_owner * nfs4_get_state_owner(struct nfs_server *, struct rpc_cred *); | ||
214 | extern void nfs4_put_state_owner(struct nfs4_state_owner *); | ||
215 | extern void nfs4_drop_state_owner(struct nfs4_state_owner *); | ||
216 | extern struct nfs4_state * nfs4_get_open_state(struct inode *, struct nfs4_state_owner *); | ||
217 | extern void nfs4_put_open_state(struct nfs4_state *); | ||
218 | extern void nfs4_close_state(struct nfs4_state *, mode_t); | ||
219 | extern struct nfs4_state *nfs4_find_state(struct inode *, struct rpc_cred *, mode_t mode); | ||
220 | extern void nfs4_increment_seqid(int status, struct nfs4_state_owner *sp); | ||
221 | extern void nfs4_schedule_state_recovery(struct nfs4_client *); | ||
222 | extern struct nfs4_lock_state *nfs4_find_lock_state(struct nfs4_state *state, fl_owner_t); | ||
223 | extern struct nfs4_lock_state *nfs4_get_lock_state(struct nfs4_state *state, fl_owner_t); | ||
224 | extern void nfs4_put_lock_state(struct nfs4_lock_state *state); | ||
225 | extern void nfs4_increment_lock_seqid(int status, struct nfs4_lock_state *ls); | ||
226 | extern void nfs4_notify_setlk(struct nfs4_state *, struct file_lock *, struct nfs4_lock_state *); | ||
227 | extern void nfs4_notify_unlck(struct nfs4_state *, struct file_lock *, struct nfs4_lock_state *); | ||
228 | extern void nfs4_copy_stateid(nfs4_stateid *, struct nfs4_state *, fl_owner_t); | ||
229 | |||
230 | extern const nfs4_stateid zero_stateid; | ||
231 | |||
232 | /* nfs4xdr.c */ | ||
233 | extern uint32_t *nfs4_decode_dirent(uint32_t *p, struct nfs_entry *entry, int plus); | ||
234 | extern struct rpc_procinfo nfs4_procedures[]; | ||
235 | |||
236 | struct nfs4_mount_data; | ||
237 | |||
238 | /* callback_xdr.c */ | ||
239 | extern 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 */ | ||