Whamcloud - gitweb
Commit OST AMD support to HEAD so we can being running with a common code base.
[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 lvfs_ucred {
18         __u32 luc_fsuid;
19         __u32 luc_fsgid;
20         __u32 luc_cap;
21         __u32 luc_suppgid1;
22         __u32 luc_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 lvfs_run_ctxt {
32         struct vfsmount *pwdmnt;
33         struct dentry   *pwd;
34         mm_segment_t     fs;
35         struct lvfs_ucred luc;
36         int              ngroups;
37         struct lvfs_callback_ops cb_ops;
38 #ifdef OBD_CTXT_DEBUG
39         int              pid;
40         __u32            magic;
41 #endif
42 };
43
44 #ifdef OBD_CTXT_DEBUG
45 #define OBD_SET_CTXT_MAGIC(ctxt) (ctxt)->magic = OBD_RUN_CTXT_MAGIC
46 #else
47 #define OBD_SET_CTXT_MAGIC(ctxt) do {} while(0)
48 #endif
49
50 /* lvfs_common.c */
51 struct dentry *lvfs_fid2dentry(struct lvfs_run_ctxt *, __u64, __u32, __u64 ,void *data);
52
53 void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx,
54                struct lvfs_ucred *cred);
55 void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx,
56               struct lvfs_ucred *cred);
57
58 #ifdef __KERNEL__
59 int lvfs_reint(struct super_block *sb, void *r_rec);
60 int lvfs_undo(struct super_block *sb, void *r_rec);
61 struct dentry *simple_mkdir(struct dentry *dir, char *name, int mode, int fix);
62 struct dentry *simple_mknod(struct dentry *dir, char *name, int mode, int fix);
63 int lustre_fread(struct file *file, void *buf, int len, loff_t *off);
64 int lustre_fwrite(struct file *file, const void *buf, int len, loff_t *off);
65 int lustre_fsync(struct file *file);
66 long l_readdir(struct file * file, struct list_head *dentry_list);
67
68 static inline void l_dput(struct dentry *de)
69 {
70         if (!de || IS_ERR(de))
71                 return;
72         //shrink_dcache_parent(de);
73         LASSERT(atomic_read(&de->d_count) > 0);
74         dput(de);
75 }
76
77 #ifdef S_PDIROPS
78 void *lock_dir(struct inode *dir, struct qstr *name);
79 void unlock_dir(struct inode *dir, void *lock);
80 #endif
81
82 /* We need to hold the inode semaphore over the dcache lookup itself, or we
83  * run the risk of entering the filesystem lookup path concurrently on SMP
84  * systems, and instantiating two inodes for the same entry.  We still
85  * protect against concurrent addition/removal races with the DLM locking.
86  */
87 static inline struct dentry *ll_lookup_one_len(const char *fid_name,
88                                                struct dentry *dparent,
89                                                int fid_namelen)
90 {
91         struct dentry *dchild;
92 #ifdef S_PDIROPS
93         struct qstr qstr;
94         void *lock;
95         qstr.name = fid_name;
96         qstr.len = fid_namelen;
97         lock = lock_dir(dparent->d_inode, &qstr);
98 #else
99         down(&dparent->d_inode->i_sem);
100 #endif
101
102         dchild = lookup_one_len(fid_name, dparent, fid_namelen);
103
104 #ifdef S_PDIROPS
105         unlock_dir(dparent->d_inode, lock);
106 #else
107         up(&dparent->d_inode->i_sem);
108 #endif
109         return dchild;
110 }
111
112 static inline void ll_sleep(int t)
113 {
114         set_current_state(TASK_INTERRUPTIBLE);
115         schedule_timeout(t * HZ);
116         set_current_state(TASK_RUNNING);
117 }
118 #endif
119
120 static inline int ll_fid2str(char *str, __u64 id, __u32 generation)
121 {
122         return sprintf(str, "%llx:%08x", (unsigned long long)id, generation);
123 }
124
125 #endif