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