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>
9 #include <linux/lustre_version.h>
12 struct lustre_intent_data {
13 __u64 it_lock_handle[2];
19 #define LL_IT2STR(it) ((it) ? ldlm_it2str((it)->it_op) : "0")
21 #if (LUSTRE_KERNEL_VERSION < 46)
22 #define LUSTRE_FPRIVATE(file) ((file)->private_data)
24 #define LUSTRE_FPRIVATE(file) ((file)->fs_private)
28 static inline struct lookup_intent *ll_nd2it(struct nameidata *nd)
30 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
37 struct ll_dentry_data {
40 struct obd_client_handle lld_cwd_och;
41 struct obd_client_handle lld_mnt_och;
44 #define ll_d2d(de) ((struct ll_dentry_data*) de->d_fsdata)
46 extern struct file_operations ll_pgcache_seq_fops;
48 #define LLI_INODE_MAGIC 0x111d0de5
49 #define LLI_INODE_DEAD 0xdeadd00d
50 #define LLI_F_HAVE_OST_SIZE_LOCK 0
51 #define LLI_F_HAVE_MDS_SIZE_LOCK 1
52 struct ll_inode_info {
55 struct semaphore lli_size_sem;
56 struct semaphore lli_open_sem;
57 struct lov_stripe_md *lli_smd;
58 char *lli_symlink_name;
61 unsigned long lli_flags;
63 /* this lock protects s_d_w and p_w_ll and mmap_cnt */
65 struct list_head lli_pending_write_llaps;
66 int lli_send_done_writing;
67 atomic_t lli_mmap_cnt;
69 struct list_head lli_close_item;
71 /* for writepage() only to communicate to fsync */
74 struct file_operations *ll_save_ifop;
75 struct file_operations *ll_save_ffop;
76 struct file_operations *ll_save_wfop;
77 struct file_operations *ll_save_wrfop;
78 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
79 struct inode lli_vfs_inode;
83 // FIXME: replace the name of this with LL_I to conform to kernel stuff
84 // static inline struct ll_inode_info *LL_I(struct inode *inode)
85 static inline struct ll_inode_info *ll_i2info(struct inode *inode)
87 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
88 return container_of(inode, struct ll_inode_info, lli_vfs_inode);
90 return (struct ll_inode_info *)&(inode->u.generic_ip);
94 /* default to about 40meg of readahead on a given system. That much tied
95 * up in 512k readahead requests serviced at 40ms each is about 1GB/s. */
96 #define SBI_DEFAULT_READAHEAD_MAX (40UL << (20 - PAGE_CACHE_SHIFT))
100 RA_STAT_DISTANT_READPAGE,
101 RA_STAT_MISS_IN_WINDOW,
102 RA_STAT_FAILED_MATCH,
107 RA_STAT_MAX_IN_FLIGHT,
112 unsigned long ra_cur_pages;
113 unsigned long ra_max_pages;
114 unsigned long ra_stats[_NR_RA_STAT];
117 /* flags for sbi->ll_flags */
118 #define LL_SBI_NOLCK 0x1 /* DLM locking disabled (directio-only) */
119 #define LL_SBI_CHECKSUM 0x2 /* checksum each page as it's written */
122 struct list_head ll_list;
123 /* this protects pglist and ra_info. It isn't safe to
124 * grab from interrupt contexts */
126 struct obd_uuid ll_sb_uuid;
127 struct obd_export *ll_mdc_exp;
128 struct obd_export *ll_osc_exp;
129 struct proc_dir_entry* ll_proc_root;
130 obd_id ll_rootino; /* number of root inode */
132 struct lustre_mount_data *ll_lmd;
135 struct list_head ll_conn_chain; /* per-conn chain of SBs */
137 struct hlist_head ll_orphan_dentry_list; /*please don't ask -p*/
138 struct ll_close_queue *ll_lcq;
140 struct lprocfs_stats *ll_stats; /* lprocfs stats counter */
142 unsigned long ll_async_page_max;
143 unsigned long ll_async_page_count;
144 unsigned long ll_pglist_gen;
145 struct list_head ll_pglist; /* all pages (llap_pglist_item) */
147 struct ll_ra_info ll_ra_info;
148 unsigned int ll_namelen;
151 struct ll_readahead_state {
153 unsigned long ras_last_readpage, ras_consecutive;
154 unsigned long ras_window_start, ras_window_len;
155 unsigned long ras_next_readahead;
159 extern kmem_cache_t *ll_file_data_slab;
160 struct lustre_handle;
161 struct ll_file_data {
162 struct obd_client_handle fd_mds_och;
163 struct ll_readahead_state fd_ras;
167 struct lov_stripe_md;
169 extern spinlock_t inode_lock;
171 extern struct proc_dir_entry *proc_lustre_fs_root;
173 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
174 # define hlist_del_init list_del_init
177 static inline struct inode *ll_info2i(struct ll_inode_info *lli)
179 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
180 return &lli->lli_vfs_inode;
182 return list_entry(lli, struct inode, u.generic_ip);
186 static inline void ll_i2uctxt(struct ll_uctxt *ctxt, struct inode *i1,
192 if (in_group_p(i1->i_gid))
193 ctxt->gid1 = i1->i_gid;
198 if (in_group_p(i2->i_gid))
199 ctxt->gid2 = i2->i_gid;
207 struct inode *icbd_parent;
208 struct dentry **icbd_childp;
212 #define LLAP_MAGIC 98764321
214 extern kmem_cache_t *ll_async_page_slab;
215 extern size_t ll_async_page_slab_size;
216 struct ll_async_page {
218 /* only trust these if the page lock is providing exclusion */
219 unsigned int llap_write_queued:1,
220 llap_defer_uptodate:1,
224 struct page *llap_page;
225 struct list_head llap_pending_write;
226 struct list_head llap_pglist_item;
227 /* user credit information for oss enforcement quota */
228 struct lvfs_ucred llap_ouc;
229 /* checksum for paranoid I/O debugging */
234 LLAP_ORIGIN_UNKNOWN = 0,
235 LLAP_ORIGIN_READPAGE,
236 LLAP_ORIGIN_READAHEAD,
237 LLAP_ORIGIN_COMMIT_WRITE,
238 LLAP_ORIGIN_WRITEPAGE,
241 extern char *llap_origins[];
243 #ifdef HAVE_REGISTER_CACHE
244 #define ll_register_cache(cache) register_cache(cache)
245 #define ll_unregister_cache(cache) unregister_cache(cache)
247 #define ll_register_cache(cache) do {} while (0)
248 #define ll_unregister_cache(cache) do {} while (0)
251 /* llite/lproc_llite.c */
253 int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
254 struct super_block *sb, char *osc, char *mdc);
255 void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi);
257 static inline int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
258 struct super_block *sb, char *osc, char *mdc){return 0;}
259 static inline void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi) {}
264 extern struct file_operations ll_dir_operations;
265 extern struct inode_operations ll_dir_inode_operations;
268 int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir);
269 struct inode *ll_iget(struct super_block *sb, ino_t hash,
270 struct lustre_md *lic);
271 struct dentry *ll_find_alias(struct inode *, struct dentry *);
272 int ll_mdc_cancel_unused(struct lustre_handle *, struct inode *, int flags,
274 int ll_mdc_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *,
275 void *data, int flag);
276 void ll_prepare_mdc_op_data(struct mdc_op_data *,
277 struct inode *i1, struct inode *i2,
278 const char *name, int namelen, int mode);
281 int ll_prepare_write(struct file *, struct page *, unsigned from, unsigned to);
282 int ll_commit_write(struct file *, struct page *, unsigned from, unsigned to);
283 int ll_writepage(struct page *page);
284 void ll_inode_fill_obdo(struct inode *inode, int cmd, struct obdo *oa);
285 void ll_ap_completion(void *data, int cmd, struct obdo *oa, int rc);
286 int llap_shrink_cache(struct ll_sb_info *sbi, int shrink_fraction);
287 extern struct cache_definition ll_cache_definition;
288 void ll_removepage(struct page *page);
289 int ll_readpage(struct file *file, struct page *page);
290 struct ll_async_page *llap_from_cookie(void *cookie);
291 struct ll_async_page *llap_from_page(struct page *page, unsigned origin);
292 struct ll_async_page *llap_cast_private(struct page *page);
293 void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras);
294 void ll_ra_accounting(struct page *page, struct address_space *mapping);
295 void ll_truncate(struct inode *inode);
298 extern struct file_operations ll_file_operations;
299 extern struct inode_operations ll_file_inode_operations;
300 extern int ll_inode_revalidate_it(struct dentry *, struct lookup_intent *);
301 int ll_extent_lock(struct ll_file_data *, struct inode *,
302 struct lov_stripe_md *, int mode, ldlm_policy_data_t *,
303 struct lustre_handle *, int ast_flags);
304 int ll_extent_unlock(struct ll_file_data *, struct inode *,
305 struct lov_stripe_md *, int mode, struct lustre_handle *);
306 int ll_file_open(struct inode *inode, struct file *file);
307 int ll_file_release(struct inode *inode, struct file *file);
308 int ll_lsm_getattr(struct obd_export *, struct lov_stripe_md *, struct obdo *);
309 int ll_glimpse_size(struct inode *inode);
310 int ll_local_open(struct file *file, struct lookup_intent *it);
311 int ll_mdc_close(struct obd_export *mdc_exp, struct inode *inode,
313 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
314 int ll_getattr(struct vfsmount *mnt, struct dentry *de,
315 struct lookup_intent *it, struct kstat *stat);
319 void ll_intent_drop_lock(struct lookup_intent *);
320 void ll_intent_release(struct lookup_intent *);
321 extern void ll_set_dd(struct dentry *de);
322 void ll_unhash_aliases(struct inode *);
323 void ll_frob_intent(struct lookup_intent **itp, struct lookup_intent *deft);
324 void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry);
326 /* llite/llite_lib.c */
328 extern struct super_operations lustre_super_operations;
330 char *ll_read_opt(const char *opt, char *data);
331 int ll_set_opt(const char *opt, char *data, int fl);
332 void ll_options(char *options, char **ost, char **mds, int *flags);
333 void ll_lli_init(struct ll_inode_info *lli);
334 int ll_fill_super(struct super_block *sb, void *data, int silent);
335 int lustre_fill_super(struct super_block *sb, void *data, int silent);
336 void lustre_put_super(struct super_block *sb);
337 struct inode *ll_inode_from_lock(struct ldlm_lock *lock);
338 void ll_clear_inode(struct inode *inode);
339 int ll_setattr_raw(struct inode *inode, struct iattr *attr);
340 int ll_setattr(struct dentry *de, struct iattr *attr);
341 int ll_statfs(struct super_block *sb, struct kstatfs *sfs);
342 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
343 unsigned long maxage);
344 void ll_update_inode(struct inode *inode, struct mds_body *body,
345 struct lov_stripe_md *lsm);
346 void ll_read_inode2(struct inode *inode, void *opaque);
347 int ll_iocontrol(struct inode *inode, struct file *file,
348 unsigned int cmd, unsigned long arg);
349 void ll_umount_begin(struct super_block *sb);
350 int lustre_remount_fs(struct super_block *sb, int *flags, char *data);
351 int ll_prep_inode(struct obd_export *exp, struct inode **inode,
352 struct ptlrpc_request *req, int offset, struct super_block *);
353 void lustre_dump_dentry(struct dentry *, int recur);
354 void lustre_dump_inode(struct inode *);
355 struct ll_async_page *llite_pglist_next_llap(struct ll_sb_info *sbi,
356 struct list_head *list);
358 /* llite/llite_nfs.c */
359 __u32 get_uuid2int(const char *name, int len);
360 struct dentry *ll_fh_to_dentry(struct super_block *sb, __u32 *data, int len,
361 int fhtype, int parent);
362 int ll_dentry_to_fh(struct dentry *, __u32 *datap, int *lenp, int need_parent);
364 /* llite/special.c */
365 extern struct inode_operations ll_special_inode_operations;
366 extern struct file_operations ll_special_chr_inode_fops;
367 extern struct file_operations ll_special_chr_file_fops;
368 extern struct file_operations ll_special_blk_inode_fops;
369 extern struct file_operations ll_special_fifo_inode_fops;
370 extern struct file_operations ll_special_fifo_file_fops;
371 extern struct file_operations ll_special_sock_inode_fops;
373 /* llite/symlink.c */
374 extern struct inode_operations ll_fast_symlink_inode_operations;
376 /* llite/llite_close.c */
377 struct ll_close_queue {
379 struct list_head lcq_list;
380 wait_queue_head_t lcq_waitq;
381 struct completion lcq_comp;
384 void llap_write_pending(struct inode *inode, struct ll_async_page *llap);
385 void llap_write_complete(struct inode *inode, struct ll_async_page *llap);
386 void ll_open_complete(struct inode *inode);
387 int ll_is_inode_dirty(struct inode *inode);
388 void ll_try_done_writing(struct inode *inode);
389 void ll_queue_done_writing(struct inode *inode);
390 void ll_close_thread_shutdown(struct ll_close_queue *lcq);
391 int ll_close_thread_start(struct ll_close_queue **lcq_ret);
393 /* llite/llite_mmap.c */
394 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
395 typedef struct rb_root rb_root_t;
396 typedef struct rb_node rb_node_t;
399 struct ll_lock_tree_node;
400 struct ll_lock_tree {
402 struct list_head lt_locked_list;
403 struct ll_file_data *lt_fd;
406 int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last);
407 int ll_file_mmap(struct file * file, struct vm_area_struct * vma);
408 struct ll_lock_tree_node * ll_node_from_inode(struct inode *inode, __u64 start,
409 __u64 end, ldlm_mode_t mode);
410 int ll_tree_lock(struct ll_lock_tree *tree,
411 struct ll_lock_tree_node *first_node,
412 const char *buf, size_t count, int ast_flags);
413 int ll_tree_unlock(struct ll_lock_tree *tree);
416 #define LL_MAX_BLKSIZE (4UL * 1024 * 1024)
418 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
419 #define ll_s2sbi(sb) ((struct ll_sb_info *)((sb)->s_fs_info))
420 #define ll_s2sbi_nocast(sb) ((sb)->s_fs_info)
421 void __d_rehash(struct dentry * entry, int lock);
422 static inline __u64 ll_ts2u64(struct timespec *time)
424 __u64 t = time->tv_sec;
428 #define ll_s2sbi(sb) ((struct ll_sb_info *)((sb)->u.generic_sbp))
429 #define ll_s2sbi_nocast(sb) ((sb)->u.generic_sbp)
430 static inline __u64 ll_ts2u64(time_t *time)
436 /* don't need an addref as the sb_info should be holding one */
437 static inline struct obd_export *ll_s2obdexp(struct super_block *sb)
439 return ll_s2sbi(sb)->ll_osc_exp;
442 /* don't need an addref as the sb_info should be holding one */
443 static inline struct obd_export *ll_s2mdcexp(struct super_block *sb)
445 return ll_s2sbi(sb)->ll_mdc_exp;
448 static inline struct client_obd *sbi2mdc(struct ll_sb_info *sbi)
450 struct obd_device *obd = sbi->ll_mdc_exp->exp_obd;
456 // FIXME: replace the name of this with LL_SB to conform to kernel stuff
457 static inline struct ll_sb_info *ll_i2sbi(struct inode *inode)
459 return ll_s2sbi(inode->i_sb);
462 static inline struct obd_export *ll_i2obdexp(struct inode *inode)
464 return ll_s2obdexp(inode->i_sb);
467 static inline struct obd_export *ll_i2mdcexp(struct inode *inode)
469 return ll_s2mdcexp(inode->i_sb);
472 static inline void ll_inode2fid(struct ll_fid *fid, struct inode *inode)
474 mdc_pack_fid(fid, inode->i_ino, inode->i_generation,
475 inode->i_mode & S_IFMT);
478 static inline int ll_mds_max_easize(struct super_block *sb)
480 return sbi2mdc(ll_s2sbi(sb))->cl_max_mds_easize;
483 static inline __u64 ll_file_maxbytes(struct inode *inode)
485 return ll_i2info(inode)->lli_maxbytes;
488 #endif /* LLITE_INTERNAL_H */