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