1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
5 #ifndef LLITE_INTERNAL_H
6 #define LLITE_INTERNAL_H
8 #include <linux/ext2_fs.h>
9 #ifdef CONFIG_FS_POSIX_ACL
10 # include <linux/fs.h>
12 # include <linux/xattr_acl.h>
14 #ifdef HAVE_LINUX_POSIX_ACL_XATTR_H
15 # include <linux/posix_acl_xattr.h>
19 #include <lustre_debug.h>
20 #include <lustre_ver.h>
21 #include <linux/lustre_version.h>
22 #include <lustre_disk.h> /* for s2sbi */
25 struct lustre_intent_data {
26 __u64 it_lock_handle[2];
32 /* If there is no FMODE_EXEC defined, make it to match nothing */
37 #define LL_IT2STR(it) ((it) ? ldlm_it2str((it)->it_op) : "0")
38 #define LUSTRE_FPRIVATE(file) ((file)->private_data)
40 #ifdef HAVE_VFS_INTENT_PATCHES
41 static inline struct lookup_intent *ll_nd2it(struct nameidata *nd)
43 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
51 struct ll_dentry_data {
54 struct obd_client_handle lld_cwd_och;
55 struct obd_client_handle lld_mnt_och;
56 #ifndef HAVE_VFS_INTENT_PATCHES
57 struct lookup_intent *lld_it;
61 #define ll_d2d(de) ((struct ll_dentry_data*) de->d_fsdata)
63 extern struct file_operations ll_pgcache_seq_fops;
65 #define LLI_INODE_MAGIC 0x111d0de5
66 #define LLI_INODE_DEAD 0xdeadd00d
67 #define LLI_F_HAVE_OST_SIZE_LOCK 0
68 #define LLI_F_HAVE_MDS_SIZE_LOCK 1
69 #define LLI_F_CONTENDED 2
70 #define LLI_F_SRVLOCK 3
72 struct ll_inode_info {
74 struct semaphore lli_size_sem; /* protect open and change size */
75 void *lli_size_sem_owner;
76 struct semaphore lli_write_sem;
77 struct lov_stripe_md *lli_smd;
78 char *lli_symlink_name;
81 unsigned long lli_flags;
82 cfs_time_t lli_contention_time;
84 /* this lock protects s_d_w and p_w_ll and mmap_cnt */
86 #ifdef HAVE_CLOSE_THREAD
87 struct list_head lli_pending_write_llaps;
88 struct list_head lli_close_item;
89 int lli_send_done_writing;
91 atomic_t lli_mmap_cnt;
93 /* for writepage() only to communicate to fsync */
96 struct posix_acl *lli_posix_acl;
98 struct list_head lli_dead_list;
100 struct semaphore lli_och_sem; /* Protects access to och pointers
101 and their usage counters */
102 /* We need all three because every inode may be opened in different
104 struct obd_client_handle *lli_mds_read_och;
105 __u64 lli_open_fd_read_count;
106 struct obd_client_handle *lli_mds_write_och;
107 __u64 lli_open_fd_write_count;
108 struct obd_client_handle *lli_mds_exec_och;
109 __u64 lli_open_fd_exec_count;
111 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
112 struct inode lli_vfs_inode;
115 /* metadata stat-ahead */
116 pid_t lli_opendir_pid;
117 struct ll_statahead_info *lli_sai;
121 * Locking to guarantee consistency of non-atomic updates to long long i_size,
122 * consistency between file size and KMS, and consistency within
123 * ->lli_smd->lsm_oinfo[]'s.
125 * Implemented by ->lli_size_sem and ->lsm_sem, nested in that order.
128 void ll_inode_size_lock(struct inode *inode, int lock_lsm);
129 void ll_inode_size_unlock(struct inode *inode, int unlock_lsm);
131 // FIXME: replace the name of this with LL_I to conform to kernel stuff
132 // static inline struct ll_inode_info *LL_I(struct inode *inode)
133 static inline struct ll_inode_info *ll_i2info(struct inode *inode)
135 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
136 return container_of(inode, struct ll_inode_info, lli_vfs_inode);
138 CLASSERT(sizeof(inode->u) >= sizeof(struct ll_inode_info));
139 return (struct ll_inode_info *)&(inode->u.generic_ip);
143 /* default to about 40meg of readahead on a given system. That much tied
144 * up in 512k readahead requests serviced at 40ms each is about 1GB/s. */
145 #define SBI_DEFAULT_READAHEAD_MAX (40UL << (20 - CFS_PAGE_SHIFT))
147 /* default to read-ahead full files smaller than 2MB on the second read */
148 #define SBI_DEFAULT_READAHEAD_WHOLE_MAX (2UL << (20 - CFS_PAGE_SHIFT))
153 RA_STAT_DISTANT_READPAGE,
154 RA_STAT_MISS_IN_WINDOW,
155 RA_STAT_FAILED_GRAB_PAGE,
156 RA_STAT_FAILED_MATCH,
161 RA_STAT_MAX_IN_FLIGHT,
162 RA_STAT_WRONG_GRAB_PAGE,
167 unsigned long ra_cur_pages;
168 unsigned long ra_max_pages;
169 unsigned long ra_max_read_ahead_whole_pages;
170 unsigned long ra_stats[_NR_RA_STAT];
173 /* LL_HIST_MAX=32 causes an overflow */
174 #define LL_HIST_MAX 28
175 #define LL_HIST_START 12 /* buckets start at 2^12 = 4k */
176 #define LL_PROCESS_HIST_MAX 10
177 struct per_process_info {
179 struct obd_histogram pp_r_hist;
180 struct obd_histogram pp_w_hist;
183 /* pp_extents[LL_PROCESS_HIST_MAX] will hold the combined process info */
184 struct ll_rw_extents_info {
185 struct per_process_info pp_extents[LL_PROCESS_HIST_MAX + 1];
188 #define LL_OFFSET_HIST_MAX 100
189 struct ll_rw_process_info {
192 loff_t rw_range_start;
194 loff_t rw_last_file_pos;
196 size_t rw_smallest_extent;
197 size_t rw_largest_extent;
198 struct file *rw_last_file;
202 enum stats_track_type {
203 STATS_TRACK_ALL = 0, /* track all processes */
204 STATS_TRACK_PID, /* track process with this pid */
205 STATS_TRACK_PPID, /* track processes with this ppid */
206 STATS_TRACK_GID, /* track processes with this gid */
210 /* flags for sbi->ll_flags */
211 #define LL_SBI_NOLCK 0x01 /* DLM locking disabled (directio-only) */
212 #define LL_SBI_DATA_CHECKSUM 0x02 /* checksum each page on the wire */
213 #define LL_SBI_FLOCK 0x04
214 #define LL_SBI_USER_XATTR 0x08 /* support user xattr */
215 #define LL_SBI_ACL 0x10 /* support ACL */
216 #define LL_SBI_JOIN 0x20 /* support JOIN */
217 #define LL_SBI_LOCALFLOCK 0x40 /* Local flocks support by kernel */
218 #define LL_SBI_LRU_RESIZE 0x80 /* support lru resize */
219 #define LL_SBI_LLITE_CHECKSUM 0x100 /* checksum each page in memory */
221 /* default value for ll_sb_info->contention_time */
222 #define SBI_DEFAULT_CONTENTION_SECONDS 60
225 struct list_head ll_list;
226 /* this protects pglist and ra_info. It isn't safe to
227 * grab from interrupt contexts */
229 spinlock_t ll_pp_extent_lock; /* Lock for pp_extent entries */
230 spinlock_t ll_process_lock; /* Lock for ll_rw_process_info */
231 struct obd_uuid ll_sb_uuid;
232 struct obd_export *ll_mdc_exp;
233 struct obd_export *ll_osc_exp;
234 struct proc_dir_entry *ll_proc_root;
235 obd_id ll_rootino; /* number of root inode */
238 struct list_head ll_conn_chain; /* per-conn chain of SBs */
239 struct lustre_client_ocd ll_lco;
241 struct list_head ll_orphan_dentry_list; /*please don't ask -p*/
242 struct ll_close_queue *ll_lcq;
244 struct lprocfs_stats *ll_stats; /* lprocfs stats counter */
246 unsigned long ll_async_page_max;
247 unsigned long ll_async_page_count;
248 unsigned long ll_pglist_gen;
249 struct list_head ll_pglist; /* all pages (llap_pglist_item) */
251 unsigned ll_contention_time; /* seconds */
253 struct ll_ra_info ll_ra_info;
254 unsigned int ll_namelen;
255 struct file_operations *ll_fop;
257 #ifdef HAVE_EXPORT___IGET
258 struct list_head ll_deathrow; /* inodes to be destroyed (b1443) */
259 spinlock_t ll_deathrow_lock;
261 /* =0 - hold lock over whole read/write
262 * >0 - max. chunk to be read/written w/o lock re-acquiring */
263 unsigned long ll_max_rw_chunk;
266 struct ll_rw_extents_info ll_rw_extents_info;
267 int ll_extent_process_count;
268 struct ll_rw_process_info ll_rw_process_info[LL_PROCESS_HIST_MAX];
269 unsigned int ll_offset_process_count;
270 struct ll_rw_process_info ll_rw_offset_info[LL_OFFSET_HIST_MAX];
271 unsigned int ll_rw_offset_entry_count;
272 enum stats_track_type ll_stats_track_type;
273 int ll_stats_track_id;
275 dev_t ll_sdev_orig; /* save s_dev before assign for
278 /* metadata stat-ahead */
279 unsigned int ll_sa_count; /* current statahead RPCs */
280 unsigned int ll_sa_max; /* max statahead RPCs */
281 unsigned int ll_sa_wrong; /* statahead thread stopped for
283 unsigned int ll_sa_total; /* statahead thread started
285 unsigned long long ll_sa_blocked; /* ls count waiting for
287 unsigned long long ll_sa_cached; /* ls count got in cache */
290 #define LL_DEFAULT_MAX_RW_CHUNK (32 * 1024 * 1024)
295 struct task_struct *lrr_reader;
296 struct list_head lrr_linkage;
300 * per file-descriptor read-ahead data.
302 struct ll_readahead_state {
305 * index of the last page that read(2) needed and that wasn't in the
306 * cache. Used by ras_update() to detect seeks.
308 * XXX nikita: if access seeks into cached region, Lustre doesn't see
311 unsigned long ras_last_readpage;
313 * number of pages read after last read-ahead window reset. As window
314 * is reset on each seek, this is effectively a number of consecutive
315 * accesses. Maybe ->ras_accessed_in_window is better name.
317 * XXX nikita: window is also reset (by ras_update()) when Lustre
318 * believes that memory pressure evicts read-ahead pages. In that
319 * case, it probably doesn't make sense to expand window to
320 * PTLRPC_MAX_BRW_PAGES on the third access.
322 unsigned long ras_consecutive_pages;
324 * number of read requests after the last read-ahead window reset
325 * As window is reset on each seek, this is effectively the number
326 * on consecutive read request and is used to trigger read-ahead.
328 unsigned long ras_consecutive_requests;
330 * Parameters of current read-ahead window. Handled by
331 * ras_update(). On the initial access to the file or after a seek,
332 * window is reset to 0. After 3 consecutive accesses, window is
333 * expanded to PTLRPC_MAX_BRW_PAGES. Afterwards, window is enlarged by
334 * PTLRPC_MAX_BRW_PAGES chunks up to ->ra_max_pages.
336 unsigned long ras_window_start, ras_window_len;
338 * Where next read-ahead should start at. This lies within read-ahead
339 * window. Read-ahead window is read in pieces rather than at once
340 * because: 1. lustre limits total number of pages under read-ahead by
341 * ->ra_max_pages (see ll_ra_count_get()), 2. client cannot read pages
342 * not covered by DLM lock.
344 unsigned long ras_next_readahead;
346 * Total number of ll_file_read requests issued, reads originating
347 * due to mmap are not counted in this total. This value is used to
348 * trigger full file read-ahead after multiple reads to a small file.
350 unsigned long ras_requests;
352 * Page index with respect to the current request, these value
353 * will not be accurate when dealing with reads issued via mmap.
355 unsigned long ras_request_index;
357 * list of struct ll_ra_read's one per read(2) call current in
358 * progress against this file descriptor. Used by read-ahead code,
359 * protected by ->ras_lock.
361 struct list_head ras_read_beads;
364 extern cfs_mem_cache_t *ll_file_data_slab;
365 struct lustre_handle;
366 struct ll_file_data {
367 struct ll_readahead_state fd_ras;
369 struct lustre_handle fd_cwlockh;
370 unsigned long fd_gid;
374 struct lov_stripe_md;
376 extern spinlock_t inode_lock;
378 extern struct proc_dir_entry *proc_lustre_fs_root;
380 static inline struct inode *ll_info2i(struct ll_inode_info *lli)
382 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
383 return &lli->lli_vfs_inode;
385 return list_entry(lli, struct inode, u.generic_ip);
390 struct inode *icbd_parent;
391 struct dentry **icbd_childp;
395 void ll_i2gids(__u32 *suppgids, struct inode *i1,struct inode *i2);
397 #define LLAP_MAGIC 98764321
399 extern cfs_mem_cache_t *ll_async_page_slab;
400 extern size_t ll_async_page_slab_size;
401 struct ll_async_page {
403 /* only trust these if the page lock is providing exclusion */
404 unsigned int llap_write_queued:1,
405 llap_defer_uptodate:1,
410 llap_lockless_io_page:1;
412 struct page *llap_page;
413 struct list_head llap_pending_write;
414 struct list_head llap_pglist_item;
415 /* checksum for paranoid I/O debugging */
420 * enumeration of llap_from_page() call-sites. Used to export statistics in
421 * /proc/fs/lustre/llite/fsN/dump_page_cache.
424 LLAP_ORIGIN_UNKNOWN = 0,
425 LLAP_ORIGIN_READPAGE,
426 LLAP_ORIGIN_READAHEAD,
427 LLAP_ORIGIN_COMMIT_WRITE,
428 LLAP_ORIGIN_WRITEPAGE,
429 LLAP_ORIGIN_REMOVEPAGE,
430 LLAP_ORIGIN_LOCKLESS_IO,
433 extern char *llap_origins[];
435 #ifdef HAVE_REGISTER_CACHE
436 #define ll_register_cache(cache) register_cache(cache)
437 #define ll_unregister_cache(cache) unregister_cache(cache)
439 #define ll_register_cache(cache) do {} while (0)
440 #define ll_unregister_cache(cache) do {} while (0)
443 void ll_ra_read_in(struct file *f, struct ll_ra_read *rar);
444 void ll_ra_read_ex(struct file *f, struct ll_ra_read *rar);
445 struct ll_ra_read *ll_ra_read_get(struct file *f);
447 /* llite/lproc_llite.c */
449 int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
450 struct super_block *sb, char *osc, char *mdc);
451 void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi);
452 void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count);
453 void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars);
455 static inline int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
456 struct super_block *sb, char *osc, char *mdc){return 0;}
457 static inline void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi) {}
458 static void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) {}
459 static void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars)
461 memset(lvars, 0, sizeof(*lvars));
467 extern struct file_operations ll_dir_operations;
468 extern struct inode_operations ll_dir_inode_operations;
470 struct page *ll_get_dir_page(struct inode *dir, unsigned long n);
472 * p is at least 6 bytes before the end of page
474 typedef struct ext2_dir_entry_2 ext2_dirent;
476 static inline ext2_dirent *ext2_next_entry(ext2_dirent *p)
478 return (ext2_dirent *)((char*)p + le16_to_cpu(p->rec_len));
481 static inline unsigned
482 ext2_validate_entry(char *base, unsigned offset, unsigned mask)
484 ext2_dirent *de = (ext2_dirent*)(base + offset);
485 ext2_dirent *p = (ext2_dirent*)(base + (offset&mask));
486 while ((char*)p < (char*)de)
487 p = ext2_next_entry(p);
488 return (char *)p - base;
491 static inline void ext2_put_page(struct page *page)
494 page_cache_release(page);
497 static inline unsigned long dir_pages(struct inode *inode)
499 return (inode->i_size + CFS_PAGE_SIZE - 1) >> CFS_PAGE_SHIFT;
503 int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir);
504 struct inode *ll_iget(struct super_block *sb, ino_t hash,
505 struct lustre_md *lic);
506 int ll_mdc_cancel_unused(struct lustre_handle *, struct inode *, int flags,
508 int ll_mdc_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *,
509 void *data, int flag);
510 int ll_prepare_mdc_op_data(struct mdc_op_data *,
511 struct inode *i1, struct inode *i2,
512 const char *name, int namelen, int mode, void *data);
513 #ifndef HAVE_VFS_INTENT_PATCHES
514 struct lookup_intent *ll_convert_intent(struct open_intent *oit,
517 void ll_pin_extent_cb(void *data);
518 int ll_page_removal_cb(void *data, int discard);
519 int ll_extent_lock_cancel_cb(struct ldlm_lock *lock, struct ldlm_lock_desc *new,
520 void *data, int flag);
521 int lookup_it_finish(struct ptlrpc_request *request, int offset,
522 struct lookup_intent *it, void *data);
523 void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry);
526 int ll_prepare_write(struct file *, struct page *, unsigned from, unsigned to);
527 int ll_commit_write(struct file *, struct page *, unsigned from, unsigned to);
528 int ll_writepage(struct page *page);
529 void ll_inode_fill_obdo(struct inode *inode, int cmd, struct obdo *oa);
530 int ll_ap_completion(void *data, int cmd, struct obdo *oa, int rc);
531 int llap_shrink_cache(struct ll_sb_info *sbi, int shrink_fraction);
532 extern struct cache_definition ll_cache_definition;
533 void ll_removepage(struct page *page);
534 int ll_readpage(struct file *file, struct page *page);
535 struct ll_async_page *llap_cast_private(struct page *page);
536 void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras);
537 void ll_ra_accounting(struct ll_async_page *llap,struct address_space *mapping);
538 void ll_truncate(struct inode *inode);
539 int ll_file_punch(struct inode *, loff_t, int);
540 ssize_t ll_file_lockless_io(struct file *, char *, size_t, loff_t *, int);
541 void ll_clear_file_contended(struct inode*);
542 int ll_sync_page_range(struct inode *, struct address_space *, loff_t, size_t);
545 extern struct file_operations ll_file_operations;
546 extern struct file_operations ll_file_operations_flock;
547 extern struct file_operations ll_file_operations_noflock;
548 extern struct inode_operations ll_file_inode_operations;
549 extern int ll_inode_revalidate_it(struct dentry *, struct lookup_intent *);
550 extern int ll_have_md_lock(struct inode *inode, __u64 bits);
551 int ll_extent_lock(struct ll_file_data *, struct inode *,
552 struct lov_stripe_md *, int mode, ldlm_policy_data_t *,
553 struct lustre_handle *, int ast_flags);
554 int ll_extent_unlock(struct ll_file_data *, struct inode *,
555 struct lov_stripe_md *, int mode, struct lustre_handle *);
556 int ll_file_open(struct inode *inode, struct file *file);
557 int ll_file_release(struct inode *inode, struct file *file);
558 int ll_lsm_getattr(struct obd_export *, struct lov_stripe_md *, struct obdo *);
559 int ll_glimpse_ioctl(struct ll_sb_info *sbi,
560 struct lov_stripe_md *lsm, lstat_t *st);
561 int ll_glimpse_size(struct inode *inode, int ast_flags);
562 int ll_local_open(struct file *file,
563 struct lookup_intent *it, struct ll_file_data *fd,
564 struct obd_client_handle *och);
565 int ll_release_openhandle(struct dentry *, struct lookup_intent *);
566 int ll_mdc_close(struct obd_export *mdc_exp, struct inode *inode,
568 int ll_mdc_real_close(struct inode *inode, int flags);
569 extern void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, struct file
570 *file, size_t count, int rw);
571 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
572 int ll_getattr_it(struct vfsmount *mnt, struct dentry *de,
573 struct lookup_intent *it, struct kstat *stat);
574 int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat);
576 struct ll_file_data *ll_file_data_get(void);
577 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
578 int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd);
580 int ll_inode_permission(struct inode *inode, int mask);
582 int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
583 int flags, struct lov_user_md *lum,
585 int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename,
586 struct lov_mds_md **lmm, int *lmm_size,
587 struct ptlrpc_request **request);
588 int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
590 int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmm,
591 int *lmm_size, struct ptlrpc_request **request);
594 void ll_intent_drop_lock(struct lookup_intent *);
595 void ll_intent_release(struct lookup_intent *);
596 extern void ll_set_dd(struct dentry *de);
597 int ll_drop_dentry(struct dentry *dentry);
598 void ll_unhash_aliases(struct inode *);
599 void ll_frob_intent(struct lookup_intent **itp, struct lookup_intent *deft);
600 void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry);
601 int ll_dcompare(struct dentry *parent, struct qstr *d_name, struct qstr *name);
602 int revalidate_it_finish(struct ptlrpc_request *request, int offset,
603 struct lookup_intent *it, struct dentry *de);
605 /* llite/llite_lib.c */
606 extern struct super_operations lustre_super_operations;
608 char *ll_read_opt(const char *opt, char *data);
609 void ll_lli_init(struct ll_inode_info *lli);
610 int ll_fill_super(struct super_block *sb);
611 void ll_put_super(struct super_block *sb);
612 void ll_kill_super(struct super_block *sb);
613 struct inode *ll_inode_from_lock(struct ldlm_lock *lock);
614 void ll_clear_inode(struct inode *inode);
615 int ll_setattr_raw(struct inode *inode, struct iattr *attr);
616 int ll_setattr(struct dentry *de, struct iattr *attr);
617 #ifndef HAVE_STATFS_DENTRY_PARAM
618 int ll_statfs(struct super_block *sb, struct kstatfs *sfs);
620 int ll_statfs(struct dentry *de, struct kstatfs *sfs);
622 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
624 void ll_update_inode(struct inode *inode, struct lustre_md *md);
625 void ll_read_inode2(struct inode *inode, void *opaque);
626 int ll_iocontrol(struct inode *inode, struct file *file,
627 unsigned int cmd, unsigned long arg);
628 #ifdef HAVE_UMOUNTBEGIN_VFSMOUNT
629 void ll_umount_begin(struct vfsmount *vfsmnt, int flags);
631 void ll_umount_begin(struct super_block *sb);
633 int ll_remount_fs(struct super_block *sb, int *flags, char *data);
634 int ll_prep_inode(struct obd_export *exp, struct inode **inode,
635 struct ptlrpc_request *req, int offset, struct super_block *);
636 void lustre_dump_dentry(struct dentry *, int recur);
637 void lustre_dump_inode(struct inode *);
638 struct ll_async_page *llite_pglist_next_llap(struct ll_sb_info *sbi,
639 struct list_head *list);
640 int ll_obd_statfs(struct inode *inode, void *arg);
641 int ll_get_max_mdsize(struct ll_sb_info *sbi, int *max_mdsize);
642 int ll_process_config(struct lustre_cfg *lcfg);
644 /* llite/llite_nfs.c */
645 extern struct export_operations lustre_export_operations;
646 __u32 get_uuid2int(const char *name, int len);
647 struct dentry *ll_fh_to_dentry(struct super_block *sb, __u32 *data, int len,
648 int fhtype, int parent);
649 int ll_dentry_to_fh(struct dentry *, __u32 *datap, int *lenp, int need_parent);
651 /* llite/special.c */
652 extern struct inode_operations ll_special_inode_operations;
653 extern struct file_operations ll_special_chr_inode_fops;
654 extern struct file_operations ll_special_chr_file_fops;
655 extern struct file_operations ll_special_blk_inode_fops;
656 extern struct file_operations ll_special_fifo_inode_fops;
657 extern struct file_operations ll_special_fifo_file_fops;
658 extern struct file_operations ll_special_sock_inode_fops;
660 /* llite/symlink.c */
661 extern struct inode_operations ll_fast_symlink_inode_operations;
663 /* llite/llite_close.c */
664 struct ll_close_queue {
666 struct list_head lcq_list;
667 wait_queue_head_t lcq_waitq;
668 struct completion lcq_comp;
671 #ifdef HAVE_CLOSE_THREAD
672 void llap_write_pending(struct inode *inode, struct ll_async_page *llap);
673 void llap_write_complete(struct inode *inode, struct ll_async_page *llap);
674 void ll_open_complete(struct inode *inode);
675 int ll_is_inode_dirty(struct inode *inode);
676 void ll_try_done_writing(struct inode *inode);
677 void ll_queue_done_writing(struct inode *inode);
679 static inline void llap_write_pending(struct inode *inode,
680 struct ll_async_page *llap) { return; };
681 static inline void llap_write_complete(struct inode *inode,
682 struct ll_async_page *llap) { return; };
683 static inline void ll_open_complete(struct inode *inode) { return; };
684 static inline int ll_is_inode_dirty(struct inode *inode) { return 0; };
685 static inline void ll_try_done_writing(struct inode *inode) { return; };
686 static inline void ll_queue_done_writing(struct inode *inode) { return; };
687 //static inline void ll_close_thread_shutdown(struct ll_close_queue *lcq) { return; };
688 //static inline int ll_close_thread_start(struct ll_close_queue **lcq_ret) { return 0; };
690 void ll_close_thread_shutdown(struct ll_close_queue *lcq);
691 int ll_close_thread_start(struct ll_close_queue **lcq_ret);
693 /* llite/llite_mmap.c */
694 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
695 typedef struct rb_root rb_root_t;
696 typedef struct rb_node rb_node_t;
699 struct ll_lock_tree_node;
700 struct ll_lock_tree {
702 struct list_head lt_locked_list;
703 struct ll_file_data *lt_fd;
706 int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last);
707 int ll_file_mmap(struct file * file, struct vm_area_struct * vma);
708 struct ll_lock_tree_node * ll_node_from_inode(struct inode *inode, __u64 start,
709 __u64 end, ldlm_mode_t mode);
710 int ll_tree_lock(struct ll_lock_tree *tree,
711 struct ll_lock_tree_node *first_node,
712 const char *buf, size_t count, int ast_flags);
713 int ll_tree_unlock(struct ll_lock_tree *tree);
715 #define ll_s2sbi(sb) (s2lsi(sb)->lsi_llsbi)
717 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
718 static inline __u64 ll_ts2u64(struct timespec *time)
720 __u64 t = time->tv_sec;
724 static inline __u64 ll_ts2u64(time_t *time)
730 /* don't need an addref as the sb_info should be holding one */
731 static inline struct obd_export *ll_s2obdexp(struct super_block *sb)
733 return ll_s2sbi(sb)->ll_osc_exp;
736 /* don't need an addref as the sb_info should be holding one */
737 static inline struct obd_export *ll_s2mdcexp(struct super_block *sb)
739 return ll_s2sbi(sb)->ll_mdc_exp;
742 static inline struct client_obd *sbi2mdc(struct ll_sb_info *sbi)
744 struct obd_device *obd = sbi->ll_mdc_exp->exp_obd;
750 // FIXME: replace the name of this with LL_SB to conform to kernel stuff
751 static inline struct ll_sb_info *ll_i2sbi(struct inode *inode)
753 return ll_s2sbi(inode->i_sb);
756 static inline struct obd_export *ll_i2obdexp(struct inode *inode)
758 return ll_s2obdexp(inode->i_sb);
761 static inline struct obd_export *ll_i2mdcexp(struct inode *inode)
763 return ll_s2mdcexp(inode->i_sb);
766 static inline void ll_inode2fid(struct ll_fid *fid, struct inode *inode)
768 mdc_pack_fid(fid, inode->i_ino, inode->i_generation,
769 inode->i_mode & S_IFMT);
772 static inline int ll_mds_max_easize(struct super_block *sb)
774 return sbi2mdc(ll_s2sbi(sb))->cl_max_mds_easize;
777 static inline __u64 ll_file_maxbytes(struct inode *inode)
779 return ll_i2info(inode)->lli_maxbytes;
783 int ll_setxattr(struct dentry *dentry, const char *name,
784 const void *value, size_t size, int flags);
785 ssize_t ll_getxattr(struct dentry *dentry, const char *name,
786 void *buffer, size_t size);
787 ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size);
788 int ll_removexattr(struct dentry *dentry, const char *name);
792 #define LL_STATAHEAD_MIN 1
793 #define LL_STATAHEAD_DEF 32
794 #define LL_STATAHEAD_MAX 10000
796 /* per inode struct, for dir only */
797 struct ll_statahead_info {
798 struct inode *sai_inode;
799 atomic_t sai_refc; /* when access this struct, hold
801 unsigned int sai_max; /* max ahead of lookup */
802 unsigned int sai_sent; /* stat requests sent count */
803 unsigned int sai_replied; /* stat requests which received
805 unsigned int sai_cached; /* UPDATE lock cached locally
807 unsigned int sai_hit; /* hit count */
808 unsigned int sai_miss; /* miss count */
809 unsigned int sai_consecutive_miss; /* consecutive miss */
810 unsigned sai_ls_all:1; /* ls -al, do stat-ahead for
812 struct ptlrpc_thread sai_thread; /* stat-ahead thread */
813 struct list_head sai_entries; /* stat-ahead entries */
814 unsigned int sai_entries_nr; /* stat-ahead entries count */
817 int ll_statahead_enter(struct inode *dir, struct dentry **dentry, int lookup);
818 void ll_statahead_exit(struct dentry *dentry, int result);
819 void ll_stop_statahead(struct inode *inode);
821 /* llite ioctl register support rountine */
828 #define LLIOC_MAX_CMD 256
831 * Rules to write a callback function:
834 * @magic: Dynamic ioctl call routine will feed this vaule with the pointer
835 * returned to ll_iocontrol_register. Callback functions should use this
836 * data to check the potential collasion of ioctl cmd. If collasion is
837 * found, callback function should return LLIOC_CONT.
838 * @rcp: The result of ioctl command.
841 * If @magic matches the pointer returned by ll_iocontrol_data, the
842 * callback should return LLIOC_STOP; return LLIOC_STOP otherwise.
844 typedef enum llioc_iter (*llioc_callback_t)(struct inode *inode,
845 struct file *file, unsigned int cmd, unsigned long arg,
846 void *magic, int *rcp);
848 enum llioc_iter ll_iocontrol_call(struct inode *inode, struct file *file,
849 unsigned int cmd, unsigned long arg, int *rcp);
851 /* export functions */
852 /* Register ioctl block dynamatically for a regular file.
854 * @cmd: the array of ioctl command set
855 * @count: number of commands in the @cmd
856 * @cb: callback function, it will be called if an ioctl command is found to
857 * belong to the command list @cmd.
860 * A magic pointer will be returned if success;
861 * otherwise, NULL will be returned.
863 void *ll_iocontrol_register(llioc_callback_t cb, int count, unsigned int *cmd);
864 void ll_iocontrol_unregister(void *magic);
868 #endif /* LLITE_INTERNAL_H */