Whamcloud - gitweb
land b1_5 onto HEAD
[fs/lustre-release.git] / lustre / llite / llite_internal.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  */
4
5 #ifndef LLITE_INTERNAL_H
6 #define LLITE_INTERNAL_H
7
8 #ifdef CONFIG_FS_POSIX_ACL
9 # include <linux/fs.h>
10 #ifdef HAVE_XATTR_ACL
11 # include <linux/xattr_acl.h>
12 #endif
13 #ifdef HAVE_LINUX_POSIX_ACL_XATTR_H
14 # include <linux/posix_acl_xattr.h>
15 #endif
16 #endif
17
18 #include <lustre_debug.h>
19 #include <lustre_ver.h>
20 #include <linux/lustre_version.h>
21 #include <lustre_disk.h>  /* for s2sbi */
22  
23 /*
24 struct lustre_intent_data {
25         __u64 it_lock_handle[2];
26         __u32 it_disposition;
27         __u32 it_status;
28         __u32 it_lock_mode;
29         }; */
30
31 /* If there is no FMODE_EXEC defined, make it to match nothing */
32 #ifndef FMODE_EXEC
33 #define FMODE_EXEC 0
34 #endif
35
36 #define LL_IT2STR(it) ((it) ? ldlm_it2str((it)->it_op) : "0")
37 #define LUSTRE_FPRIVATE(file) ((file)->private_data)
38
39 #ifdef LUSTRE_KERNEL_VERSION
40 static inline struct lookup_intent *ll_nd2it(struct nameidata *nd)
41 {
42 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
43         return &nd->intent;
44 #else
45         return nd->intent;
46 #endif
47 }
48 #endif
49
50 struct ll_dentry_data {
51         int                      lld_cwd_count;
52         int                      lld_mnt_count;
53         struct obd_client_handle lld_cwd_och;
54         struct obd_client_handle lld_mnt_och;
55 #ifndef LUSTRE_KERNEL_VERSION
56         struct lookup_intent     *lld_it;
57 #endif
58 };
59
60 #define ll_d2d(de) ((struct ll_dentry_data*) de->d_fsdata)
61
62 extern struct file_operations ll_pgcache_seq_fops;
63
64 #define LLI_INODE_MAGIC                 0x111d0de5
65 #define LLI_INODE_DEAD                  0xdeadd00d
66 #define LLI_F_HAVE_OST_SIZE_LOCK        0
67 #define LLI_F_HAVE_MDS_SIZE_LOCK        1
68
69 struct ll_inode_info {
70         int                     lli_inode_magic;
71         struct semaphore        lli_size_sem;
72         void                   *lli_size_sem_owner;
73         struct semaphore        lli_open_sem;
74         struct semaphore        lli_write_sem;
75         struct lov_stripe_md   *lli_smd;
76         char                   *lli_symlink_name;
77         __u64                   lli_maxbytes;
78         __u64                   lli_io_epoch;
79         unsigned long           lli_flags;
80
81         /* this lock protects s_d_w and p_w_ll and mmap_cnt */
82         spinlock_t              lli_lock;
83         struct list_head        lli_pending_write_llaps;
84         int                     lli_send_done_writing;
85         atomic_t                lli_mmap_cnt;
86
87         struct list_head        lli_close_item;
88
89         /* for writepage() only to communicate to fsync */
90         int                     lli_async_rc;
91
92         struct posix_acl       *lli_posix_acl;
93
94         struct list_head        lli_dead_list;
95
96         struct semaphore        lli_och_sem; /* Protects access to och pointers
97                                                 and their usage counters */
98         /* We need all three because every inode may be opened in different
99            modes */
100         struct obd_client_handle *lli_mds_read_och;
101         __u64                   lli_open_fd_read_count;
102         struct obd_client_handle *lli_mds_write_och;
103         __u64                   lli_open_fd_write_count;
104         struct obd_client_handle *lli_mds_exec_och;
105         __u64                   lli_open_fd_exec_count;
106
107 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
108         struct inode            lli_vfs_inode;
109 #endif
110 };
111
112 /*
113  * Locking to guarantee consistency of non-atomic updates to long long i_size,
114  * consistency between file size and KMS, and consistency within
115  * ->lli_smd->lsm_oinfo[]'s.
116  *
117  * Implemented by ->lli_size_sem and ->lsm_sem, nested in that order.
118  */
119
120 void ll_inode_size_lock(struct inode *inode, int lock_lsm);
121 void ll_inode_size_unlock(struct inode *inode, int unlock_lsm);
122
123 // FIXME: replace the name of this with LL_I to conform to kernel stuff
124 // static inline struct ll_inode_info *LL_I(struct inode *inode)
125 static inline struct ll_inode_info *ll_i2info(struct inode *inode)
126 {
127 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
128         return container_of(inode, struct ll_inode_info, lli_vfs_inode);
129 #else
130         return (struct ll_inode_info *)&(inode->u.generic_ip);
131 #endif
132 }
133
134 /* default to about 40meg of readahead on a given system.  That much tied
135  * up in 512k readahead requests serviced at 40ms each is about 1GB/s. */
136 #define SBI_DEFAULT_READAHEAD_MAX (40UL << (20 - CFS_PAGE_SHIFT))
137
138 /* default to read-ahead full files smaller than 2MB on the second read */
139 #define SBI_DEFAULT_READAHEAD_WHOLE_MAX (2UL << (20 - CFS_PAGE_SHIFT))
140
141 enum ra_stat {
142         RA_STAT_HIT = 0,
143         RA_STAT_MISS,
144         RA_STAT_DISTANT_READPAGE,
145         RA_STAT_MISS_IN_WINDOW,
146         RA_STAT_FAILED_GRAB_PAGE,
147         RA_STAT_FAILED_MATCH,
148         RA_STAT_DISCARDED,
149         RA_STAT_ZERO_LEN,
150         RA_STAT_ZERO_WINDOW,
151         RA_STAT_EOF,
152         RA_STAT_MAX_IN_FLIGHT,
153         RA_STAT_WRONG_GRAB_PAGE,
154         _NR_RA_STAT,
155 };
156
157 struct ll_ra_info {
158         unsigned long             ra_cur_pages;
159         unsigned long             ra_max_pages;
160         unsigned long             ra_max_read_ahead_whole_pages;
161         unsigned long             ra_stats[_NR_RA_STAT];
162 };
163
164 /* LL_HIST_MAX=32 causes an overflow */
165 #define LL_HIST_MAX 28
166 #define LL_HIST_START 12 /* buckets start at 2^12 = 4k */
167 #define LL_PROCESS_HIST_MAX 10
168 struct per_process_info {
169         pid_t pid;
170         struct obd_histogram pp_r_hist;
171         struct obd_histogram pp_w_hist;
172 };
173
174 /* pp_extents[LL_PROCESS_HIST_MAX] will hold the combined process info */
175 struct ll_rw_extents_info {
176         struct per_process_info pp_extents[LL_PROCESS_HIST_MAX + 1];
177 };
178
179 #define LL_OFFSET_HIST_MAX 100
180 struct ll_rw_process_info {
181         pid_t                     rw_pid;
182         int                       rw_op;
183         loff_t                    rw_range_start;
184         loff_t                    rw_range_end;
185         loff_t                    rw_last_file_pos;
186         loff_t                    rw_offset;
187         size_t                    rw_smallest_extent;
188         size_t                    rw_largest_extent;
189         struct file               *rw_last_file;
190 };
191
192 enum vfs_ops_list {
193         VFS_OPS_READ = 0,
194         VFS_OPS_WRITE,
195         VFS_OPS_IOCTL,
196         VFS_OPS_OPEN,
197         VFS_OPS_RELEASE,
198         VFS_OPS_MMAP,
199         VFS_OPS_SEEK,
200         VFS_OPS_FSYNC,
201         VFS_OPS_FLOCK,
202         VFS_OPS_SETATTR,
203         VFS_OPS_GETATTR,
204         VFS_OPS_SETXATTR,
205         VFS_OPS_GETXATTR,
206         VFS_OPS_LISTXATTR,
207         VFS_OPS_REMOVEXATTR,
208         VFS_OPS_TRUNCATE,
209         VFS_OPS_INODE_PERMISSION,
210         VFS_OPS_LAST,
211 };
212
213 enum vfs_track_type {
214         VFS_TRACK_ALL = 0,  /* track all processes */
215         VFS_TRACK_PID,      /* track process with this pid */
216         VFS_TRACK_PPID,     /* track processes with this ppid */
217         VFS_TRACK_GID,      /* track processes with this gid */
218         VFS_TRACK_LAST,
219 };
220
221 /* flags for sbi->ll_flags */
222 #define LL_SBI_NOLCK            0x01 /* DLM locking disabled (directio-only) */
223 #define LL_SBI_CHECKSUM         0x02 /* checksum each page as it's written */
224 #define LL_SBI_FLOCK            0x04
225 #define LL_SBI_USER_XATTR       0x08 /* support user xattr */
226 #define LL_SBI_ACL              0x10 /* support ACL */
227 #define LL_SBI_JOIN             0x20 /* support JOIN */
228
229 struct ll_sb_info {
230         struct list_head          ll_list;
231         /* this protects pglist and ra_info.  It isn't safe to
232          * grab from interrupt contexts */
233         spinlock_t                ll_lock;
234         struct obd_uuid           ll_sb_uuid;
235         struct obd_export        *ll_mdc_exp;
236         struct obd_export        *ll_osc_exp;
237         struct proc_dir_entry    *ll_proc_root;
238         obd_id                    ll_rootino; /* number of root inode */
239
240         int                       ll_flags;
241         struct list_head          ll_conn_chain; /* per-conn chain of SBs */
242         struct lustre_client_ocd  ll_lco;
243
244         struct list_head          ll_orphan_dentry_list; /*please don't ask -p*/
245         struct ll_close_queue    *ll_lcq;
246
247         struct lprocfs_stats     *ll_stats; /* lprocfs stats counter */
248
249         unsigned long             ll_async_page_max;
250         unsigned long             ll_async_page_count;
251         unsigned long             ll_pglist_gen;
252         struct list_head          ll_pglist; /* all pages (llap_pglist_item) */
253
254         struct ll_ra_info         ll_ra_info;
255         unsigned int              ll_namelen;
256         struct file_operations   *ll_fop;
257
258         struct list_head          ll_deathrow; /* inodes to be destroyed (b1443) */
259         spinlock_t                ll_deathrow_lock;
260         /* =0 - hold lock over whole read/write
261          * >0 - max. chunk to be read/written w/o lock re-acquiring */
262         unsigned long             ll_max_rw_chunk;
263
264         /* Statistics */
265         struct ll_rw_extents_info ll_rw_extents_info;
266         int                       ll_extent_process_count;
267         struct ll_rw_process_info ll_rw_process_info[LL_PROCESS_HIST_MAX];
268         unsigned int              ll_offset_process_count;
269         struct ll_rw_process_info ll_rw_offset_info[LL_OFFSET_HIST_MAX];
270         unsigned int              ll_rw_offset_entry_count;
271         struct lprocfs_stats     *ll_vfs_ops_stats;
272         enum vfs_track_type       ll_vfs_track_type;
273         int                       ll_vfs_track_id;
274 };
275
276 #define LL_DEFAULT_MAX_RW_CHUNK         (32 * 1024 * 1024)
277
278 struct ll_ra_read {
279         pgoff_t             lrr_start;
280         pgoff_t             lrr_count;
281         struct task_struct *lrr_reader;
282         struct list_head    lrr_linkage;
283 };
284
285 /*
286  * per file-descriptor read-ahead data.
287  */
288 struct ll_readahead_state {
289         spinlock_t      ras_lock;
290         /*
291          * index of the last page that read(2) needed and that wasn't in the
292          * cache. Used by ras_update() to detect seeks.
293          *
294          * XXX nikita: if access seeks into cached region, Lustre doesn't see
295          * this.
296          */
297         unsigned long   ras_last_readpage;
298         /*
299          * number of pages read after last read-ahead window reset. As window
300          * is reset on each seek, this is effectively a number of consecutive
301          * accesses. Maybe ->ras_accessed_in_window is better name.
302          *
303          * XXX nikita: window is also reset (by ras_update()) when Lustre
304          * believes that memory pressure evicts read-ahead pages. In that
305          * case, it probably doesn't make sense to expand window to
306          * PTLRPC_MAX_BRW_PAGES on the third access.
307          */
308         unsigned long   ras_consecutive_pages;
309         /*
310          * number of read requests after the last read-ahead window reset
311          * As window is reset on each seek, this is effectively the number 
312          * on consecutive read request and is used to trigger read-ahead.
313          */
314         unsigned long   ras_consecutive_requests;
315         /*
316          * Parameters of current read-ahead window. Handled by
317          * ras_update(). On the initial access to the file or after a seek,
318          * window is reset to 0. After 3 consecutive accesses, window is
319          * expanded to PTLRPC_MAX_BRW_PAGES. Afterwards, window is enlarged by
320          * PTLRPC_MAX_BRW_PAGES chunks up to ->ra_max_pages.
321          */
322         unsigned long   ras_window_start, ras_window_len;
323         /*
324          * Where next read-ahead should start at. This lies within read-ahead
325          * window. Read-ahead window is read in pieces rather than at once
326          * because: 1. lustre limits total number of pages under read-ahead by
327          * ->ra_max_pages (see ll_ra_count_get()), 2. client cannot read pages
328          * not covered by DLM lock.
329          */
330         unsigned long   ras_next_readahead;
331         /*
332          * Total number of ll_file_read requests issued, reads originating
333          * due to mmap are not counted in this total.  This value is used to
334          * trigger full file read-ahead after multiple reads to a small file.
335          */
336         unsigned long   ras_requests;
337         /*
338          * Page index with respect to the current request, these value 
339          * will not be accurate when dealing with reads issued via mmap.
340          */
341         unsigned long   ras_request_index;
342         /*
343          * list of struct ll_ra_read's one per read(2) call current in
344          * progress against this file descriptor. Used by read-ahead code,
345          * protected by ->ras_lock.
346          */
347         struct list_head ras_read_beads;
348 };
349
350 extern kmem_cache_t *ll_file_data_slab;
351 struct lustre_handle;
352 struct ll_file_data {
353         struct ll_readahead_state fd_ras;
354         int fd_omode;
355         struct lustre_handle fd_cwlockh;
356         unsigned long fd_gid;
357         __u32 fd_flags;
358 };
359
360 struct lov_stripe_md;
361
362 extern spinlock_t inode_lock;
363
364 extern struct proc_dir_entry *proc_lustre_fs_root;
365
366 static inline struct inode *ll_info2i(struct ll_inode_info *lli)
367 {
368 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
369         return &lli->lli_vfs_inode;
370 #else
371         return list_entry(lli, struct inode, u.generic_ip);
372 #endif
373 }
374
375 struct it_cb_data {
376         struct inode *icbd_parent;
377         struct dentry **icbd_childp;
378         obd_id hash;
379 };
380
381 void ll_i2gids(__u32 *suppgids, struct inode *i1,struct inode *i2);
382
383 #define LLAP_MAGIC 98764321
384
385 extern kmem_cache_t *ll_async_page_slab;
386 extern size_t ll_async_page_slab_size;
387 struct ll_async_page {
388         int              llap_magic;
389          /* only trust these if the page lock is providing exclusion */
390         unsigned int     llap_write_queued:1,
391                          llap_defer_uptodate:1,
392                          llap_origin:3,
393                          llap_ra_used:1,
394                          llap_ignore_quota:1;
395         void            *llap_cookie;
396         struct page     *llap_page;
397         struct list_head llap_pending_write;
398         struct list_head llap_pglist_item;
399         /* checksum for paranoid I/O debugging */
400         __u32 llap_checksum;
401 };
402
403 /*
404  * enumeration of llap_from_page() call-sites. Used to export statistics in
405  * /proc/fs/lustre/llite/fsN/dump_page_cache.
406  */
407 enum {
408         LLAP_ORIGIN_UNKNOWN = 0,
409         LLAP_ORIGIN_READPAGE,
410         LLAP_ORIGIN_READAHEAD,
411         LLAP_ORIGIN_COMMIT_WRITE,
412         LLAP_ORIGIN_WRITEPAGE,
413         LLAP_ORIGIN_REMOVEPAGE,
414         LLAP__ORIGIN_MAX,
415 };
416 extern char *llap_origins[];
417
418 #ifdef HAVE_REGISTER_CACHE
419 #define ll_register_cache(cache) register_cache(cache)
420 #define ll_unregister_cache(cache) unregister_cache(cache)
421 #else
422 #define ll_register_cache(cache) do {} while (0)
423 #define ll_unregister_cache(cache) do {} while (0)
424 #endif
425
426 void ll_ra_read_in(struct file *f, struct ll_ra_read *rar);
427 void ll_ra_read_ex(struct file *f, struct ll_ra_read *rar);
428 struct ll_ra_read *ll_ra_read_get(struct file *f);
429
430 /* llite/lproc_llite.c */
431 #ifdef LPROCFS
432 int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
433                                 struct super_block *sb, char *osc, char *mdc);
434 void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi);
435 void ll_vfs_ops_tally(struct ll_sb_info *sbi, int op);
436 #else
437 static inline int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
438                         struct super_block *sb, char *osc, char *mdc){return 0;}
439 static inline void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi) {}
440 static void ll_vfs_ops_tally(struct ll_sb_info *sbi, int op) {}
441 #endif
442
443
444 /* llite/dir.c */
445 extern struct file_operations ll_dir_operations;
446 extern struct inode_operations ll_dir_inode_operations;
447
448 /* llite/namei.c */
449 int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir);
450 struct inode *ll_iget(struct super_block *sb, ino_t hash,
451                       struct lustre_md *lic);
452 struct dentry *ll_find_alias(struct inode *, struct dentry *);
453 int ll_mdc_cancel_unused(struct lustre_handle *, struct inode *, int flags,
454                          void *opaque);
455 int ll_mdc_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *,
456                         void *data, int flag);
457 int ll_prepare_mdc_op_data(struct mdc_op_data *,
458                            struct inode *i1, struct inode *i2,
459                            const char *name, int namelen, int mode);
460 #ifndef LUSTRE_KERNEL_VERSION
461 struct lookup_intent *ll_convert_intent(struct open_intent *oit,
462                                         int lookup_flags);
463 #endif
464
465 /* llite/rw.c */
466 int ll_prepare_write(struct file *, struct page *, unsigned from, unsigned to);
467 int ll_commit_write(struct file *, struct page *, unsigned from, unsigned to);
468 int ll_writepage(struct page *page);
469 void ll_inode_fill_obdo(struct inode *inode, int cmd, struct obdo *oa);
470 int ll_ap_completion(void *data, int cmd, struct obdo *oa, int rc);
471 int llap_shrink_cache(struct ll_sb_info *sbi, int shrink_fraction);
472 extern struct cache_definition ll_cache_definition;
473 void ll_removepage(struct page *page);
474 int ll_readpage(struct file *file, struct page *page);
475 struct ll_async_page *llap_from_cookie(void *cookie);
476 struct ll_async_page *llap_cast_private(struct page *page);
477 void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras);
478 void ll_ra_accounting(struct ll_async_page *llap,struct address_space *mapping);
479 void ll_truncate(struct inode *inode);
480 int ll_sync_page_range(struct inode *, struct address_space *, loff_t, size_t);
481
482 /* llite/file.c */
483 extern struct file_operations ll_file_operations;
484 extern struct file_operations ll_file_operations_flock;
485 extern struct inode_operations ll_file_inode_operations;
486 extern int ll_inode_revalidate_it(struct dentry *, struct lookup_intent *);
487 extern int ll_have_md_lock(struct inode *inode, __u64 bits);
488 int ll_extent_lock(struct ll_file_data *, struct inode *,
489                    struct lov_stripe_md *, int mode, ldlm_policy_data_t *,
490                    struct lustre_handle *, int ast_flags);
491 int ll_extent_unlock(struct ll_file_data *, struct inode *,
492                      struct lov_stripe_md *, int mode, struct lustre_handle *);
493 int ll_file_open(struct inode *inode, struct file *file);
494 int ll_file_release(struct inode *inode, struct file *file);
495 int ll_lsm_getattr(struct obd_export *, struct lov_stripe_md *, struct obdo *);
496 int ll_glimpse_ioctl(struct ll_sb_info *sbi, 
497                      struct lov_stripe_md *lsm, lstat_t *st);
498 int ll_glimpse_size(struct inode *inode, int ast_flags);
499 int ll_local_open(struct file *file,
500                   struct lookup_intent *it, struct ll_file_data *fd,
501                   struct obd_client_handle *och);
502 int ll_release_openhandle(struct dentry *, struct lookup_intent *);
503 int ll_mdc_close(struct obd_export *mdc_exp, struct inode *inode,
504                  struct file *file);
505 int ll_mdc_real_close(struct inode *inode, int flags);
506 extern void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, struct file
507                                *file, size_t count, int rw);
508 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
509 int ll_getattr_it(struct vfsmount *mnt, struct dentry *de,
510                struct lookup_intent *it, struct kstat *stat);
511 int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat);
512 #endif
513 struct ll_file_data *ll_file_data_get(void);
514 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
515 int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd);
516 #else
517 int ll_inode_permission(struct inode *inode, int mask);
518 #endif
519 int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
520                              int flags, struct lov_user_md *lum,
521                              int lum_size);
522 int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename,
523                              struct lov_mds_md **lmm, int *lmm_size,
524                              struct ptlrpc_request **request);
525 int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump);
526 int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmm, 
527                      int *lmm_size, struct ptlrpc_request **request);
528
529 /* llite/dcache.c */
530 void ll_intent_drop_lock(struct lookup_intent *);
531 void ll_intent_release(struct lookup_intent *);
532 extern void ll_set_dd(struct dentry *de);
533 int ll_drop_dentry(struct dentry *dentry);
534 void ll_unhash_aliases(struct inode *);
535 void ll_frob_intent(struct lookup_intent **itp, struct lookup_intent *deft);
536 void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry);
537 int ll_dcompare(struct dentry *parent, struct qstr *d_name, struct qstr *name);
538 int revalidate_it_finish(struct ptlrpc_request *request, int offset,
539                          struct lookup_intent *it, struct dentry *de);
540
541 /* llite/llite_lib.c */
542 extern struct super_operations lustre_super_operations;
543
544 char *ll_read_opt(const char *opt, char *data);
545 void ll_lli_init(struct ll_inode_info *lli);
546 int ll_fill_super(struct super_block *sb);
547 void ll_put_super(struct super_block *sb);
548 struct inode *ll_inode_from_lock(struct ldlm_lock *lock);
549 void ll_clear_inode(struct inode *inode);
550 int ll_setattr_raw(struct inode *inode, struct iattr *attr);
551 int ll_setattr(struct dentry *de, struct iattr *attr);
552 #ifndef HAVE_STATFS_DENTRY_PARAM
553 int ll_statfs(struct super_block *sb, struct kstatfs *sfs);
554 #else
555 int ll_statfs(struct dentry *de, struct kstatfs *sfs);
556 #endif
557 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
558                        __u64 max_age);
559 void ll_update_inode(struct inode *inode, struct lustre_md *md);
560 void ll_read_inode2(struct inode *inode, void *opaque);
561 int ll_iocontrol(struct inode *inode, struct file *file,
562                  unsigned int cmd, unsigned long arg);
563 #ifdef HAVE_UMOUNTBEGIN_VFSMOUNT
564 void ll_umount_begin(struct vfsmount *vfsmnt, int flags);
565 #else
566 void ll_umount_begin(struct super_block *sb);
567 #endif
568 int ll_remount_fs(struct super_block *sb, int *flags, char *data);
569 int ll_prep_inode(struct obd_export *exp, struct inode **inode,
570                   struct ptlrpc_request *req, int offset, struct super_block *);
571 void lustre_dump_dentry(struct dentry *, int recur);
572 void lustre_dump_inode(struct inode *);
573 struct ll_async_page *llite_pglist_next_llap(struct ll_sb_info *sbi,
574                                              struct list_head *list);
575 int ll_obd_statfs(struct inode *inode, void *arg);
576 int ll_get_max_mdsize(struct ll_sb_info *sbi, int *max_mdsize);
577 int ll_process_config(struct lustre_cfg *lcfg);
578
579 /* llite/llite_nfs.c */
580 extern struct export_operations lustre_export_operations;
581 __u32 get_uuid2int(const char *name, int len);
582 struct dentry *ll_fh_to_dentry(struct super_block *sb, __u32 *data, int len,
583                                int fhtype, int parent);
584 int ll_dentry_to_fh(struct dentry *, __u32 *datap, int *lenp, int need_parent);
585
586 /* llite/special.c */
587 extern struct inode_operations ll_special_inode_operations;
588 extern struct file_operations ll_special_chr_inode_fops;
589 extern struct file_operations ll_special_chr_file_fops;
590 extern struct file_operations ll_special_blk_inode_fops;
591 extern struct file_operations ll_special_fifo_inode_fops;
592 extern struct file_operations ll_special_fifo_file_fops;
593 extern struct file_operations ll_special_sock_inode_fops;
594
595 /* llite/symlink.c */
596 extern struct inode_operations ll_fast_symlink_inode_operations;
597
598 /* llite/llite_close.c */
599 struct ll_close_queue {
600         spinlock_t              lcq_lock;
601         struct list_head        lcq_list;
602         wait_queue_head_t       lcq_waitq;
603         struct completion       lcq_comp;
604 };
605
606 void llap_write_pending(struct inode *inode, struct ll_async_page *llap);
607 void llap_write_complete(struct inode *inode, struct ll_async_page *llap);
608 void ll_open_complete(struct inode *inode);
609 int ll_is_inode_dirty(struct inode *inode);
610 void ll_try_done_writing(struct inode *inode);
611 void ll_queue_done_writing(struct inode *inode);
612 void ll_close_thread_shutdown(struct ll_close_queue *lcq);
613 int ll_close_thread_start(struct ll_close_queue **lcq_ret);
614
615 /* llite/llite_mmap.c */
616 #if  (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
617 typedef struct rb_root  rb_root_t;
618 typedef struct rb_node  rb_node_t;
619 #endif
620
621 struct ll_lock_tree_node;
622 struct ll_lock_tree {
623         rb_root_t                       lt_root;
624         struct list_head                lt_locked_list;
625         struct ll_file_data             *lt_fd;
626 };
627
628 int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last);
629 int ll_file_mmap(struct file * file, struct vm_area_struct * vma);
630 struct ll_lock_tree_node * ll_node_from_inode(struct inode *inode, __u64 start,
631                                               __u64 end, ldlm_mode_t mode);
632 int ll_tree_lock(struct ll_lock_tree *tree,
633                  struct ll_lock_tree_node *first_node,
634                  const char *buf, size_t count, int ast_flags);
635 int ll_tree_unlock(struct ll_lock_tree *tree);
636
637 #define    ll_s2sbi(sb)        (s2lsi(sb)->lsi_llsbi)
638
639 #if  (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
640 void __d_rehash(struct dentry * entry, int lock);
641 static inline __u64 ll_ts2u64(struct timespec *time)
642 {
643         __u64 t = time->tv_sec;
644         return t;
645 }
646 #else  /* 2.4 here */
647 static inline __u64 ll_ts2u64(time_t *time)
648 {
649         return *time;
650 }
651 #endif
652
653 /* don't need an addref as the sb_info should be holding one */
654 static inline struct obd_export *ll_s2obdexp(struct super_block *sb)
655 {
656         return ll_s2sbi(sb)->ll_osc_exp;
657 }
658
659 /* don't need an addref as the sb_info should be holding one */
660 static inline struct obd_export *ll_s2mdcexp(struct super_block *sb)
661 {
662         return ll_s2sbi(sb)->ll_mdc_exp;
663 }
664
665 static inline struct client_obd *sbi2mdc(struct ll_sb_info *sbi)
666 {
667         struct obd_device *obd = sbi->ll_mdc_exp->exp_obd;
668         if (obd == NULL)
669                 LBUG();
670         return &obd->u.cli;
671 }
672
673 // FIXME: replace the name of this with LL_SB to conform to kernel stuff
674 static inline struct ll_sb_info *ll_i2sbi(struct inode *inode)
675 {
676         return ll_s2sbi(inode->i_sb);
677 }
678
679 static inline struct obd_export *ll_i2obdexp(struct inode *inode)
680 {
681         return ll_s2obdexp(inode->i_sb);
682 }
683
684 static inline struct obd_export *ll_i2mdcexp(struct inode *inode)
685 {
686         return ll_s2mdcexp(inode->i_sb);
687 }
688
689 static inline void ll_inode2fid(struct ll_fid *fid, struct inode *inode)
690 {
691         mdc_pack_fid(fid, inode->i_ino, inode->i_generation,
692                      inode->i_mode & S_IFMT);
693 }
694
695 static inline int ll_mds_max_easize(struct super_block *sb)
696 {
697         return sbi2mdc(ll_s2sbi(sb))->cl_max_mds_easize;
698 }
699
700 static inline __u64 ll_file_maxbytes(struct inode *inode)
701 {
702         return ll_i2info(inode)->lli_maxbytes;
703 }
704
705 /* llite/xattr.c */
706 int ll_setxattr(struct dentry *dentry, const char *name,
707                 const void *value, size_t size, int flags);
708 ssize_t ll_getxattr(struct dentry *dentry, const char *name,
709                     void *buffer, size_t size);
710 ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size);
711 int ll_removexattr(struct dentry *dentry, const char *name);
712
713 #endif /* LLITE_INTERNAL_H */