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/ext2_fs.h>
9 #ifdef CONFIG_FS_POSIX_ACL
10 # include <linux/fs.h>
12 # include <linux/xattr_acl.h>
14 #ifdef HAVE_LINUX_POSIX_ACL_XATTR_H
15 # include <linux/posix_acl_xattr.h>
19 #include <lustre_debug.h>
20 #include <lustre_ver.h>
21 #include <linux/lustre_version.h>
22 #include <lustre_disk.h> /* for s2sbi */
25 struct lustre_intent_data {
26 __u64 it_lock_handle[2];
32 /* If there is no FMODE_EXEC defined, make it to match nothing */
37 #define LL_IT2STR(it) ((it) ? ldlm_it2str((it)->it_op) : "0")
38 #define LUSTRE_FPRIVATE(file) ((file)->private_data)
40 #ifdef HAVE_VFS_INTENT_PATCHES
41 static inline struct lookup_intent *ll_nd2it(struct nameidata *nd)
43 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
51 struct ll_dentry_data {
54 struct obd_client_handle lld_cwd_och;
55 struct obd_client_handle lld_mnt_och;
56 #ifndef HAVE_VFS_INTENT_PATCHES
57 struct lookup_intent *lld_it;
61 #define ll_d2d(de) ((struct ll_dentry_data*) de->d_fsdata)
63 extern struct file_operations ll_pgcache_seq_fops;
65 #define LLI_INODE_MAGIC 0x111d0de5
66 #define LLI_INODE_DEAD 0xdeadd00d
67 #define LLI_F_HAVE_OST_SIZE_LOCK 0
68 #define LLI_F_HAVE_MDS_SIZE_LOCK 1
70 struct ll_inode_info {
72 struct semaphore lli_size_sem; /* protect open and change size */
73 void *lli_size_sem_owner;
74 struct semaphore lli_write_sem;
75 struct lov_stripe_md *lli_smd;
76 char *lli_symlink_name;
79 unsigned long lli_flags;
81 /* this lock protects s_d_w and p_w_ll and mmap_cnt */
83 #ifdef HAVE_CLOSE_THREAD
84 struct list_head lli_pending_write_llaps;
85 struct list_head lli_close_item;
86 int lli_send_done_writing;
88 atomic_t lli_mmap_cnt;
90 /* for writepage() only to communicate to fsync */
93 struct posix_acl *lli_posix_acl;
95 struct list_head lli_dead_list;
97 struct semaphore lli_och_sem; /* Protects access to och pointers
98 and their usage counters */
99 /* We need all three because every inode may be opened in different
101 struct obd_client_handle *lli_mds_read_och;
102 __u64 lli_open_fd_read_count;
103 struct obd_client_handle *lli_mds_write_och;
104 __u64 lli_open_fd_write_count;
105 struct obd_client_handle *lli_mds_exec_och;
106 __u64 lli_open_fd_exec_count;
108 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
109 struct inode lli_vfs_inode;
112 /* metadata stat-ahead */
113 pid_t lli_opendir_pid;
114 struct ll_statahead_info *lli_sai;
118 * Locking to guarantee consistency of non-atomic updates to long long i_size,
119 * consistency between file size and KMS, and consistency within
120 * ->lli_smd->lsm_oinfo[]'s.
122 * Implemented by ->lli_size_sem and ->lsm_sem, nested in that order.
125 void ll_inode_size_lock(struct inode *inode, int lock_lsm);
126 void ll_inode_size_unlock(struct inode *inode, int unlock_lsm);
128 // FIXME: replace the name of this with LL_I to conform to kernel stuff
129 // static inline struct ll_inode_info *LL_I(struct inode *inode)
130 static inline struct ll_inode_info *ll_i2info(struct inode *inode)
132 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
133 return container_of(inode, struct ll_inode_info, lli_vfs_inode);
135 CLASSERT(sizeof(inode->u) >= sizeof(struct ll_inode_info));
136 return (struct ll_inode_info *)&(inode->u.generic_ip);
140 /* default to about 40meg of readahead on a given system. That much tied
141 * up in 512k readahead requests serviced at 40ms each is about 1GB/s. */
142 #define SBI_DEFAULT_READAHEAD_MAX (40UL << (20 - CFS_PAGE_SHIFT))
144 /* default to read-ahead full files smaller than 2MB on the second read */
145 #define SBI_DEFAULT_READAHEAD_WHOLE_MAX (2UL << (20 - CFS_PAGE_SHIFT))
150 RA_STAT_DISTANT_READPAGE,
151 RA_STAT_MISS_IN_WINDOW,
152 RA_STAT_FAILED_GRAB_PAGE,
153 RA_STAT_FAILED_MATCH,
158 RA_STAT_MAX_IN_FLIGHT,
159 RA_STAT_WRONG_GRAB_PAGE,
164 unsigned long ra_cur_pages;
165 unsigned long ra_max_pages;
166 unsigned long ra_max_read_ahead_whole_pages;
167 unsigned long ra_stats[_NR_RA_STAT];
170 /* LL_HIST_MAX=32 causes an overflow */
171 #define LL_HIST_MAX 28
172 #define LL_HIST_START 12 /* buckets start at 2^12 = 4k */
173 #define LL_PROCESS_HIST_MAX 10
174 struct per_process_info {
176 struct obd_histogram pp_r_hist;
177 struct obd_histogram pp_w_hist;
180 /* pp_extents[LL_PROCESS_HIST_MAX] will hold the combined process info */
181 struct ll_rw_extents_info {
182 struct per_process_info pp_extents[LL_PROCESS_HIST_MAX + 1];
185 #define LL_OFFSET_HIST_MAX 100
186 struct ll_rw_process_info {
189 loff_t rw_range_start;
191 loff_t rw_last_file_pos;
193 size_t rw_smallest_extent;
194 size_t rw_largest_extent;
195 struct file *rw_last_file;
199 enum stats_track_type {
200 STATS_TRACK_ALL = 0, /* track all processes */
201 STATS_TRACK_PID, /* track process with this pid */
202 STATS_TRACK_PPID, /* track processes with this ppid */
203 STATS_TRACK_GID, /* track processes with this gid */
207 /* flags for sbi->ll_flags */
208 #define LL_SBI_NOLCK 0x01 /* DLM locking disabled (directio-only) */
209 #define LL_SBI_CHECKSUM 0x02 /* checksum each page as it's written */
210 #define LL_SBI_FLOCK 0x04
211 #define LL_SBI_USER_XATTR 0x08 /* support user xattr */
212 #define LL_SBI_ACL 0x10 /* support ACL */
213 #define LL_SBI_JOIN 0x20 /* support JOIN */
214 #define LL_SBI_LOCALFLOCK 0x40 /* Local flocks support by kernel */
217 struct list_head ll_list;
218 /* this protects pglist and ra_info. It isn't safe to
219 * grab from interrupt contexts */
221 spinlock_t ll_pp_extent_lock; /* Lock for pp_extent entries */
222 spinlock_t ll_process_lock; /* Lock for ll_rw_process_info */
223 struct obd_uuid ll_sb_uuid;
224 struct obd_export *ll_mdc_exp;
225 struct obd_export *ll_osc_exp;
226 struct proc_dir_entry *ll_proc_root;
227 obd_id ll_rootino; /* number of root inode */
230 struct list_head ll_conn_chain; /* per-conn chain of SBs */
231 struct lustre_client_ocd ll_lco;
233 struct list_head ll_orphan_dentry_list; /*please don't ask -p*/
234 struct ll_close_queue *ll_lcq;
236 struct lprocfs_stats *ll_stats; /* lprocfs stats counter */
238 unsigned long ll_async_page_max;
239 unsigned long ll_async_page_count;
240 unsigned long ll_pglist_gen;
241 struct list_head ll_pglist; /* all pages (llap_pglist_item) */
243 struct ll_ra_info ll_ra_info;
244 unsigned int ll_namelen;
245 struct file_operations *ll_fop;
247 #ifdef HAVE_EXPORT___IGET
248 struct list_head ll_deathrow; /* inodes to be destroyed (b1443) */
249 spinlock_t ll_deathrow_lock;
251 /* =0 - hold lock over whole read/write
252 * >0 - max. chunk to be read/written w/o lock re-acquiring */
253 unsigned long ll_max_rw_chunk;
256 struct ll_rw_extents_info ll_rw_extents_info;
257 int ll_extent_process_count;
258 struct ll_rw_process_info ll_rw_process_info[LL_PROCESS_HIST_MAX];
259 unsigned int ll_offset_process_count;
260 struct ll_rw_process_info ll_rw_offset_info[LL_OFFSET_HIST_MAX];
261 unsigned int ll_rw_offset_entry_count;
262 enum stats_track_type ll_stats_track_type;
263 int ll_stats_track_id;
265 dev_t ll_sdev_orig; /* save s_dev before assign for
268 /* metadata stat-ahead */
269 unsigned int ll_sa_count; /* current statahead RPCs */
270 unsigned int ll_sa_max; /* max statahead RPCs */
271 unsigned int ll_sa_wrong; /* statahead thread stopped for
273 unsigned int ll_sa_total; /* statahead thread started
275 unsigned long long ll_sa_blocked; /* ls count waiting for
277 unsigned long long ll_sa_cached; /* ls count got in cache */
280 #define LL_DEFAULT_MAX_RW_CHUNK (32 * 1024 * 1024)
285 struct task_struct *lrr_reader;
286 struct list_head lrr_linkage;
290 * per file-descriptor read-ahead data.
292 struct ll_readahead_state {
295 * index of the last page that read(2) needed and that wasn't in the
296 * cache. Used by ras_update() to detect seeks.
298 * XXX nikita: if access seeks into cached region, Lustre doesn't see
301 unsigned long ras_last_readpage;
303 * number of pages read after last read-ahead window reset. As window
304 * is reset on each seek, this is effectively a number of consecutive
305 * accesses. Maybe ->ras_accessed_in_window is better name.
307 * XXX nikita: window is also reset (by ras_update()) when Lustre
308 * believes that memory pressure evicts read-ahead pages. In that
309 * case, it probably doesn't make sense to expand window to
310 * PTLRPC_MAX_BRW_PAGES on the third access.
312 unsigned long ras_consecutive_pages;
314 * number of read requests after the last read-ahead window reset
315 * As window is reset on each seek, this is effectively the number
316 * on consecutive read request and is used to trigger read-ahead.
318 unsigned long ras_consecutive_requests;
320 * Parameters of current read-ahead window. Handled by
321 * ras_update(). On the initial access to the file or after a seek,
322 * window is reset to 0. After 3 consecutive accesses, window is
323 * expanded to PTLRPC_MAX_BRW_PAGES. Afterwards, window is enlarged by
324 * PTLRPC_MAX_BRW_PAGES chunks up to ->ra_max_pages.
326 unsigned long ras_window_start, ras_window_len;
328 * Where next read-ahead should start at. This lies within read-ahead
329 * window. Read-ahead window is read in pieces rather than at once
330 * because: 1. lustre limits total number of pages under read-ahead by
331 * ->ra_max_pages (see ll_ra_count_get()), 2. client cannot read pages
332 * not covered by DLM lock.
334 unsigned long ras_next_readahead;
336 * Total number of ll_file_read requests issued, reads originating
337 * due to mmap are not counted in this total. This value is used to
338 * trigger full file read-ahead after multiple reads to a small file.
340 unsigned long ras_requests;
342 * Page index with respect to the current request, these value
343 * will not be accurate when dealing with reads issued via mmap.
345 unsigned long ras_request_index;
347 * list of struct ll_ra_read's one per read(2) call current in
348 * progress against this file descriptor. Used by read-ahead code,
349 * protected by ->ras_lock.
351 struct list_head ras_read_beads;
354 extern cfs_mem_cache_t *ll_file_data_slab;
355 struct lustre_handle;
356 struct ll_file_data {
357 struct ll_readahead_state fd_ras;
359 struct lustre_handle fd_cwlockh;
360 unsigned long fd_gid;
364 struct lov_stripe_md;
366 extern spinlock_t inode_lock;
368 extern struct proc_dir_entry *proc_lustre_fs_root;
370 static inline struct inode *ll_info2i(struct ll_inode_info *lli)
372 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
373 return &lli->lli_vfs_inode;
375 return list_entry(lli, struct inode, u.generic_ip);
380 struct inode *icbd_parent;
381 struct dentry **icbd_childp;
385 void ll_i2gids(__u32 *suppgids, struct inode *i1,struct inode *i2);
387 #define LLAP_MAGIC 98764321
389 extern cfs_mem_cache_t *ll_async_page_slab;
390 extern size_t ll_async_page_slab_size;
391 struct ll_async_page {
393 /* only trust these if the page lock is providing exclusion */
394 unsigned int llap_write_queued:1,
395 llap_defer_uptodate:1,
400 struct page *llap_page;
401 struct list_head llap_pending_write;
402 struct list_head llap_pglist_item;
403 /* checksum for paranoid I/O debugging */
408 * enumeration of llap_from_page() call-sites. Used to export statistics in
409 * /proc/fs/lustre/llite/fsN/dump_page_cache.
412 LLAP_ORIGIN_UNKNOWN = 0,
413 LLAP_ORIGIN_READPAGE,
414 LLAP_ORIGIN_READAHEAD,
415 LLAP_ORIGIN_COMMIT_WRITE,
416 LLAP_ORIGIN_WRITEPAGE,
417 LLAP_ORIGIN_REMOVEPAGE,
420 extern char *llap_origins[];
422 #ifdef HAVE_REGISTER_CACHE
423 #define ll_register_cache(cache) register_cache(cache)
424 #define ll_unregister_cache(cache) unregister_cache(cache)
426 #define ll_register_cache(cache) do {} while (0)
427 #define ll_unregister_cache(cache) do {} while (0)
430 void ll_ra_read_in(struct file *f, struct ll_ra_read *rar);
431 void ll_ra_read_ex(struct file *f, struct ll_ra_read *rar);
432 struct ll_ra_read *ll_ra_read_get(struct file *f);
434 /* llite/lproc_llite.c */
436 int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
437 struct super_block *sb, char *osc, char *mdc);
438 void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi);
439 void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count);
441 static inline int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
442 struct super_block *sb, char *osc, char *mdc){return 0;}
443 static inline void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi) {}
444 static void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) {}
449 extern struct file_operations ll_dir_operations;
450 extern struct inode_operations ll_dir_inode_operations;
452 struct page *ll_get_dir_page(struct inode *dir, unsigned long n);
454 * p is at least 6 bytes before the end of page
456 typedef struct ext2_dir_entry_2 ext2_dirent;
458 static inline ext2_dirent *ext2_next_entry(ext2_dirent *p)
460 return (ext2_dirent *)((char*)p + le16_to_cpu(p->rec_len));
463 static inline unsigned
464 ext2_validate_entry(char *base, unsigned offset, unsigned mask)
466 ext2_dirent *de = (ext2_dirent*)(base + offset);
467 ext2_dirent *p = (ext2_dirent*)(base + (offset&mask));
468 while ((char*)p < (char*)de)
469 p = ext2_next_entry(p);
470 return (char *)p - base;
473 static inline void ext2_put_page(struct page *page)
476 page_cache_release(page);
479 static inline unsigned long dir_pages(struct inode *inode)
481 return (inode->i_size + CFS_PAGE_SIZE - 1) >> CFS_PAGE_SHIFT;
485 int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir);
486 struct inode *ll_iget(struct super_block *sb, ino_t hash,
487 struct lustre_md *lic);
488 int ll_mdc_cancel_unused(struct lustre_handle *, struct inode *, int flags,
490 int ll_mdc_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *,
491 void *data, int flag);
492 int ll_prepare_mdc_op_data(struct mdc_op_data *,
493 struct inode *i1, struct inode *i2,
494 const char *name, int namelen, int mode, void *data);
495 #ifndef HAVE_VFS_INTENT_PATCHES
496 struct lookup_intent *ll_convert_intent(struct open_intent *oit,
499 int lookup_it_finish(struct ptlrpc_request *request, int offset,
500 struct lookup_intent *it, void *data);
501 void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry);
504 int ll_prepare_write(struct file *, struct page *, unsigned from, unsigned to);
505 int ll_commit_write(struct file *, struct page *, unsigned from, unsigned to);
506 int ll_writepage(struct page *page);
507 void ll_inode_fill_obdo(struct inode *inode, int cmd, struct obdo *oa);
508 int ll_ap_completion(void *data, int cmd, struct obdo *oa, int rc);
509 int llap_shrink_cache(struct ll_sb_info *sbi, int shrink_fraction);
510 extern struct cache_definition ll_cache_definition;
511 void ll_removepage(struct page *page);
512 int ll_readpage(struct file *file, struct page *page);
513 struct ll_async_page *llap_cast_private(struct page *page);
514 void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras);
515 void ll_ra_accounting(struct ll_async_page *llap,struct address_space *mapping);
516 void ll_truncate(struct inode *inode);
517 int ll_sync_page_range(struct inode *, struct address_space *, loff_t, size_t);
520 extern struct file_operations ll_file_operations;
521 extern struct file_operations ll_file_operations_flock;
522 extern struct file_operations ll_file_operations_noflock;
523 extern struct inode_operations ll_file_inode_operations;
524 extern int ll_inode_revalidate_it(struct dentry *, struct lookup_intent *);
525 extern int ll_have_md_lock(struct inode *inode, __u64 bits);
526 int ll_extent_lock(struct ll_file_data *, struct inode *,
527 struct lov_stripe_md *, int mode, ldlm_policy_data_t *,
528 struct lustre_handle *, int ast_flags);
529 int ll_extent_unlock(struct ll_file_data *, struct inode *,
530 struct lov_stripe_md *, int mode, struct lustre_handle *);
531 int ll_file_open(struct inode *inode, struct file *file);
532 int ll_file_release(struct inode *inode, struct file *file);
533 int ll_lsm_getattr(struct obd_export *, struct lov_stripe_md *, struct obdo *);
534 int ll_glimpse_ioctl(struct ll_sb_info *sbi,
535 struct lov_stripe_md *lsm, lstat_t *st);
536 int ll_glimpse_size(struct inode *inode, int ast_flags);
537 int ll_local_open(struct file *file,
538 struct lookup_intent *it, struct ll_file_data *fd,
539 struct obd_client_handle *och);
540 int ll_release_openhandle(struct dentry *, struct lookup_intent *);
541 int ll_mdc_close(struct obd_export *mdc_exp, struct inode *inode,
543 int ll_mdc_real_close(struct inode *inode, int flags);
544 extern void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, struct file
545 *file, size_t count, int rw);
546 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
547 int ll_getattr_it(struct vfsmount *mnt, struct dentry *de,
548 struct lookup_intent *it, struct kstat *stat);
549 int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat);
551 struct ll_file_data *ll_file_data_get(void);
552 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
553 int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd);
555 int ll_inode_permission(struct inode *inode, int mask);
557 int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
558 int flags, struct lov_user_md *lum,
560 int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename,
561 struct lov_mds_md **lmm, int *lmm_size,
562 struct ptlrpc_request **request);
563 int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump);
564 int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmm,
565 int *lmm_size, struct ptlrpc_request **request);
568 void ll_intent_drop_lock(struct lookup_intent *);
569 void ll_intent_release(struct lookup_intent *);
570 extern void ll_set_dd(struct dentry *de);
571 int ll_drop_dentry(struct dentry *dentry);
572 void ll_unhash_aliases(struct inode *);
573 void ll_frob_intent(struct lookup_intent **itp, struct lookup_intent *deft);
574 void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry);
575 int ll_dcompare(struct dentry *parent, struct qstr *d_name, struct qstr *name);
576 int revalidate_it_finish(struct ptlrpc_request *request, int offset,
577 struct lookup_intent *it, struct dentry *de);
579 /* llite/llite_lib.c */
580 extern struct super_operations lustre_super_operations;
582 char *ll_read_opt(const char *opt, char *data);
583 void ll_lli_init(struct ll_inode_info *lli);
584 int ll_fill_super(struct super_block *sb);
585 void ll_put_super(struct super_block *sb);
586 struct inode *ll_inode_from_lock(struct ldlm_lock *lock);
587 void ll_clear_inode(struct inode *inode);
588 int ll_setattr_raw(struct inode *inode, struct iattr *attr);
589 int ll_setattr(struct dentry *de, struct iattr *attr);
590 #ifndef HAVE_STATFS_DENTRY_PARAM
591 int ll_statfs(struct super_block *sb, struct kstatfs *sfs);
593 int ll_statfs(struct dentry *de, struct kstatfs *sfs);
595 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
597 void ll_update_inode(struct inode *inode, struct lustre_md *md);
598 void ll_read_inode2(struct inode *inode, void *opaque);
599 int ll_iocontrol(struct inode *inode, struct file *file,
600 unsigned int cmd, unsigned long arg);
601 #ifdef HAVE_UMOUNTBEGIN_VFSMOUNT
602 void ll_umount_begin(struct vfsmount *vfsmnt, int flags);
604 void ll_umount_begin(struct super_block *sb);
606 int ll_remount_fs(struct super_block *sb, int *flags, char *data);
607 int ll_prep_inode(struct obd_export *exp, struct inode **inode,
608 struct ptlrpc_request *req, int offset, struct super_block *);
609 void lustre_dump_dentry(struct dentry *, int recur);
610 void lustre_dump_inode(struct inode *);
611 struct ll_async_page *llite_pglist_next_llap(struct ll_sb_info *sbi,
612 struct list_head *list);
613 int ll_obd_statfs(struct inode *inode, void *arg);
614 int ll_get_max_mdsize(struct ll_sb_info *sbi, int *max_mdsize);
615 int ll_process_config(struct lustre_cfg *lcfg);
617 /* llite/llite_nfs.c */
618 extern struct export_operations lustre_export_operations;
619 __u32 get_uuid2int(const char *name, int len);
620 struct dentry *ll_fh_to_dentry(struct super_block *sb, __u32 *data, int len,
621 int fhtype, int parent);
622 int ll_dentry_to_fh(struct dentry *, __u32 *datap, int *lenp, int need_parent);
624 /* llite/special.c */
625 extern struct inode_operations ll_special_inode_operations;
626 extern struct file_operations ll_special_chr_inode_fops;
627 extern struct file_operations ll_special_chr_file_fops;
628 extern struct file_operations ll_special_blk_inode_fops;
629 extern struct file_operations ll_special_fifo_inode_fops;
630 extern struct file_operations ll_special_fifo_file_fops;
631 extern struct file_operations ll_special_sock_inode_fops;
633 /* llite/symlink.c */
634 extern struct inode_operations ll_fast_symlink_inode_operations;
636 /* llite/llite_close.c */
637 struct ll_close_queue {
639 struct list_head lcq_list;
640 wait_queue_head_t lcq_waitq;
641 struct completion lcq_comp;
644 #ifdef HAVE_CLOSE_THREAD
645 void llap_write_pending(struct inode *inode, struct ll_async_page *llap);
646 void llap_write_complete(struct inode *inode, struct ll_async_page *llap);
647 void ll_open_complete(struct inode *inode);
648 int ll_is_inode_dirty(struct inode *inode);
649 void ll_try_done_writing(struct inode *inode);
650 void ll_queue_done_writing(struct inode *inode);
652 static inline void llap_write_pending(struct inode *inode,
653 struct ll_async_page *llap) { return; };
654 static inline void llap_write_complete(struct inode *inode,
655 struct ll_async_page *llap) { return; };
656 static inline void ll_open_complete(struct inode *inode) { return; };
657 static inline int ll_is_inode_dirty(struct inode *inode) { return 0; };
658 static inline void ll_try_done_writing(struct inode *inode) { return; };
659 static inline void ll_queue_done_writing(struct inode *inode) { return; };
660 //static inline void ll_close_thread_shutdown(struct ll_close_queue *lcq) { return; };
661 //static inline int ll_close_thread_start(struct ll_close_queue **lcq_ret) { return 0; };
663 void ll_close_thread_shutdown(struct ll_close_queue *lcq);
664 int ll_close_thread_start(struct ll_close_queue **lcq_ret);
666 /* llite/llite_mmap.c */
667 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
668 typedef struct rb_root rb_root_t;
669 typedef struct rb_node rb_node_t;
672 struct ll_lock_tree_node;
673 struct ll_lock_tree {
675 struct list_head lt_locked_list;
676 struct ll_file_data *lt_fd;
679 int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last);
680 int ll_file_mmap(struct file * file, struct vm_area_struct * vma);
681 struct ll_lock_tree_node * ll_node_from_inode(struct inode *inode, __u64 start,
682 __u64 end, ldlm_mode_t mode);
683 int ll_tree_lock(struct ll_lock_tree *tree,
684 struct ll_lock_tree_node *first_node,
685 const char *buf, size_t count, int ast_flags);
686 int ll_tree_unlock(struct ll_lock_tree *tree);
688 #define ll_s2sbi(sb) (s2lsi(sb)->lsi_llsbi)
690 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
691 void __d_rehash(struct dentry * entry, int lock);
692 static inline __u64 ll_ts2u64(struct timespec *time)
694 __u64 t = time->tv_sec;
698 static inline __u64 ll_ts2u64(time_t *time)
704 /* don't need an addref as the sb_info should be holding one */
705 static inline struct obd_export *ll_s2obdexp(struct super_block *sb)
707 return ll_s2sbi(sb)->ll_osc_exp;
710 /* don't need an addref as the sb_info should be holding one */
711 static inline struct obd_export *ll_s2mdcexp(struct super_block *sb)
713 return ll_s2sbi(sb)->ll_mdc_exp;
716 static inline struct client_obd *sbi2mdc(struct ll_sb_info *sbi)
718 struct obd_device *obd = sbi->ll_mdc_exp->exp_obd;
724 // FIXME: replace the name of this with LL_SB to conform to kernel stuff
725 static inline struct ll_sb_info *ll_i2sbi(struct inode *inode)
727 return ll_s2sbi(inode->i_sb);
730 static inline struct obd_export *ll_i2obdexp(struct inode *inode)
732 return ll_s2obdexp(inode->i_sb);
735 static inline struct obd_export *ll_i2mdcexp(struct inode *inode)
737 return ll_s2mdcexp(inode->i_sb);
740 static inline void ll_inode2fid(struct ll_fid *fid, struct inode *inode)
742 mdc_pack_fid(fid, inode->i_ino, inode->i_generation,
743 inode->i_mode & S_IFMT);
746 static inline int ll_mds_max_easize(struct super_block *sb)
748 return sbi2mdc(ll_s2sbi(sb))->cl_max_mds_easize;
751 static inline __u64 ll_file_maxbytes(struct inode *inode)
753 return ll_i2info(inode)->lli_maxbytes;
757 int ll_setxattr(struct dentry *dentry, const char *name,
758 const void *value, size_t size, int flags);
759 ssize_t ll_getxattr(struct dentry *dentry, const char *name,
760 void *buffer, size_t size);
761 ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size);
762 int ll_removexattr(struct dentry *dentry, const char *name);
766 #define LL_STATAHEAD_MIN 1
767 #define LL_STATAHEAD_DEF 32
768 #define LL_STATAHEAD_MAX 10000
770 /* per inode struct, for dir only */
771 struct ll_statahead_info {
772 struct inode *sai_inode;
773 atomic_t sai_refc; /* when access this struct, hold
775 unsigned int sai_max; /* max ahead of lookup */
776 unsigned int sai_sent; /* stat requests sent count */
777 unsigned int sai_replied; /* stat requests which received
779 unsigned int sai_cached; /* UPDATE lock cached locally
781 unsigned int sai_hit; /* hit count */
782 unsigned int sai_miss; /* miss count */
783 unsigned int sai_consecutive_miss; /* consecutive miss */
784 unsigned sai_ls_all:1; /* ls -al, do stat-ahead for
786 struct ptlrpc_thread sai_thread; /* stat-ahead thread */
787 struct list_head sai_entries; /* stat-ahead entries */
788 unsigned int sai_entries_nr; /* stat-ahead entries count */
791 int ll_statahead_enter(struct inode *dir, struct dentry **dentry, int lookup);
792 void ll_statahead_exit(struct dentry *dentry, int result);
793 void ll_stop_statahead(struct inode *inode);
795 #endif /* LLITE_INTERNAL_H */