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