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