1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
5 #ifndef LLITE_INTERNAL_H
6 #define LLITE_INTERNAL_H
8 #include <linux/lustre_debug.h>
11 struct lustre_intent_data {
12 __u64 it_lock_handle[2];
18 #define LL_IT2STR(it) ((it) ? ldlm_it2str((it)->it_op) : "0")
20 static inline struct lookup_intent *ll_nd2it(struct nameidata *nd)
22 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
29 struct ll_dentry_data {
32 struct obd_client_handle lld_cwd_och;
33 struct obd_client_handle lld_mnt_och;
36 #define ll_d2d(de) ((struct ll_dentry_data*) de->d_fsdata)
38 extern struct file_operations ll_pgcache_seq_fops;
40 #define LLI_INODE_MAGIC 0x111d0de5
41 #define LLI_INODE_DEAD 0xdeadd00d
42 #define LLI_F_HAVE_OST_SIZE_LOCK 0
43 #define LLI_F_HAVE_MDS_SIZE_LOCK 1
44 struct ll_inode_info {
47 struct semaphore lli_size_sem;
48 struct semaphore lli_open_sem;
49 struct lov_stripe_md *lli_smd;
50 char *lli_symlink_name;
53 unsigned long lli_flags;
55 /* this lock protects s_d_w and p_w_ll and mmap_cnt */
57 struct list_head lli_pending_write_llaps;
58 int lli_send_done_writing;
59 atomic_t lli_mmap_cnt;
61 struct list_head lli_close_item;
63 /* for writepage() only to communicate to fsync */
66 struct file_operations *ll_save_ifop;
67 struct file_operations *ll_save_ffop;
68 struct file_operations *ll_save_wfop;
69 struct file_operations *ll_save_wrfop;
70 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
71 struct inode lli_vfs_inode;
75 // FIXME: replace the name of this with LL_I to conform to kernel stuff
76 // static inline struct ll_inode_info *LL_I(struct inode *inode)
77 static inline struct ll_inode_info *ll_i2info(struct inode *inode)
79 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
80 return container_of(inode, struct ll_inode_info, lli_vfs_inode);
82 return (struct ll_inode_info *)&(inode->u.generic_ip);
87 /* default to about 40meg of readahead on a given system. That much tied
88 * up in 512k readahead requests serviced at 40ms each is about 1GB/s. */
89 #define SBI_DEFAULT_READAHEAD_MAX (40UL << (20 - PAGE_CACHE_SHIFT))
93 RA_STAT_DISTANT_READPAGE,
94 RA_STAT_MISS_IN_WINDOW,
100 RA_STAT_MAX_IN_FLIGHT,
105 unsigned long ra_cur_pages;
106 unsigned long ra_max_pages;
107 unsigned long ra_stats[_NR_RA_STAT];
111 struct list_head ll_list;
112 /* this protects pglist and ra_info. It isn't safe to
113 * grab from interrupt contexts */
115 struct obd_uuid ll_sb_uuid;
116 struct obd_export *ll_mdc_exp;
117 struct obd_export *ll_osc_exp;
118 struct proc_dir_entry* ll_proc_root;
119 obd_id ll_rootino; /* number of root inode */
121 struct lustre_mount_data *ll_lmd;
125 struct list_head ll_conn_chain; /* per-conn chain of SBs */
127 struct hlist_head ll_orphan_dentry_list; /*please don't ask -p*/
128 struct ll_close_queue *ll_lcq;
130 struct lprocfs_stats *ll_stats; /* lprocfs stats counter */
132 unsigned long ll_async_page_max;
133 unsigned long ll_async_page_count;
134 unsigned long ll_pglist_gen;
135 struct list_head ll_pglist; /* all pages (llap_pglist_item) */
137 struct ll_ra_info ll_ra_info;
138 unsigned int ll_namelen;
141 struct ll_readahead_state {
143 unsigned long ras_last_readpage, ras_consecutive;
144 unsigned long ras_window_start, ras_window_len;
145 unsigned long ras_next_readahead;
149 extern kmem_cache_t *ll_file_data_slab;
150 struct ll_file_data {
151 struct obd_client_handle fd_mds_och;
152 struct ll_readahead_state fd_ras;
156 struct lustre_handle;
157 struct lov_stripe_md;
159 extern spinlock_t inode_lock;
161 extern void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi);
162 extern struct proc_dir_entry *proc_lustre_fs_root;
164 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
165 # define hlist_del_init list_del_init
168 static inline struct inode *ll_info2i(struct ll_inode_info *lli)
170 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
171 return &lli->lli_vfs_inode;
173 return list_entry(lli, struct inode, u.generic_ip);
177 static inline void ll_i2uctxt(struct ll_uctxt *ctxt, struct inode *i1,
183 if (in_group_p(i1->i_gid))
184 ctxt->gid1 = i1->i_gid;
189 if (in_group_p(i2->i_gid))
190 ctxt->gid2 = i2->i_gid;
198 struct inode *icbd_parent;
199 struct dentry **icbd_childp;
203 #define LLAP_MAGIC 98764321
205 extern kmem_cache_t *ll_async_page_slab;
206 extern size_t ll_async_page_slab_size;
207 struct ll_async_page {
210 struct page *llap_page;
211 struct list_head llap_pending_write;
212 /* only trust these if the page lock is providing exclusion */
213 unsigned int llap_write_queued:1,
214 llap_defer_uptodate:1,
217 struct list_head llap_pglist_item;
221 LLAP_ORIGIN_UNKNOWN = 0,
222 LLAP_ORIGIN_READPAGE,
223 LLAP_ORIGIN_READAHEAD,
224 LLAP_ORIGIN_COMMIT_WRITE,
225 LLAP_ORIGIN_WRITEPAGE,
228 extern char *llap_origins[];
230 #ifdef HAVE_REGISTER_CACHE
231 #define ll_register_cache(cache) register_cache(cache)
232 #define ll_unregister_cache(cache) unregister_cache(cache)
234 #define ll_register_cache(cache) do {} while (0)
235 #define ll_unregister_cache(cache) do {} while (0)
238 /* llite/lproc_llite.c */
239 int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
240 struct super_block *sb, char *osc, char *mdc);
241 void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi);
244 extern struct file_operations ll_dir_operations;
245 extern struct inode_operations ll_dir_inode_operations;
248 int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir);
249 struct inode *ll_iget(struct super_block *sb, ino_t hash,
250 struct lustre_md *lic);
251 struct dentry *ll_find_alias(struct inode *, struct dentry *);
252 int ll_mdc_cancel_unused(struct lustre_handle *, struct inode *, int flags,
254 int ll_mdc_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *,
255 void *data, int flag);
256 void ll_prepare_mdc_op_data(struct mdc_op_data *,
257 struct inode *i1, struct inode *i2,
258 const char *name, int namelen, int mode);
261 int ll_prepare_write(struct file *, struct page *, unsigned from, unsigned to);
262 int ll_commit_write(struct file *, struct page *, unsigned from, unsigned to);
263 int ll_writepage(struct page *page);
264 void ll_inode_fill_obdo(struct inode *inode, int cmd, struct obdo *oa);
265 void ll_ap_completion(void *data, int cmd, struct obdo *oa, int rc);
266 int llap_shrink_cache(struct ll_sb_info *sbi, int shrink_fraction);
267 extern struct cache_definition ll_cache_definition;
268 void ll_removepage(struct page *page);
269 int ll_readpage(struct file *file, struct page *page);
270 struct ll_async_page *llap_from_cookie(void *cookie);
271 struct ll_async_page *llap_from_page(struct page *page, unsigned origin);
272 struct ll_async_page *llap_cast_private(struct page *page);
273 void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras);
274 void ll_ra_accounting(struct page *page, struct address_space *mapping);
275 void ll_truncate(struct inode *inode);
278 extern struct file_operations ll_file_operations;
279 extern struct inode_operations ll_file_inode_operations;
280 extern int ll_inode_revalidate_it(struct dentry *, struct lookup_intent *);
281 int ll_extent_lock(struct ll_file_data *, struct inode *,
282 struct lov_stripe_md *, int mode, ldlm_policy_data_t *,
283 struct lustre_handle *, int ast_flags);
284 int ll_extent_unlock(struct ll_file_data *, struct inode *,
285 struct lov_stripe_md *, int mode, struct lustre_handle *);
286 int ll_file_open(struct inode *inode, struct file *file);
287 int ll_file_release(struct inode *inode, struct file *file);
288 int ll_lsm_getattr(struct obd_export *, struct lov_stripe_md *, struct obdo *);
289 int ll_glimpse_size(struct inode *inode);
290 int ll_local_open(struct file *file, struct lookup_intent *it);
291 int ll_mdc_close(struct obd_export *mdc_exp, struct inode *inode,
293 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
294 int ll_getattr(struct vfsmount *mnt, struct dentry *de,
295 struct lookup_intent *it, struct kstat *stat);
299 void ll_intent_drop_lock(struct lookup_intent *);
300 void ll_intent_release(struct lookup_intent *);
301 extern void ll_set_dd(struct dentry *de);
302 void ll_unhash_aliases(struct inode *);
303 void ll_frob_intent(struct lookup_intent **itp, struct lookup_intent *deft);
304 void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry);
306 /* llite/llite_lib.c */
308 extern struct super_operations lustre_super_operations;
310 char *ll_read_opt(const char *opt, char *data);
311 int ll_set_opt(const char *opt, char *data, int fl);
312 void ll_options(char *options, char **ost, char **mds, int *flags);
313 void ll_lli_init(struct ll_inode_info *lli);
314 int ll_fill_super(struct super_block *sb, void *data, int silent);
315 int lustre_fill_super(struct super_block *sb, void *data, int silent);
316 void lustre_put_super(struct super_block *sb);
317 struct inode *ll_inode_from_lock(struct ldlm_lock *lock);
318 void ll_clear_inode(struct inode *inode);
319 int ll_setattr_raw(struct inode *inode, struct iattr *attr);
320 int ll_setattr(struct dentry *de, struct iattr *attr);
321 int ll_statfs(struct super_block *sb, struct kstatfs *sfs);
322 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
323 unsigned long maxage);
324 void ll_update_inode(struct inode *inode, struct mds_body *body,
325 struct lov_stripe_md *lsm);
326 void ll_read_inode2(struct inode *inode, void *opaque);
327 int ll_iocontrol(struct inode *inode, struct file *file,
328 unsigned int cmd, unsigned long arg);
329 void ll_umount_begin(struct super_block *sb);
330 int lustre_remount_fs(struct super_block *sb, int *flags, char *data);
331 int ll_prep_inode(struct obd_export *exp, struct inode **inode,
332 struct ptlrpc_request *req, int offset, struct super_block *);
333 void lustre_dump_dentry(struct dentry *, int recur);
334 void lustre_dump_inode(struct inode *);
335 struct ll_async_page *llite_pglist_next_llap(struct ll_sb_info *sbi,
336 struct list_head *list);
338 /* llite/llite_nfs.c */
339 __u32 get_uuid2int(const char *name, int len);
340 struct dentry *ll_fh_to_dentry(struct super_block *sb, __u32 *data, int len,
341 int fhtype, int parent);
342 int ll_dentry_to_fh(struct dentry *, __u32 *datap, int *lenp, int need_parent);
344 /* llite/special.c */
345 extern struct inode_operations ll_special_inode_operations;
346 extern struct file_operations ll_special_chr_inode_fops;
347 extern struct file_operations ll_special_chr_file_fops;
348 extern struct file_operations ll_special_blk_inode_fops;
349 extern struct file_operations ll_special_fifo_inode_fops;
350 extern struct file_operations ll_special_fifo_file_fops;
351 extern struct file_operations ll_special_sock_inode_fops;
353 /* llite/symlink.c */
354 extern struct inode_operations ll_fast_symlink_inode_operations;
356 /* llite/llite_close.c */
357 struct ll_close_queue {
359 struct list_head lcq_list;
360 wait_queue_head_t lcq_waitq;
361 struct completion lcq_comp;
364 void llap_write_pending(struct inode *inode, struct ll_async_page *llap);
365 void llap_write_complete(struct inode *inode, struct ll_async_page *llap);
366 void ll_open_complete(struct inode *inode);
367 int ll_is_inode_dirty(struct inode *inode);
368 void ll_try_done_writing(struct inode *inode);
369 void ll_queue_done_writing(struct inode *inode);
370 void ll_close_thread_shutdown(struct ll_close_queue *lcq);
371 int ll_close_thread_start(struct ll_close_queue **lcq_ret);
373 /* llite/llite_mmap.c */
374 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
375 typedef struct rb_root rb_root_t;
376 typedef struct rb_node rb_node_t;
379 struct ll_lock_tree_node;
380 struct ll_lock_tree {
382 struct list_head lt_locked_list;
383 struct ll_file_data *lt_fd;
386 int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last);
387 int ll_file_mmap(struct file * file, struct vm_area_struct * vma);
388 struct ll_lock_tree_node * ll_node_from_inode(struct inode *inode, __u64 start,
389 __u64 end, ldlm_mode_t mode);
390 int ll_tree_lock(struct ll_lock_tree *tree,
391 struct ll_lock_tree_node *first_node,
392 const char *buf, size_t count, int ast_flags);
393 int ll_tree_unlock(struct ll_lock_tree *tree);
396 #define LL_SBI_NOLCK 0x1
398 #define LL_MAX_BLKSIZE (4UL * 1024 * 1024)
400 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
401 #define ll_s2sbi(sb) ((struct ll_sb_info *)((sb)->s_fs_info))
402 #define ll_s2sbi_nocast(sb) ((sb)->s_fs_info)
403 void __d_rehash(struct dentry * entry, int lock);
404 static inline __u64 ll_ts2u64(struct timespec *time)
406 __u64 t = time->tv_sec;
410 #define ll_s2sbi(sb) ((struct ll_sb_info *)((sb)->u.generic_sbp))
411 #define ll_s2sbi_nocast(sb) ((sb)->u.generic_sbp)
412 static inline __u64 ll_ts2u64(time_t *time)
418 /* don't need an addref as the sb_info should be holding one */
419 static inline struct obd_export *ll_s2obdexp(struct super_block *sb)
421 return ll_s2sbi(sb)->ll_osc_exp;
424 /* don't need an addref as the sb_info should be holding one */
425 static inline struct obd_export *ll_s2mdcexp(struct super_block *sb)
427 return ll_s2sbi(sb)->ll_mdc_exp;
430 static inline struct client_obd *sbi2mdc(struct ll_sb_info *sbi)
432 struct obd_device *obd = sbi->ll_mdc_exp->exp_obd;
438 // FIXME: replace the name of this with LL_SB to conform to kernel stuff
439 static inline struct ll_sb_info *ll_i2sbi(struct inode *inode)
441 return ll_s2sbi(inode->i_sb);
444 static inline struct obd_export *ll_i2obdexp(struct inode *inode)
446 return ll_s2obdexp(inode->i_sb);
449 static inline struct obd_export *ll_i2mdcexp(struct inode *inode)
451 return ll_s2mdcexp(inode->i_sb);
454 static inline void ll_inode2fid(struct ll_fid *fid, struct inode *inode)
456 mdc_pack_fid(fid, inode->i_ino, inode->i_generation,
457 inode->i_mode & S_IFMT);
460 static inline int ll_mds_max_easize(struct super_block *sb)
462 return sbi2mdc(ll_s2sbi(sb))->cl_max_mds_easize;
465 static inline __u64 ll_file_maxbytes(struct inode *inode)
467 return ll_i2info(inode)->lli_maxbytes;
470 #endif /* LLITE_INTERNAL_H */