1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
7 #include <libcfs/kp30.h>
9 #define LL_ID_NAMELEN (16 + 1 + 8 + 1)
11 #if defined __KERNEL__
12 #include <linux/dcache.h>
13 #include <linux/namei.h>
14 #include <linux/lustre_compat25.h>
15 #include <linux/lvfs_linux.h>
19 #include <lvfs_user_fs.h>
22 struct mds_grp_hash_entry;
26 struct lustre_sec_desc *luc_lsd;
27 struct group_info *luc_ginfo;
35 struct lvfs_callback_ops {
36 struct dentry *(*l_id2dentry)(__u64 ino, __u32 gen,
37 __u64 gr, void *data);
40 #define OBD_RUN_CTXT_MAGIC 0xC0FFEEAA
41 #define OBD_CTXT_DEBUG /* development-only debugging */
42 struct lvfs_run_ctxt {
43 struct vfsmount *pwdmnt;
46 struct lvfs_ucred luc;
47 struct lvfs_callback_ops cb_ops;
49 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4)
50 struct group_info *group_info;
52 struct group_info group_info;
61 #define OBD_SET_CTXT_MAGIC(ctxt) (ctxt)->magic = OBD_RUN_CTXT_MAGIC
63 #define OBD_SET_CTXT_MAGIC(ctxt) do {} while(0)
67 struct dentry *lvfs_id2dentry(struct lvfs_run_ctxt *, __u64,
68 __u32, __u64 ,void *data);
70 void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx,
71 struct lvfs_ucred *cred);
72 void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx,
73 struct lvfs_ucred *cred);
76 int lvfs_reint(struct super_block *sb, void *r_rec);
77 int lvfs_undo(struct super_block *sb, void *r_rec);
78 struct dentry *simple_mkdir(struct dentry *dir, char *name, int mode, int fix);
79 struct dentry *simple_mknod(struct dentry *dir, char *name, int mode, int fix);
80 int lustre_fread(struct file *file, void *buf, int len, loff_t *off);
81 int lustre_fwrite(struct file *file, const void *buf, int len, loff_t *off);
82 int lustre_fsync(struct file *file);
83 long l_readdir(struct file * file, struct list_head *dentry_list);
85 static inline void l_dput(struct dentry *de)
87 if (!de || IS_ERR(de))
89 //shrink_dcache_parent(de);
90 LASSERT(atomic_read(&de->d_count) > 0);
95 void *lock_dir(struct inode *dir, struct qstr *name);
96 void unlock_dir(struct inode *dir, void *lock);
99 /* We need to hold the inode semaphore over the dcache lookup itself, or we run
100 * the risk of entering the filesystem lookup path concurrently on SMP systems,
101 * and instantiating two inodes for the same entry. We still protect against
102 * concurrent addition/removal races with the DLM locking. */
103 static inline struct dentry *
104 ll_lookup_one_len(const char *name, struct dentry *dparent, int namelen)
106 struct dentry *dchild;
112 lock = lock_dir(dparent->d_inode, &qstr);
114 down(&dparent->d_inode->i_sem);
117 dchild = lookup_one_len(name, dparent, namelen);
120 unlock_dir(dparent->d_inode, lock);
122 up(&dparent->d_inode->i_sem);
127 static inline void ll_sleep(int t)
129 set_current_state(TASK_INTERRUPTIBLE);
130 schedule_timeout(t * HZ);
131 set_current_state(TASK_RUNNING);
134 static inline struct dentry *
135 ll_d_lookup(const char *name,
136 struct dentry *dparent, int len)
142 qstr.hash = full_name_hash(name, len);
143 return d_lookup(dparent, &qstr);
147 static inline int ll_id2str(char *str, __u64 id, __u32 generation)
149 return sprintf(str, "%llx:%08x", (unsigned long long)id,