Whamcloud - gitweb
Merge fixes from b1_6 to HEAD.
[fs/lustre-release.git] / lustre / llite / llite_internal.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  */
4
5 #ifndef LLITE_INTERNAL_H
6 #define LLITE_INTERNAL_H
7
8 # 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         dev_t                     ll_sdev_orig;      /* save s_dev before assign for clustred nfs*/
292 };
293
294 #define LL_DEFAULT_MAX_RW_CHUNK         (32 * 1024 * 1024)
295
296 struct ll_ra_read {
297         pgoff_t             lrr_start;
298         pgoff_t             lrr_count;
299         struct task_struct *lrr_reader;
300         struct list_head    lrr_linkage;
301 };
302
303 /*
304  * per file-descriptor read-ahead data.
305  */
306 struct ll_readahead_state {
307         spinlock_t      ras_lock;
308         /*
309          * index of the last page that read(2) needed and that wasn't in the
310          * cache. Used by ras_update() to detect seeks.
311          *
312          * XXX nikita: if access seeks into cached region, Lustre doesn't see
313          * this.
314          */
315         unsigned long   ras_last_readpage;
316         /*
317          * number of pages read after last read-ahead window reset. As window
318          * is reset on each seek, this is effectively a number of consecutive
319          * accesses. Maybe ->ras_accessed_in_window is better name.
320          *
321          * XXX nikita: window is also reset (by ras_update()) when Lustre
322          * believes that memory pressure evicts read-ahead pages. In that
323          * case, it probably doesn't make sense to expand window to
324          * PTLRPC_MAX_BRW_PAGES on the third access.
325          */
326         unsigned long   ras_consecutive_pages;
327         /*
328          * number of read requests after the last read-ahead window reset
329          * As window is reset on each seek, this is effectively the number
330          * on consecutive read request and is used to trigger read-ahead.
331          */
332         unsigned long   ras_consecutive_requests;
333         /*
334          * Parameters of current read-ahead window. Handled by
335          * ras_update(). On the initial access to the file or after a seek,
336          * window is reset to 0. After 3 consecutive accesses, window is
337          * expanded to PTLRPC_MAX_BRW_PAGES. Afterwards, window is enlarged by
338          * PTLRPC_MAX_BRW_PAGES chunks up to ->ra_max_pages.
339          */
340         unsigned long   ras_window_start, ras_window_len;
341         /*
342          * Where next read-ahead should start at. This lies within read-ahead
343          * window. Read-ahead window is read in pieces rather than at once
344          * because: 1. lustre limits total number of pages under read-ahead by
345          * ->ra_max_pages (see ll_ra_count_get()), 2. client cannot read pages
346          * not covered by DLM lock.
347          */
348         unsigned long   ras_next_readahead;
349         /*
350          * Total number of ll_file_read requests issued, reads originating
351          * due to mmap are not counted in this total.  This value is used to
352          * trigger full file read-ahead after multiple reads to a small file.
353          */
354         unsigned long   ras_requests;
355         /*
356          * Page index with respect to the current request, these value
357          * will not be accurate when dealing with reads issued via mmap.
358          */
359         unsigned long   ras_request_index;
360         /*
361          * list of struct ll_ra_read's one per read(2) call current in
362          * progress against this file descriptor. Used by read-ahead code,
363          * protected by ->ras_lock.
364          */
365         struct list_head ras_read_beads;
366 };
367
368 struct ll_file_dir {
369 };
370
371 extern cfs_mem_cache_t *ll_file_data_slab;
372 struct lustre_handle;
373 struct ll_file_data {
374         struct ll_readahead_state fd_ras;
375         int fd_omode;
376         struct lustre_handle fd_cwlockh;
377         unsigned long fd_gid;
378         struct ll_file_dir fd_dir;
379         __u32 fd_flags;
380 };
381
382 struct lov_stripe_md;
383
384 extern spinlock_t inode_lock;
385
386 extern struct proc_dir_entry *proc_lustre_fs_root;
387
388 static inline struct inode *ll_info2i(struct ll_inode_info *lli)
389 {
390 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
391         return &lli->lli_vfs_inode;
392 #else
393         return list_entry(lli, struct inode, u.generic_ip);
394 #endif
395 }
396
397 struct it_cb_data {
398         struct inode *icbd_parent;
399         struct dentry **icbd_childp;
400         obd_id hash;
401 };
402
403 void ll_i2gids(__u32 *suppgids, struct inode *i1,struct inode *i2);
404
405 #define LLAP_MAGIC 98764321
406
407 extern cfs_mem_cache_t *ll_async_page_slab;
408 extern size_t ll_async_page_slab_size;
409 struct ll_async_page {
410         int              llap_magic;
411          /* only trust these if the page lock is providing exclusion */
412         unsigned int     llap_write_queued:1,
413                          llap_defer_uptodate:1,
414                          llap_origin:3,
415                          llap_ra_used:1,
416                          llap_ignore_quota:1;
417         void            *llap_cookie;
418         struct page     *llap_page;
419         struct list_head llap_pending_write;
420         struct list_head llap_pglist_item;
421         /* checksum for paranoid I/O debugging */
422         __u32            llap_checksum;
423 };
424
425 /*
426  * enumeration of llap_from_page() call-sites. Used to export statistics in
427  * /proc/fs/lustre/llite/fsN/dump_page_cache.
428  */
429 enum {
430         LLAP_ORIGIN_UNKNOWN = 0,
431         LLAP_ORIGIN_READPAGE,
432         LLAP_ORIGIN_READAHEAD,
433         LLAP_ORIGIN_COMMIT_WRITE,
434         LLAP_ORIGIN_WRITEPAGE,
435         LLAP_ORIGIN_REMOVEPAGE,
436         LLAP__ORIGIN_MAX,
437 };
438 extern char *llap_origins[];
439
440 #ifdef HAVE_REGISTER_CACHE
441 #define ll_register_cache(cache) register_cache(cache)
442 #define ll_unregister_cache(cache) unregister_cache(cache)
443 #else
444 #define ll_register_cache(cache) do {} while (0)
445 #define ll_unregister_cache(cache) do {} while (0)
446 #endif
447
448 void ll_ra_read_in(struct file *f, struct ll_ra_read *rar);
449 void ll_ra_read_ex(struct file *f, struct ll_ra_read *rar);
450 struct ll_ra_read *ll_ra_read_get(struct file *f);
451
452 /* llite/lproc_llite.c */
453 #ifdef LPROCFS
454 int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
455                                 struct super_block *sb, char *osc, char *mdc);
456 void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi);
457 void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count);
458 #else
459 static inline int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
460                         struct super_block *sb, char *osc, char *mdc){return 0;}
461 static inline void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi) {}
462 static void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) {}
463 #endif
464
465
466 /* llite/dir.c */
467 extern struct file_operations ll_dir_operations;
468 extern struct inode_operations ll_dir_inode_operations;
469
470 /* llite/namei.c */
471 int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir);
472 struct inode *ll_iget(struct super_block *sb, ino_t hash,
473                       struct lustre_md *lic);
474 struct dentry *ll_find_alias(struct inode *, struct dentry *);
475 int ll_md_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *,
476                        void *data, int flag);
477 #ifndef LUSTRE_KERNEL_VERSION
478 struct lookup_intent *ll_convert_intent(struct open_intent *oit,
479                                         int lookup_flags);
480 #endif
481
482 /* llite/rw.c */
483 int ll_prepare_write(struct file *, struct page *, unsigned from, unsigned to);
484 int ll_commit_write(struct file *, struct page *, unsigned from, unsigned to);
485 int ll_writepage(struct page *page);
486 void ll_inode_fill_obdo(struct inode *inode, int cmd, struct obdo *oa);
487 int ll_ap_completion(void *data, int cmd, struct obdo *oa, int rc);
488 int llap_shrink_cache(struct ll_sb_info *sbi, int shrink_fraction);
489 struct ll_async_page *llap_from_page(struct page *page, unsigned origin);
490 extern struct cache_definition ll_cache_definition;
491 void ll_removepage(struct page *page);
492 int ll_readpage(struct file *file, struct page *page);
493 struct ll_async_page *llap_cast_private(struct page *page);
494 void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras);
495 void ll_ra_accounting(struct ll_async_page *llap,struct address_space *mapping);
496 void ll_truncate(struct inode *inode);
497 int ll_sync_page_range(struct inode *, struct address_space *, loff_t, size_t);
498
499 /* llite/file.c */
500 extern struct file_operations ll_file_operations;
501 extern struct file_operations ll_file_operations_flock;
502 extern struct file_operations ll_file_operations_noflock;
503 extern struct inode_operations ll_file_inode_operations;
504 extern int ll_inode_revalidate_it(struct dentry *, struct lookup_intent *);
505 extern int ll_have_md_lock(struct inode *inode, __u64 bits);
506 int ll_extent_lock(struct ll_file_data *, struct inode *,
507                    struct lov_stripe_md *, int mode, ldlm_policy_data_t *,
508                    struct lustre_handle *, int ast_flags);
509 int ll_extent_unlock(struct ll_file_data *, struct inode *,
510                      struct lov_stripe_md *, int mode, struct lustre_handle *);
511 int ll_file_open(struct inode *inode, struct file *file);
512 int ll_file_release(struct inode *inode, struct file *file);
513 int ll_lsm_getattr(struct obd_export *, struct lov_stripe_md *, struct obdo *);
514 int ll_local_size(struct inode *inode);
515 int ll_glimpse_ioctl(struct ll_sb_info *sbi,
516                      struct lov_stripe_md *lsm, lstat_t *st);
517 int ll_glimpse_size(struct inode *inode, int ast_flags);
518 int ll_local_open(struct file *file,
519                   struct lookup_intent *it, struct ll_file_data *fd,
520                   struct obd_client_handle *och);
521 int ll_release_openhandle(struct dentry *, struct lookup_intent *);
522 int ll_md_close(struct obd_export *md_exp, struct inode *inode,
523                 struct file *file);
524 int ll_md_real_close(struct inode *inode, int flags);
525 void ll_epoch_close(struct inode *inode, struct md_op_data *op_data,
526                     struct obd_client_handle **och, unsigned long flags);
527 int ll_sizeonmds_update(struct inode *inode, struct md_open_data *data,
528                         struct lustre_handle *fh, __u64 ioepoch);
529 int ll_inode_getattr(struct inode *inode, struct obdo *obdo);
530 int ll_md_setattr(struct inode *inode, struct md_op_data *op_data,
531                   struct md_open_data **mod);
532 void ll_pack_inode2opdata(struct inode *inode, struct md_op_data *op_data,
533                           struct lustre_handle *fh);
534 extern void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, struct file
535                                *file, size_t count, int rw);
536 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
537 int ll_getattr_it(struct vfsmount *mnt, struct dentry *de,
538                struct lookup_intent *it, struct kstat *stat);
539 int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat);
540 #endif
541 struct ll_file_data *ll_file_data_get(void);
542 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
543 int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd);
544 #else
545 int ll_inode_permission(struct inode *inode, int mask);
546 #endif
547 int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
548                              int flags, struct lov_user_md *lum,
549                              int lum_size);
550 int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename,
551                              struct lov_mds_md **lmm, int *lmm_size,
552                              struct ptlrpc_request **request);
553 int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump);
554 int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmm, 
555                      int *lmm_size, struct ptlrpc_request **request);
556
557 /* llite/dcache.c */
558 void ll_intent_drop_lock(struct lookup_intent *);
559 void ll_intent_release(struct lookup_intent *);
560 int ll_drop_dentry(struct dentry *dentry);
561 extern void ll_set_dd(struct dentry *de);
562 int ll_drop_dentry(struct dentry *dentry);
563 void ll_unhash_aliases(struct inode *);
564 void ll_frob_intent(struct lookup_intent **itp, struct lookup_intent *deft);
565 void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry);
566 int ll_dcompare(struct dentry *parent, struct qstr *d_name, struct qstr *name);
567 int ll_revalidate_it_finish(struct ptlrpc_request *request, int offset,
568                             struct lookup_intent *it, struct dentry *de);
569
570 /* llite/llite_lib.c */
571 extern struct super_operations lustre_super_operations;
572
573 char *ll_read_opt(const char *opt, char *data);
574 void ll_lli_init(struct ll_inode_info *lli);
575 int ll_fill_super(struct super_block *sb);
576 void ll_put_super(struct super_block *sb);
577 void ll_kill_super(struct super_block *sb);
578 struct inode *ll_inode_from_lock(struct ldlm_lock *lock);
579 void ll_clear_inode(struct inode *inode);
580 int ll_setattr_raw(struct inode *inode, struct iattr *attr);
581 int ll_setattr(struct dentry *de, struct iattr *attr);
582 #ifndef HAVE_STATFS_DENTRY_PARAM
583 int ll_statfs(struct super_block *sb, struct kstatfs *sfs);
584 #else
585 int ll_statfs(struct dentry *de, struct kstatfs *sfs);
586 #endif
587 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
588                        __u64 max_age);
589 void ll_update_inode(struct inode *inode, struct lustre_md *md);
590 void ll_read_inode2(struct inode *inode, void *opaque);
591 void ll_delete_inode(struct inode *inode);
592 int ll_iocontrol(struct inode *inode, struct file *file,
593                  unsigned int cmd, unsigned long arg);
594 int ll_flush_ctx(struct inode *inode);
595 #ifdef HAVE_UMOUNTBEGIN_VFSMOUNT
596 void ll_umount_begin(struct vfsmount *vfsmnt, int flags);
597 #else
598 void ll_umount_begin(struct super_block *sb);
599 #endif
600 int ll_remount_fs(struct super_block *sb, int *flags, char *data);
601 int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
602                   int offset, struct super_block *);
603 void lustre_dump_dentry(struct dentry *, int recur);
604 void lustre_dump_inode(struct inode *);
605 struct ll_async_page *llite_pglist_next_llap(struct ll_sb_info *sbi,
606                                              struct list_head *list);
607 int ll_obd_statfs(struct inode *inode, void *arg);
608 int ll_get_max_mdsize(struct ll_sb_info *sbi, int *max_mdsize);
609 int ll_process_config(struct lustre_cfg *lcfg);
610 int ll_ioctl_getfacl(struct inode *inode, struct rmtacl_ioctl_data *ioc);
611 int ll_ioctl_setfacl(struct inode *inode, struct rmtacl_ioctl_data *ioc);
612 struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data,
613                                       struct inode *i1, struct inode *i2,
614                                       const char *name, int namelen,
615                                       int mode, __u32 opc, void *data);
616 void ll_finish_md_op_data(struct md_op_data *op_data);
617
618 /* llite/llite_nfs.c */
619 extern struct export_operations lustre_export_operations;
620 __u32 get_uuid2int(const char *name, int len);
621 struct dentry *ll_fh_to_dentry(struct super_block *sb, __u32 *data, int len,
622                                int fhtype, int parent);
623 int ll_dentry_to_fh(struct dentry *, __u32 *datap, int *lenp, int need_parent);
624
625 /* llite/special.c */
626 extern struct inode_operations ll_special_inode_operations;
627 extern struct file_operations ll_special_chr_inode_fops;
628 extern struct file_operations ll_special_chr_file_fops;
629 extern struct file_operations ll_special_blk_inode_fops;
630 extern struct file_operations ll_special_fifo_inode_fops;
631 extern struct file_operations ll_special_fifo_file_fops;
632 extern struct file_operations ll_special_sock_inode_fops;
633
634 /* llite/symlink.c */
635 extern struct inode_operations ll_fast_symlink_inode_operations;
636
637 /* llite/llite_close.c */
638 struct ll_close_queue {
639         spinlock_t              lcq_lock;
640         struct list_head        lcq_head;
641         wait_queue_head_t       lcq_waitq;
642         struct completion       lcq_comp;
643         atomic_t                lcq_stop;
644 };
645
646 void llap_write_pending(struct inode *inode, struct ll_async_page *llap);
647 int llap_write_complete(struct inode *inode, struct ll_async_page *llap);
648 int ll_inode_dirty(struct inode *inode, unsigned long flags);
649 void ll_queue_done_writing(struct inode *inode, unsigned long flags);
650 void ll_close_thread_shutdown(struct ll_close_queue *lcq);
651 int ll_close_thread_start(struct ll_close_queue **lcq_ret);
652
653 /* llite/llite_mmap.c */
654 #if  (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
655 typedef struct rb_root  rb_root_t;
656 typedef struct rb_node  rb_node_t;
657 #endif
658
659 struct ll_lock_tree_node;
660 struct ll_lock_tree {
661         rb_root_t                       lt_root;
662         struct list_head                lt_locked_list;
663         struct ll_file_data             *lt_fd;
664 };
665
666 int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last);
667 int ll_file_mmap(struct file * file, struct vm_area_struct * vma);
668 struct ll_lock_tree_node * ll_node_from_inode(struct inode *inode, __u64 start,
669                                               __u64 end, ldlm_mode_t mode);
670 int ll_tree_lock(struct ll_lock_tree *tree,
671                  struct ll_lock_tree_node *first_node,
672                  const char *buf, size_t count, int ast_flags);
673 int ll_tree_unlock(struct ll_lock_tree *tree);
674
675 #define    ll_s2sbi(sb)        (s2lsi(sb)->lsi_llsbi)
676
677 #if  (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
678 void __d_rehash(struct dentry * entry, int lock);
679 static inline __u64 ll_ts2u64(struct timespec *time)
680 {
681         __u64 t = time->tv_sec;
682         return t;
683 }
684 #else  /* 2.4 here */
685 static inline __u64 ll_ts2u64(time_t *time)
686 {
687         return *time;
688 }
689 #endif
690
691 /* don't need an addref as the sb_info should be holding one */
692 static inline struct obd_export *ll_s2dtexp(struct super_block *sb)
693 {
694         return ll_s2sbi(sb)->ll_dt_exp;
695 }
696
697 /* don't need an addref as the sb_info should be holding one */
698 static inline struct obd_export *ll_s2mdexp(struct super_block *sb)
699 {
700         return ll_s2sbi(sb)->ll_md_exp;
701 }
702
703 static inline struct client_obd *sbi2mdc(struct ll_sb_info *sbi)
704 {
705         struct obd_device *obd = sbi->ll_md_exp->exp_obd;
706         if (obd == NULL)
707                 LBUG();
708         return &obd->u.cli;
709 }
710
711 // FIXME: replace the name of this with LL_SB to conform to kernel stuff
712 static inline struct ll_sb_info *ll_i2sbi(struct inode *inode)
713 {
714         return ll_s2sbi(inode->i_sb);
715 }
716
717 static inline struct obd_export *ll_i2dtexp(struct inode *inode)
718 {
719         return ll_s2dtexp(inode->i_sb);
720 }
721
722 static inline struct obd_export *ll_i2mdexp(struct inode *inode)
723 {
724         return ll_s2mdexp(inode->i_sb);
725 }
726
727 static inline struct lu_fid *ll_inode2fid(struct inode *inode)
728 {
729         struct lu_fid *fid;
730         LASSERT(inode != NULL);
731         fid = &ll_i2info(inode)->lli_fid;
732         LASSERT(fid_is_igif(fid) || fid_ver(fid) == 0);
733         return fid;
734 }
735
736 static inline int ll_mds_max_easize(struct super_block *sb)
737 {
738         return sbi2mdc(ll_s2sbi(sb))->cl_max_mds_easize;
739 }
740
741 static inline __u64 ll_file_maxbytes(struct inode *inode)
742 {
743         return ll_i2info(inode)->lli_maxbytes;
744 }
745
746 /* llite/xattr.c */
747 int ll_setxattr(struct dentry *dentry, const char *name,
748                 const void *value, size_t size, int flags);
749 ssize_t ll_getxattr(struct dentry *dentry, const char *name,
750                     void *buffer, size_t size);
751 ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size);
752 int ll_removexattr(struct dentry *dentry, const char *name);
753
754 /* llite/remote_perm.c */
755 extern cfs_mem_cache_t *ll_remote_perm_cachep;
756 extern cfs_mem_cache_t *ll_rmtperm_hash_cachep;
757
758 struct hlist_head *alloc_rmtperm_hash(void);
759 void free_rmtperm_hash(struct hlist_head *hash);
760 int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm);
761 int lustre_check_remote_perm(struct inode *inode, int mask);
762
763 /* llite/llite_fid.c */
764 ino_t ll_fid_build_ino(struct ll_sb_info *sbi, struct lu_fid *fid);
765
766 /* llite/llite_capa.c */
767 extern cfs_timer_t ll_capa_timer;
768
769 int ll_capa_thread_start(void);
770 void ll_capa_thread_stop(void);
771 void ll_capa_timer_callback(unsigned long unused);
772
773 struct obd_capa *ll_add_capa(struct inode *inode, struct obd_capa *ocapa);
774 int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa);
775
776 void ll_capa_open(struct inode *inode);
777 void ll_capa_close(struct inode *inode);
778
779 struct obd_capa *ll_mdscapa_get(struct inode *inode);
780 struct obd_capa *ll_osscapa_get(struct inode *inode, __u64 opc);
781
782 void ll_truncate_free_capa(struct obd_capa *ocapa);
783 void ll_clear_inode_capas(struct inode *inode);
784 void ll_print_capa_stat(struct ll_sb_info *sbi);
785
786 #endif /* LLITE_INTERNAL_H */