Whamcloud - gitweb
- revert the b=1934 fix from 1/16 to stop llmount from hanging
[fs/lustre-release.git] / lustre / include / linux / lvfs.h
1 #ifndef __LVFS_H__
2 #define __LVFS_H__
3
4 #include <linux/kp30.h>
5
6 #if defined __KERNEL__
7 #include <linux/lvfs_linux.h>
8 #endif 
9
10 #ifdef LIBLUSTRE
11 #include <lvfs_user_fs.h>
12 #endif
13
14 /* simple.c */
15 struct obd_ucred {
16         __u32 ouc_fsuid;
17         __u32 ouc_fsgid;
18         __u32 ouc_cap;
19         __u32 ouc_suppgid1;
20         __u32 ouc_suppgid2;
21 };
22
23 struct lvfs_callback_ops {
24         struct dentry *(*l_fid2dentry)(__u64 id_ino, __u32 gen, __u64 gr, void *data);
25 };
26
27 #define OBD_RUN_CTXT_MAGIC      0xC0FFEEAA
28 #define OBD_CTXT_DEBUG          /* development-only debugging */
29 struct obd_run_ctxt {
30         struct vfsmount *pwdmnt;
31         struct dentry   *pwd;
32         mm_segment_t     fs;
33         struct obd_ucred ouc;
34         int              ngroups;
35         struct lvfs_callback_ops cb_ops;
36 #ifdef OBD_CTXT_DEBUG
37         __u32            magic;
38 #endif
39 };
40
41 #ifdef OBD_CTXT_DEBUG
42 #define OBD_SET_CTXT_MAGIC(ctxt) (ctxt)->magic = OBD_RUN_CTXT_MAGIC
43 #else
44 #define OBD_SET_CTXT_MAGIC(ctxt) do {} while(0)
45 #endif
46
47 /* lvfs_common.c */
48 struct dentry *lvfs_fid2dentry(struct obd_run_ctxt *, __u64, __u32, __u64 ,void *data);
49
50 void push_ctxt(struct obd_run_ctxt *save, struct obd_run_ctxt *new_ctx,
51                struct obd_ucred *cred);
52 void pop_ctxt(struct obd_run_ctxt *saved, struct obd_run_ctxt *new_ctx,
53               struct obd_ucred *cred);
54
55 #ifdef __KERNEL__
56
57 struct dentry *simple_mkdir(struct dentry *dir, char *name, int mode);
58 struct dentry *simple_mknod(struct dentry *dir, char *name, int mode);
59 int lustre_fread(struct file *file, void *buf, int len, loff_t *off);
60 int lustre_fwrite(struct file *file, const void *buf, int len, loff_t *off);
61 int lustre_fsync(struct file *file);
62 long l_readdir(struct file * file, void * dirent, unsigned int count);
63
64 static inline void l_dput(struct dentry *de)
65 {
66         if (!de || IS_ERR(de))
67                 return;
68         //shrink_dcache_parent(de);
69         LASSERT(atomic_read(&de->d_count) > 0);
70         dput(de);
71 }
72
73 /* We need to hold the inode semaphore over the dcache lookup itself, or we
74  * run the risk of entering the filesystem lookup path concurrently on SMP
75  * systems, and instantiating two inodes for the same entry.  We still
76  * protect against concurrent addition/removal races with the DLM locking.
77  */
78 static inline struct dentry *ll_lookup_one_len(const char *fid_name,
79                                                struct dentry *dparent,
80                                                int fid_namelen)
81 {
82         struct dentry *dchild;
83
84         down(&dparent->d_inode->i_sem);
85         dchild = lookup_one_len(fid_name, dparent, fid_namelen);
86         up(&dparent->d_inode->i_sem);
87
88         return dchild;
89 }
90
91 static inline void ll_sleep(int t)
92 {
93         set_current_state(TASK_INTERRUPTIBLE);
94         schedule_timeout(t * HZ);
95         set_current_state(TASK_RUNNING);
96 }
97 #endif
98
99 #define LL_FID_NAMELEN         (16 + 1 + 8 + 1)
100 static inline int ll_fid2str(char *str, __u64 id, __u32 generation)
101 {
102         return sprintf(str, "%llx:%08x", (unsigned long long)id, generation);
103 }
104
105 #endif