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