Whamcloud - gitweb
Branch b1_6
[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 #include <linux/ext2_fs.h>
9 #ifdef CONFIG_FS_POSIX_ACL
10 # include <linux/fs.h>
11 #ifdef HAVE_XATTR_ACL
12 # include <linux/xattr_acl.h>
13 #endif
14 #ifdef HAVE_LINUX_POSIX_ACL_XATTR_H
15 # include <linux/posix_acl_xattr.h>
16 #endif
17 #endif
18
19 #include <lustre_debug.h>
20 #include <lustre_ver.h>
21 #include <linux/lustre_version.h>
22 #include <lustre_disk.h>  /* for s2sbi */
23  
24 /*
25 struct lustre_intent_data {
26         __u64 it_lock_handle[2];
27         __u32 it_disposition;
28         __u32 it_status;
29         __u32 it_lock_mode;
30         }; */
31
32 /* If there is no FMODE_EXEC defined, make it to match nothing */
33 #ifndef FMODE_EXEC
34 #define FMODE_EXEC 0
35 #endif
36
37 #define LL_IT2STR(it) ((it) ? ldlm_it2str((it)->it_op) : "0")
38 #define LUSTRE_FPRIVATE(file) ((file)->private_data)
39
40 #ifdef HAVE_VFS_INTENT_PATCHES
41 static inline struct lookup_intent *ll_nd2it(struct nameidata *nd)
42 {
43 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
44         return &nd->intent;
45 #else
46         return nd->intent;
47 #endif
48 }
49 #endif
50
51 struct ll_dentry_data {
52         int                      lld_cwd_count;
53         int                      lld_mnt_count;
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;
58 #endif
59 };
60
61 #define ll_d2d(de) ((struct ll_dentry_data*) de->d_fsdata)
62
63 extern struct file_operations ll_pgcache_seq_fops;
64
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
69
70 struct ll_inode_info {
71         int                     lli_inode_magic;
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;
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 #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;
87 #endif
88         atomic_t                lli_mmap_cnt;
89
90         /* for writepage() only to communicate to fsync */
91         int                     lli_async_rc;
92
93         struct posix_acl       *lli_posix_acl;
94
95         struct list_head        lli_dead_list;
96
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
100            modes */
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;
107
108 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
109         struct inode            lli_vfs_inode;
110 #endif
111
112         /* metadata stat-ahead */
113         pid_t                   lli_opendir_pid;
114         struct ll_statahead_info *lli_sai;
115 };
116
117 /*
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.
121  *
122  * Implemented by ->lli_size_sem and ->lsm_sem, nested in that order.
123  */
124
125 void ll_inode_size_lock(struct inode *inode, int lock_lsm);
126 void ll_inode_size_unlock(struct inode *inode, int unlock_lsm);
127
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)
131 {
132 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
133         return container_of(inode, struct ll_inode_info, lli_vfs_inode);
134 #else
135         CLASSERT(sizeof(inode->u) >= sizeof(struct ll_inode_info));
136         return (struct ll_inode_info *)&(inode->u.generic_ip);
137 #endif
138 }
139
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))
143
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))
146
147 enum ra_stat {
148         RA_STAT_HIT = 0,
149         RA_STAT_MISS,
150         RA_STAT_DISTANT_READPAGE,
151         RA_STAT_MISS_IN_WINDOW,
152         RA_STAT_FAILED_GRAB_PAGE,
153         RA_STAT_FAILED_MATCH,
154         RA_STAT_DISCARDED,
155         RA_STAT_ZERO_LEN,
156         RA_STAT_ZERO_WINDOW,
157         RA_STAT_EOF,
158         RA_STAT_MAX_IN_FLIGHT,
159         RA_STAT_WRONG_GRAB_PAGE,
160         _NR_RA_STAT,
161 };
162
163 struct ll_ra_info {
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];
168 };
169
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 {
175         pid_t pid;
176         struct obd_histogram pp_r_hist;
177         struct obd_histogram pp_w_hist;
178 };
179
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];
183 };
184
185 #define LL_OFFSET_HIST_MAX 100
186 struct ll_rw_process_info {
187         pid_t                     rw_pid;
188         int                       rw_op;
189         loff_t                    rw_range_start;
190         loff_t                    rw_range_end;
191         loff_t                    rw_last_file_pos;
192         loff_t                    rw_offset;
193         size_t                    rw_smallest_extent;
194         size_t                    rw_largest_extent;
195         struct file               *rw_last_file;
196 };
197
198
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 */
204         STATS_TRACK_LAST,
205 };
206
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 */
215
216 struct ll_sb_info {
217         struct list_head          ll_list;
218         /* this protects pglist and ra_info.  It isn't safe to
219          * grab from interrupt contexts */
220         spinlock_t                ll_lock;
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 */
228
229         int                       ll_flags;
230         struct list_head          ll_conn_chain; /* per-conn chain of SBs */
231         struct lustre_client_ocd  ll_lco;
232
233         struct list_head          ll_orphan_dentry_list; /*please don't ask -p*/
234         struct ll_close_queue    *ll_lcq;
235
236         struct lprocfs_stats     *ll_stats; /* lprocfs stats counter */
237
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) */
242
243         struct ll_ra_info         ll_ra_info;
244         unsigned int              ll_namelen;
245         struct file_operations   *ll_fop;
246
247 #ifdef HAVE_EXPORT___IGET
248         struct list_head          ll_deathrow; /* inodes to be destroyed (b1443) */
249         spinlock_t                ll_deathrow_lock;
250 #endif
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;
254
255         /* Statistics */
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;
264         int                       ll_rw_stats_on;
265         dev_t                     ll_sdev_orig; /* save s_dev before assign for
266                                                  * clustred nfs */
267
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
272                                                 * low hit ratio */
273         unsigned int              ll_sa_total; /* statahead thread started
274                                                 * count */
275         unsigned long long        ll_sa_blocked; /* ls count waiting for
276                                                   * statahead */
277         unsigned long long        ll_sa_cached;  /* ls count got in cache */
278 };
279
280 #define LL_DEFAULT_MAX_RW_CHUNK         (32 * 1024 * 1024)
281
282 struct ll_ra_read {
283         pgoff_t             lrr_start;
284         pgoff_t             lrr_count;
285         struct task_struct *lrr_reader;
286         struct list_head    lrr_linkage;
287 };
288
289 /*
290  * per file-descriptor read-ahead data.
291  */
292 struct ll_readahead_state {
293         spinlock_t      ras_lock;
294         /*
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.
297          *
298          * XXX nikita: if access seeks into cached region, Lustre doesn't see
299          * this.
300          */
301         unsigned long   ras_last_readpage;
302         /*
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.
306          *
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.
311          */
312         unsigned long   ras_consecutive_pages;
313         /*
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.
317          */
318         unsigned long   ras_consecutive_requests;
319         /*
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.
325          */
326         unsigned long   ras_window_start, ras_window_len;
327         /*
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.
333          */
334         unsigned long   ras_next_readahead;
335         /*
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.
339          */
340         unsigned long   ras_requests;
341         /*
342          * Page index with respect to the current request, these value 
343          * will not be accurate when dealing with reads issued via mmap.
344          */
345         unsigned long   ras_request_index;
346         /*
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.
350          */
351         struct list_head ras_read_beads;
352 };
353
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;
358         int fd_omode;
359         struct lustre_handle fd_cwlockh;
360         unsigned long fd_gid;
361         __u32 fd_flags;
362 };
363
364 struct lov_stripe_md;
365
366 extern spinlock_t inode_lock;
367
368 extern struct proc_dir_entry *proc_lustre_fs_root;
369
370 static inline struct inode *ll_info2i(struct ll_inode_info *lli)
371 {
372 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
373         return &lli->lli_vfs_inode;
374 #else
375         return list_entry(lli, struct inode, u.generic_ip);
376 #endif
377 }
378
379 struct it_cb_data {
380         struct inode   *icbd_parent;
381         struct dentry **icbd_childp;
382         obd_id          hash;
383 };
384
385 void ll_i2gids(__u32 *suppgids, struct inode *i1,struct inode *i2);
386
387 #define LLAP_MAGIC 98764321
388
389 extern cfs_mem_cache_t *ll_async_page_slab;
390 extern size_t ll_async_page_slab_size;
391 struct ll_async_page {
392         int              llap_magic;
393          /* only trust these if the page lock is providing exclusion */
394         unsigned int     llap_write_queued:1,
395                          llap_defer_uptodate:1,
396                          llap_origin:3,
397                          llap_ra_used:1,
398                          llap_ignore_quota:1;
399         void            *llap_cookie;
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 */
404         __u32 llap_checksum;
405 };
406
407 /*
408  * enumeration of llap_from_page() call-sites. Used to export statistics in
409  * /proc/fs/lustre/llite/fsN/dump_page_cache.
410  */
411 enum {
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,
418         LLAP__ORIGIN_MAX,
419 };
420 extern char *llap_origins[];
421
422 #ifdef HAVE_REGISTER_CACHE
423 #define ll_register_cache(cache) register_cache(cache)
424 #define ll_unregister_cache(cache) unregister_cache(cache)
425 #else
426 #define ll_register_cache(cache) do {} while (0)
427 #define ll_unregister_cache(cache) do {} while (0)
428 #endif
429
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);
433
434 /* llite/lproc_llite.c */
435 #ifdef LPROCFS
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);
440 #else
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) {}
445 #endif
446
447
448 /* llite/dir.c */
449 extern struct file_operations ll_dir_operations;
450 extern struct inode_operations ll_dir_inode_operations;
451
452 struct page *ll_get_dir_page(struct inode *dir, unsigned long n);
453 /*
454  * p is at least 6 bytes before the end of page
455  */
456 typedef struct ext2_dir_entry_2 ext2_dirent;
457
458 static inline ext2_dirent *ext2_next_entry(ext2_dirent *p)
459 {
460         return (ext2_dirent *)((char*)p + le16_to_cpu(p->rec_len));
461 }
462
463 static inline unsigned
464 ext2_validate_entry(char *base, unsigned offset, unsigned mask)
465 {
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;
471 }
472
473 static inline void ext2_put_page(struct page *page)
474 {
475         kunmap(page);
476         page_cache_release(page);
477 }
478
479 static inline unsigned long dir_pages(struct inode *inode)
480 {
481         return (inode->i_size + CFS_PAGE_SIZE - 1) >> CFS_PAGE_SHIFT;
482 }
483
484 /* llite/namei.c */
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,
489                          void *opaque);
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,
497                                         int lookup_flags);
498 #endif
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);
502
503 /* llite/rw.c */
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);
518
519 /* llite/file.c */
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,
542                  struct file *file);
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);
550 #endif
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);
554 #else
555 int ll_inode_permission(struct inode *inode, int mask);
556 #endif
557 int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
558                              int flags, struct lov_user_md *lum,
559                              int lum_size);
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);
566
567 /* llite/dcache.c */
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);
578
579 /* llite/llite_lib.c */
580 extern struct super_operations lustre_super_operations;
581
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);
592 #else
593 int ll_statfs(struct dentry *de, struct kstatfs *sfs);
594 #endif
595 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
596                        __u64 max_age);
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);
603 #else
604 void ll_umount_begin(struct super_block *sb);
605 #endif
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);
616
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);
623
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;
632
633 /* llite/symlink.c */
634 extern struct inode_operations ll_fast_symlink_inode_operations;
635
636 /* llite/llite_close.c */
637 struct ll_close_queue {
638         spinlock_t              lcq_lock;
639         struct list_head        lcq_list;
640         wait_queue_head_t       lcq_waitq;
641         struct completion       lcq_comp;
642 };
643
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);
651 #else
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; };
662 #endif
663 void ll_close_thread_shutdown(struct ll_close_queue *lcq);
664 int ll_close_thread_start(struct ll_close_queue **lcq_ret);
665
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;
670 #endif
671
672 struct ll_lock_tree_node;
673 struct ll_lock_tree {
674         rb_root_t                       lt_root;
675         struct list_head                lt_locked_list;
676         struct ll_file_data             *lt_fd;
677 };
678
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);
687
688 #define    ll_s2sbi(sb)        (s2lsi(sb)->lsi_llsbi)
689
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)
693 {
694         __u64 t = time->tv_sec;
695         return t;
696 }
697 #else  /* 2.4 here */
698 static inline __u64 ll_ts2u64(time_t *time)
699 {
700         return *time;
701 }
702 #endif
703
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)
706 {
707         return ll_s2sbi(sb)->ll_osc_exp;
708 }
709
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)
712 {
713         return ll_s2sbi(sb)->ll_mdc_exp;
714 }
715
716 static inline struct client_obd *sbi2mdc(struct ll_sb_info *sbi)
717 {
718         struct obd_device *obd = sbi->ll_mdc_exp->exp_obd;
719         if (obd == NULL)
720                 LBUG();
721         return &obd->u.cli;
722 }
723
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)
726 {
727         return ll_s2sbi(inode->i_sb);
728 }
729
730 static inline struct obd_export *ll_i2obdexp(struct inode *inode)
731 {
732         return ll_s2obdexp(inode->i_sb);
733 }
734
735 static inline struct obd_export *ll_i2mdcexp(struct inode *inode)
736 {
737         return ll_s2mdcexp(inode->i_sb);
738 }
739
740 static inline void ll_inode2fid(struct ll_fid *fid, struct inode *inode)
741 {
742         mdc_pack_fid(fid, inode->i_ino, inode->i_generation,
743                      inode->i_mode & S_IFMT);
744 }
745
746 static inline int ll_mds_max_easize(struct super_block *sb)
747 {
748         return sbi2mdc(ll_s2sbi(sb))->cl_max_mds_easize;
749 }
750
751 static inline __u64 ll_file_maxbytes(struct inode *inode)
752 {
753         return ll_i2info(inode)->lli_maxbytes;
754 }
755
756 /* llite/xattr.c */
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);
763
764 /* statahead.c */
765
766 #define LL_STATAHEAD_MIN  1
767 #define LL_STATAHEAD_DEF  32
768 #define LL_STATAHEAD_MAX  10000
769
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
774                                                  * refcount */
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
778                                                  * reply */
779         unsigned int            sai_cached;     /* UPDATE lock cached locally
780                                                  * already */
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
785                                                  * hidden entries */
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 */
789 };
790
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);
794
795 #endif /* LLITE_INTERNAL_H */