1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * lustre lite cluster file system
6 * This code is issued under the GNU General Public License.
7 * See the file COPYING in this distribution
9 * Copyright (C) 2002 Cluster File Systems, Inc. <info@clusterfs.com>
20 #include <linux/ext2_fs.h>
21 #include <linux/proc_fs.h>
23 #include <linux/obd_class.h>
24 #include <linux/lustre_net.h>
25 #include <linux/lustre_mds.h>
26 #include <linux/lustre_ha.h>
28 extern kmem_cache_t *ll_file_data_slab;
30 struct lustre_handle fd_mdshandle;
31 struct lustre_handle fd_osthandle;
32 struct ptlrpc_request *fd_req;
36 struct lustre_intent_data {
37 __u64 it_lock_handle[2];
43 struct ll_dentry_data {
44 struct semaphore lld_it_sem;
47 #define ll_d2d(dentry) ((struct ll_dentry_data*) dentry->d_fsdata)
49 struct ll_read_inode2_cookie {
50 struct mds_body *lic_body;
51 struct lov_mds_md *lic_lmm;
54 #define LL_INLINESZ 60
55 struct ll_inode_info {
56 struct lov_stripe_md *lli_smd;
57 char *lli_symlink_name;
58 struct semaphore lli_open_sem;
59 atomic_t lli_open_count; /* see ll_file_release */
60 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
61 struct inode lli_vfs_inode;
65 /* interpet return codes from intent lookup */
66 #define LL_LOOKUP_POSITIVE 1
67 #define LL_LOOKUP_NEGATIVE 2
69 #define LL_SUPER_MAGIC 0x0BD00BD0
71 #define LL_COMMITCBD_STOPPING 0x1
72 #define LL_COMMITCBD_STOPPED 0x2
73 #define LL_COMMITCBD_RUNNING 0x4
75 #define LL_SBI_NOLCK 0x1
78 struct obd_uuid ll_sb_uuid;
79 struct lustre_handle ll_mdc_conn;
80 struct lustre_handle ll_osc_conn;
81 struct proc_dir_entry* ll_proc_root;
82 obd_id ll_rootino; /* number of root inode */
85 wait_queue_head_t ll_commitcbd_waitq;
86 wait_queue_head_t ll_commitcbd_ctl_waitq;
87 int ll_commitcbd_flags;
88 struct task_struct *ll_commitcbd_thread;
89 time_t ll_commitcbd_waketime;
90 time_t ll_commitcbd_timeout;
91 spinlock_t ll_commitcbd_lock;
92 struct list_head ll_conn_chain; /* per-conn chain of SBs */
94 struct list_head ll_orphan_dentry_list; /*please don't ask -p*/
97 static inline struct ll_sb_info *ll_s2sbi(struct super_block *sb)
99 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
100 return (struct ll_sb_info *)(sb->s_fs_info);
102 return (struct ll_sb_info *)(sb->u.generic_sbp);
106 static inline struct lustre_handle *ll_s2obdconn(struct super_block *sb)
108 return &(ll_s2sbi(sb))->ll_osc_conn;
111 static inline struct client_obd *sbi2mdc(struct ll_sb_info *sbi)
113 struct obd_device *obd = class_conn2obd(&sbi->ll_mdc_conn);
119 // FIXME: replace the name of this with LL_SB to conform to kernel stuff
120 static inline struct ll_sb_info *ll_i2sbi(struct inode *inode)
122 return ll_s2sbi(inode->i_sb);
125 static inline void d_unhash_aliases(struct inode *inode)
127 struct dentry *dentry = NULL;
128 struct list_head *tmp;
129 struct ll_sb_info *sbi = ll_i2sbi(inode);
132 CDEBUG(D_INODE, "marking dentries for ino %lx/%x invalid\n",
133 inode->i_ino, inode->i_generation);
135 spin_lock(&dcache_lock);
136 list_for_each(tmp, &inode->i_dentry) {
137 dentry = list_entry(tmp, struct dentry, d_alias);
139 list_del_init(&dentry->d_hash);
140 dentry->d_flags |= DCACHE_LUSTRE_INVALID;
141 list_add(&dentry->d_hash, &sbi->ll_orphan_dentry_list);
144 spin_unlock(&dcache_lock);
148 // FIXME: replace the name of this with LL_I to conform to kernel stuff
149 // static inline struct ll_inode_info *LL_I(struct inode *inode)
150 static inline struct ll_inode_info *ll_i2info(struct inode *inode)
152 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
153 return container_of(inode, struct ll_inode_info, lli_vfs_inode);
155 return (struct ll_inode_info *)&(inode->u.generic_ip);
159 static inline struct lustre_handle *ll_i2obdconn(struct inode *inode)
161 return ll_s2obdconn(inode->i_sb);
164 static inline void ll_ino2fid(struct ll_fid *fid, obd_id ino, __u32 generation,
168 fid->generation = generation;
172 static inline void ll_inode2fid(struct ll_fid *fid, struct inode *inode)
174 ll_ino2fid(fid, inode->i_ino, inode->i_generation,
175 inode->i_mode & S_IFMT);
178 static inline int ll_mds_max_easize(struct super_block *sb)
180 return sbi2mdc(ll_s2sbi(sb))->cl_max_mds_easize;
184 int ll_lock(struct inode *dir, struct dentry *dentry,
185 struct lookup_intent *it, struct lustre_handle *lockh);
186 int ll_unlock(__u32 mode, struct lustre_handle *lockh);
188 typedef int (*intent_finish_cb)(int flag, struct ptlrpc_request *,
189 struct dentry **, struct lookup_intent *,
190 int offset, obd_id ino);
191 int ll_intent_lock(struct inode *parent, struct dentry **,
192 struct lookup_intent *, intent_finish_cb);
195 void ll_intent_release(struct dentry *, struct lookup_intent *);
199 I originally implmented these as functions, then realized a macro
200 would be more helpful for debugging, so the CDEBUG messages show
201 the current calling function. The orignal functions are in llite/dcache.c
203 int ll_save_intent(struct dentry * de, struct lookup_intent * it);
204 struct lookup_intent * ll_get_intent(struct dentry * de);
207 #define IT_RELEASED_MAGIC 0xDEADCAFE
209 #define LL_SAVE_INTENT(de, it) \
211 LASSERT(ll_d2d(de) != NULL); \
213 down(&ll_d2d(de)->lld_it_sem); \
214 LASSERT(de->d_it == NULL); \
216 CDEBUG(D_DENTRY, "D_IT DOWN dentry %p fsdata %p intent: %s sem %d\n", \
217 de, ll_d2d(de), ldlm_it2str(de->d_it->it_op), \
218 atomic_read(&(ll_d2d(de)->lld_it_sem.count))); \
221 #define LL_GET_INTENT(de, it) \
225 LASSERT(ll_d2d(de) != NULL); \
227 LASSERT(it->it_op != IT_RELEASED_MAGIC); \
229 CDEBUG(D_DENTRY, "D_IT UP dentry %p fsdata %p intent: %s\n", \
230 de, ll_d2d(de), ldlm_it2str(de->d_it->it_op)); \
232 it->it_op = IT_RELEASED_MAGIC; \
233 up(&ll_d2d(de)->lld_it_sem); \
237 int ll_have_md_lock(struct dentry *de);
240 extern struct file_operations ll_dir_operations;
241 extern struct inode_operations ll_dir_inode_operations;
244 extern struct file_operations ll_file_operations;
245 extern struct inode_operations ll_file_inode_operations;
246 extern struct inode_operations ll_special_inode_operations;
248 int ll_lock_callback(struct ldlm_lock *, struct ldlm_lock_desc *, void *data, int flag);
249 int ll_size_lock(struct inode *, struct lov_stripe_md *, obd_off start,
250 int mode, struct lustre_handle *);
251 int ll_size_unlock(struct inode *, struct lov_stripe_md *, int mode,
252 struct lustre_handle *);
253 int ll_file_size(struct inode *inode, struct lov_stripe_md *md,
254 struct lustre_handle *);
255 int ll_create_objects(struct super_block *sb, obd_id id, uid_t uid,
256 gid_t gid, struct lov_stripe_md **lsmp);
259 struct page *ll_getpage(struct inode *inode, unsigned long offset,
260 int create, int locked);
261 void ll_truncate(struct inode *inode);
264 void ll_update_inode(struct inode *, struct mds_body *, struct lov_mds_md *);
267 extern struct inode_operations ll_fast_symlink_inode_operations;
268 extern struct inode_operations ll_symlink_inode_operations;
271 void ll_sysctl_init(void);
272 void ll_sysctl_clean(void);
274 #endif /* __KERNEL__ */
276 #include <asm/types.h>
278 #define LL_IOC_GETFLAGS _IOR ('f', 151, long)
279 #define LL_IOC_SETFLAGS _IOW ('f', 152, long)
280 #define LL_IOC_CLRFLAGS _IOW ('f', 153, long)
281 #define LL_IOC_LOV_SETSTRIPE _IOW ('f', 154, long)
282 #define LL_IOC_LOV_GETSTRIPE _IOW ('f', 155, long)
284 #define O_LOV_DELAY_CREATE 0100000000 /* hopefully this does not conflict */
286 #define LL_FILE_IGNORE_LOCK 0x00000001