aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/nfsd
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@citi.umich.edu>2009-12-04 19:36:06 -0500
committerJ. Bruce Fields <bfields@citi.umich.edu>2009-12-15 15:01:46 -0500
commit1557aca7904ed6fadd22cdc3364754070bb3d3c3 (patch)
tree97af309e4cff7e9fc2cb9d90aeceff8404c2c47f /include/linux/nfsd
parentc7af6b0895229bd080b86afc91302b66f6df0378 (diff)
nfsd: move most of nfsfh.h to fs/nfsd
Most of this can be trivially moved to a private header as well. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Diffstat (limited to 'include/linux/nfsd')
-rw-r--r--include/linux/nfsd/nfsfh.h199
1 files changed, 0 insertions, 199 deletions
diff --git a/include/linux/nfsd/nfsfh.h b/include/linux/nfsd/nfsfh.h
index 49523edbc510..65e333afaee4 100644
--- a/include/linux/nfsd/nfsfh.h
+++ b/include/linux/nfsd/nfsfh.h
@@ -162,205 +162,6 @@ typedef struct svc_fh {
162 162
163} svc_fh; 163} svc_fh;
164 164
165enum nfsd_fsid {
166 FSID_DEV = 0,
167 FSID_NUM,
168 FSID_MAJOR_MINOR,
169 FSID_ENCODE_DEV,
170 FSID_UUID4_INUM,
171 FSID_UUID8,
172 FSID_UUID16,
173 FSID_UUID16_INUM,
174};
175
176enum fsid_source {
177 FSIDSOURCE_DEV,
178 FSIDSOURCE_FSID,
179 FSIDSOURCE_UUID,
180};
181extern enum fsid_source fsid_source(struct svc_fh *fhp);
182
183
184/* This might look a little large to "inline" but in all calls except
185 * one, 'vers' is constant so moste of the function disappears.
186 */
187static inline void mk_fsid(int vers, u32 *fsidv, dev_t dev, ino_t ino,
188 u32 fsid, unsigned char *uuid)
189{
190 u32 *up;
191 switch(vers) {
192 case FSID_DEV:
193 fsidv[0] = htonl((MAJOR(dev)<<16) |
194 MINOR(dev));
195 fsidv[1] = ino_t_to_u32(ino);
196 break;
197 case FSID_NUM:
198 fsidv[0] = fsid;
199 break;
200 case FSID_MAJOR_MINOR:
201 fsidv[0] = htonl(MAJOR(dev));
202 fsidv[1] = htonl(MINOR(dev));
203 fsidv[2] = ino_t_to_u32(ino);
204 break;
205
206 case FSID_ENCODE_DEV:
207 fsidv[0] = new_encode_dev(dev);
208 fsidv[1] = ino_t_to_u32(ino);
209 break;
210
211 case FSID_UUID4_INUM:
212 /* 4 byte fsid and inode number */
213 up = (u32*)uuid;
214 fsidv[0] = ino_t_to_u32(ino);
215 fsidv[1] = up[0] ^ up[1] ^ up[2] ^ up[3];
216 break;
217
218 case FSID_UUID8:
219 /* 8 byte fsid */
220 up = (u32*)uuid;
221 fsidv[0] = up[0] ^ up[2];
222 fsidv[1] = up[1] ^ up[3];
223 break;
224
225 case FSID_UUID16:
226 /* 16 byte fsid - NFSv3+ only */
227 memcpy(fsidv, uuid, 16);
228 break;
229
230 case FSID_UUID16_INUM:
231 /* 8 byte inode and 16 byte fsid */
232 *(u64*)fsidv = (u64)ino;
233 memcpy(fsidv+2, uuid, 16);
234 break;
235 default: BUG();
236 }
237}
238
239static inline int key_len(int type)
240{
241 switch(type) {
242 case FSID_DEV: return 8;
243 case FSID_NUM: return 4;
244 case FSID_MAJOR_MINOR: return 12;
245 case FSID_ENCODE_DEV: return 8;
246 case FSID_UUID4_INUM: return 8;
247 case FSID_UUID8: return 8;
248 case FSID_UUID16: return 16;
249 case FSID_UUID16_INUM: return 24;
250 default: return 0;
251 }
252}
253
254/*
255 * Shorthand for dprintk()'s
256 */
257extern char * SVCFH_fmt(struct svc_fh *fhp);
258
259/*
260 * Function prototypes
261 */
262__be32 fh_verify(struct svc_rqst *, struct svc_fh *, int, int);
263__be32 fh_compose(struct svc_fh *, struct svc_export *, struct dentry *, struct svc_fh *);
264__be32 fh_update(struct svc_fh *);
265void fh_put(struct svc_fh *);
266
267static __inline__ struct svc_fh *
268fh_copy(struct svc_fh *dst, struct svc_fh *src)
269{
270 WARN_ON(src->fh_dentry || src->fh_locked);
271
272 *dst = *src;
273 return dst;
274}
275
276static inline void
277fh_copy_shallow(struct knfsd_fh *dst, struct knfsd_fh *src)
278{
279 dst->fh_size = src->fh_size;
280 memcpy(&dst->fh_base, &src->fh_base, src->fh_size);
281}
282
283static __inline__ struct svc_fh *
284fh_init(struct svc_fh *fhp, int maxsize)
285{
286 memset(fhp, 0, sizeof(*fhp));
287 fhp->fh_maxsize = maxsize;
288 return fhp;
289}
290
291#ifdef CONFIG_NFSD_V3
292/*
293 * Fill in the pre_op attr for the wcc data
294 */
295static inline void
296fill_pre_wcc(struct svc_fh *fhp)
297{
298 struct inode *inode;
299
300 inode = fhp->fh_dentry->d_inode;
301 if (!fhp->fh_pre_saved) {
302 fhp->fh_pre_mtime = inode->i_mtime;
303 fhp->fh_pre_ctime = inode->i_ctime;
304 fhp->fh_pre_size = inode->i_size;
305 fhp->fh_pre_change = inode->i_version;
306 fhp->fh_pre_saved = 1;
307 }
308}
309
310extern void fill_post_wcc(struct svc_fh *);
311#else
312#define fill_pre_wcc(ignored)
313#define fill_post_wcc(notused)
314#endif /* CONFIG_NFSD_V3 */
315
316
317/*
318 * Lock a file handle/inode
319 * NOTE: both fh_lock and fh_unlock are done "by hand" in
320 * vfs.c:nfsd_rename as it needs to grab 2 i_mutex's at once
321 * so, any changes here should be reflected there.
322 */
323
324static inline void
325fh_lock_nested(struct svc_fh *fhp, unsigned int subclass)
326{
327 struct dentry *dentry = fhp->fh_dentry;
328 struct inode *inode;
329
330 BUG_ON(!dentry);
331
332 if (fhp->fh_locked) {
333 printk(KERN_WARNING "fh_lock: %s/%s already locked!\n",
334 dentry->d_parent->d_name.name, dentry->d_name.name);
335 return;
336 }
337
338 inode = dentry->d_inode;
339 mutex_lock_nested(&inode->i_mutex, subclass);
340 fill_pre_wcc(fhp);
341 fhp->fh_locked = 1;
342}
343
344static inline void
345fh_lock(struct svc_fh *fhp)
346{
347 fh_lock_nested(fhp, I_MUTEX_NORMAL);
348}
349
350/*
351 * Unlock a file handle/inode
352 */
353static inline void
354fh_unlock(struct svc_fh *fhp)
355{
356 BUG_ON(!fhp->fh_dentry);
357
358 if (fhp->fh_locked) {
359 fill_post_wcc(fhp);
360 mutex_unlock(&fhp->fh_dentry->d_inode->i_mutex);
361 fhp->fh_locked = 0;
362 }
363}
364#endif /* __KERNEL__ */ 165#endif /* __KERNEL__ */
365 166
366 167