1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2003 Cluster File Systems, Inc.
6 * This code is issued under the GNU General Public License.
7 * See the file COPYING in this distribution
10 #ifndef LLITE_INTERNAL_H
11 #define LLITE_INTERNAL_H
13 /* default to about 40meg of readahead on a given system. That much tied
14 * up in 512k readahead requests serviced at 40ms each is about 1GB/s. */
15 #define SBI_DEFAULT_RA_MAX ((40 << 20) >> PAGE_CACHE_SHIFT)
20 RA_STAT_DISTANT_READPAGE,
21 RA_STAT_MISS_IN_WINDOW,
27 RA_STAT_MAX_IN_FLIGHT,
32 unsigned long ra_cur_pages;
33 unsigned long ra_max_pages;
34 unsigned long ra_stats[_NR_RA_STAT];
37 /* after roughly how long should we remove an inactive mount? */
38 #define GNS_MOUNT_TIMEOUT 120
40 /* how often should the GNS timer look for mounts to cleanup? */
41 #define GNS_TICK_TIMEOUT 1
43 /* how many times GNS will try to wait for 1 second for mount */
44 #define GNS_WAIT_ATTEMPTS 10
47 /* this protects pglist and max_r_a_pages. It isn't safe to grab from
48 * interrupt contexts. */
51 struct obd_uuid ll_sb_uuid;
52 struct obd_export *ll_md_exp;
53 struct obd_export *ll_dt_exp;
54 struct lov_desc ll_dt_desc;
55 struct proc_dir_entry *ll_proc_root;
56 struct lustre_id ll_rootid; /* root lustre id */
58 struct lustre_mount_data *ll_lmd;
62 struct list_head ll_conn_chain; /* per-conn chain of SBs */
64 struct hlist_head ll_orphan_dentry_list; /*please don't ask -p*/
65 struct ll_close_queue *ll_lcq;
67 struct lprocfs_stats *ll_stats; /* lprocfs stats counter */
69 unsigned long ll_pglist_gen;
70 struct list_head ll_pglist;
72 struct ll_ra_info ll_ra_info;
74 /* times spent waiting for locks in each call site. These are
75 * all protected by the ll_lock */
76 struct obd_service_time ll_read_stime;
77 struct obd_service_time ll_write_stime;
78 struct obd_service_time ll_grouplock_stime;
79 struct obd_service_time ll_seek_stime;
80 struct obd_service_time ll_setattr_stime;
81 struct obd_service_time ll_brw_stime;
82 // struct obd_service_time ll_done_stime;
84 int ll_config_version; /* last-applied update */
86 /* list of GNS mounts; protected by the dcache_lock */
87 struct list_head ll_mnt_list;
89 struct semaphore ll_gns_sem;
90 spinlock_t ll_gns_lock;
91 wait_queue_head_t ll_gns_waitq;
93 struct timer_list ll_gns_timer;
94 struct list_head ll_gns_sbi_head;
96 unsigned long ll_gns_tick;
97 unsigned long ll_gns_timeout;
98 struct completion ll_gns_mount_finished;
101 char ll_gns_upcall[PATH_MAX];
103 /* mount object entry name */
104 char ll_gns_oname[PATH_MAX];
108 struct completion gc_starting;
109 struct completion gc_finishing;
112 /* mounting states */
113 #define LL_GNS_IDLE (1 << 0)
114 #define LL_GNS_MOUNTING (1 << 1)
115 #define LL_GNS_FINISHED (1 << 2)
117 /* mounts checking flags */
118 #define LL_GNS_UMOUNT (1 << 0)
119 #define LL_GNS_CHECK (1 << 1)
121 struct ll_readahead_state {
123 unsigned long ras_last_readpage, ras_consecutive;
124 unsigned long ras_window_start, ras_window_len;
125 unsigned long ras_next_readahead;
129 extern kmem_cache_t *ll_file_data_slab;
130 extern kmem_cache_t *ll_intent_slab;
131 struct lustre_handle;
132 struct ll_file_data {
133 struct obd_client_handle fd_mds_och;
134 struct ll_readahead_state fd_ras;
136 struct lustre_handle fd_cwlockh;
137 unsigned long fd_gid;
140 struct lov_stripe_md;
142 extern spinlock_t inode_lock;
144 extern void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi);
145 extern struct proc_dir_entry *proc_lustre_fs_root;
147 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
148 # define hlist_del_init list_del_init
151 static inline struct inode *ll_info2i(struct ll_inode_info *lli)
153 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
154 return &lli->lli_vfs_inode;
156 return list_entry(lli, struct inode, u.generic_ip);
162 struct inode *icbd_parent;
163 struct dentry **icbd_childp;
167 #define LLAP_MAGIC 98764321
169 struct ll_async_page {
172 struct page *llap_page;
173 struct list_head llap_pending_write;
174 /* only trust these if the page lock is providing exclusion */
175 unsigned llap_write_queued:1,
176 llap_defer_uptodate:1,
179 struct list_head llap_proc_item;
182 #define LL_CDEBUG_PAGE(mask, page, fmt, arg...) \
183 CDEBUG(mask, "page %p map %p ind %lu priv %0lx: " fmt, \
184 page, page->mapping, page->index, page->private, ## arg)
186 /* llite/lproc_llite.c */
187 int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
188 struct super_block *sb, char *lov,
190 void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi);
193 extern struct file_operations ll_dir_operations;
194 extern struct inode_operations ll_dir_inode_operations;
197 int ll_objects_destroy(struct ptlrpc_request *request,
198 struct inode *dir, int offset);
199 struct inode *ll_iget(struct super_block *sb, ino_t hash,
200 struct lustre_md *lic);
201 struct dentry *ll_find_alias(struct inode *, struct dentry *);
202 int ll_mdc_cancel_unused(struct lustre_handle *, struct inode *, int flags,
204 int ll_mdc_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *,
205 void *data, int flag);
207 int ll_prepare_write(struct file *, struct page *, unsigned from, unsigned to);
208 int ll_commit_write(struct file *, struct page *, unsigned from, unsigned to);
209 int ll_writepage(struct page *page);
210 void ll_inode_fill_obdo(struct inode *inode, int cmd, struct obdo *oa);
211 void ll_ap_completion(void *data, int cmd, struct obdo *oa, int rc);
212 void ll_removepage(struct page *page);
213 int ll_readpage(struct file *file, struct page *page);
214 struct ll_async_page *llap_from_cookie(void *cookie);
215 struct ll_async_page *llap_from_page(struct page *page);
216 struct ll_async_page *llap_cast_private(struct page *page);
217 void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras);
219 void ll_ra_accounting(struct page *page, struct address_space *mapping);
220 void ll_truncate(struct inode *inode);
223 extern struct file_operations ll_file_operations;
224 extern struct inode_operations ll_file_inode_operations;
225 extern int ll_inode_revalidate_it(struct dentry *);
226 extern int ll_setxattr(struct dentry *, const char *, const void *,
228 extern int ll_getxattr(struct dentry *, const char *, void *, size_t);
229 extern int ll_listxattr(struct dentry *, char *, size_t);
230 extern int ll_removexattr(struct dentry *, const char *);
231 extern int ll_inode_permission(struct inode *, int, struct nameidata *);
232 int ll_refresh_lsm(struct inode *inode, struct lov_stripe_md *lsm);
233 int ll_extent_lock(struct ll_file_data *, struct inode *,
234 struct lov_stripe_md *, int mode, ldlm_policy_data_t *,
235 struct lustre_handle *, int ast_flags,
236 struct obd_service_time *);
237 int ll_extent_unlock(struct ll_file_data *, struct inode *,
238 struct lov_stripe_md *, int mode, struct lustre_handle *);
239 int ll_file_open(struct inode *inode, struct file *file);
240 int ll_file_release(struct inode *inode, struct file *file);
241 int ll_lsm_getattr(struct obd_export *, struct lov_stripe_md *, struct obdo *);
242 int ll_glimpse_size(struct inode *inode);
243 int ll_local_open(struct file *file, struct lookup_intent *it);
244 int ll_md_close(struct obd_export *md_exp, struct inode *inode,
246 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
247 int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat);
249 void ll_stime_record(struct ll_sb_info *sbi, struct timeval *start,
250 struct obd_service_time *stime);
253 void ll_intent_drop_lock(struct lookup_intent *);
254 void ll_intent_release(struct lookup_intent *);
255 int ll_intent_alloc(struct lookup_intent *);
256 void ll_intent_free(struct lookup_intent *it);
257 extern void ll_set_dd(struct dentry *de);
258 void ll_unhash_aliases(struct inode *);
259 void ll_frob_intent(struct lookup_intent **itp, struct lookup_intent *deft);
260 void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry);
261 int revalidate_it_finish(struct ptlrpc_request *request, int offset,
262 struct lookup_intent *it, struct dentry *de);
265 /* llite/llite_gns.c */
266 int ll_gns_start_thread(void);
267 void ll_gns_stop_thread(void);
269 int ll_gns_mount_object(struct dentry *dentry,
270 struct vfsmount *mnt);
271 int ll_gns_umount_object(struct vfsmount *mnt);
273 int ll_gns_check_mounts(struct ll_sb_info *sbi,
276 void ll_gns_timer_callback(unsigned long data);
277 void ll_gns_add_timer(struct ll_sb_info *sbi);
278 void ll_gns_del_timer(struct ll_sb_info *sbi);
280 /* llite/llite_lib.c */
281 extern struct super_operations lustre_super_operations;
283 char *ll_read_opt(const char *opt, char *data);
284 int ll_set_opt(const char *opt, char *data, int fl);
285 void ll_options(char *options, char **ost, char **mds, char **sec, int *flags);
286 void ll_lli_init(struct ll_inode_info *lli);
287 int ll_fill_super(struct super_block *sb, void *data, int silent);
288 int lustre_fill_super(struct super_block *sb, void *data, int silent);
289 void lustre_put_super(struct super_block *sb);
290 struct inode *ll_inode_from_lock(struct ldlm_lock *lock);
291 void ll_clear_inode(struct inode *inode);
292 int ll_attr2inode(struct inode *inode, struct iattr *attr, int trunc);
293 int ll_setattr_raw(struct inode *inode, struct iattr *attr);
294 int ll_setattr(struct dentry *de, struct iattr *attr);
295 int ll_statfs(struct super_block *sb, struct kstatfs *sfs);
296 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
297 unsigned long maxage);
298 void ll_update_inode(struct inode *inode, struct lustre_md *);
299 int it_disposition(struct lookup_intent *it, int flag);
300 void it_set_disposition(struct lookup_intent *it, int flag);
301 void ll_read_inode2(struct inode *inode, void *opaque);
302 void ll_delete_inode(struct inode *inode);
303 int ll_iocontrol(struct inode *inode, struct file *file,
304 unsigned int cmd, unsigned long arg);
305 void ll_umount_begin(struct super_block *sb);
306 int ll_prep_inode(struct obd_export *, struct obd_export *, struct inode **inode,
307 struct ptlrpc_request *req, int offset, struct super_block *);
308 __u32 get_uuid2int(const char *name, int len);
309 struct dentry *ll_fh_to_dentry(struct super_block *sb, __u32 *data, int len,
310 int fhtype, int parent);
311 int ll_dentry_to_fh(struct dentry *, __u32 *datap, int *lenp, int need_parent);
312 int null_if_equal(struct ldlm_lock *lock, void *data);
313 int ll_process_config_update(struct ll_sb_info *sbi, int clean);
315 /* llite/special.c */
316 extern struct inode_operations ll_special_inode_operations;
317 extern struct file_operations ll_special_chr_inode_fops;
318 extern struct file_operations ll_special_chr_file_fops;
319 extern struct file_operations ll_special_blk_inode_fops;
320 extern struct file_operations ll_special_fifo_inode_fops;
321 extern struct file_operations ll_special_fifo_file_fops;
322 extern struct file_operations ll_special_sock_inode_fops;
324 /* llite/symlink.c */
325 extern struct inode_operations ll_fast_symlink_inode_operations;
327 /* llite/llite_close.c */
328 struct ll_close_queue {
330 struct list_head lcq_list;
331 wait_queue_head_t lcq_waitq;
332 struct completion lcq_comp;
335 void llap_write_pending(struct inode *inode, struct ll_async_page *llap);
336 void llap_write_complete(struct inode *inode, struct ll_async_page *llap);
337 void ll_open_complete(struct inode *inode);
338 int ll_is_inode_dirty(struct inode *inode);
339 void ll_try_done_writing(struct inode *inode);
340 void ll_queue_done_writing(struct inode *inode);
341 void ll_close_thread_shutdown(struct ll_close_queue *lcq);
342 int ll_close_thread_start(struct ll_close_queue **lcq_ret);
345 /* llite/llite_mmap.c */
346 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
347 typedef struct rb_root rb_root_t;
348 typedef struct rb_node rb_node_t;
351 struct ll_lock_tree_node;
352 struct ll_lock_tree {
354 struct list_head lt_locked_list;
355 struct ll_file_data *lt_fd;
357 int ll_teardown_mmaps(struct address_space *mapping, __u64 first,
359 int ll_file_mmap(struct file * file, struct vm_area_struct * vma);
360 struct ll_lock_tree_node * ll_node_from_inode(struct inode *inode, __u64 start,
361 __u64 end, ldlm_mode_t mode);
362 int ll_tree_lock(struct ll_lock_tree *tree,
363 struct ll_lock_tree_node *first_node, struct inode *inode,
364 const char *buf, size_t count, int ast_flags);
365 int ll_tree_unlock(struct ll_lock_tree *tree, struct inode *inode);
367 int ll_get_fid(struct obd_export *exp, struct lustre_id *idp,
368 char *filename, struct lustre_id *ret);
371 #define LL_SBI_NOLCK 0x1
372 #define LL_SBI_READAHEAD 0x2
373 #define LL_SUPER_MAGIC 0x0BD00BD0
374 #define LL_MAX_BLKSIZE (4UL * 1024 * 1024)
376 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
377 #define ll_s2sbi(sb) ((struct ll_sb_info *)((sb)->s_fs_info))
378 #define ll_set_sbi(sb, sbi) ((sb)->s_fs_info = sbi)
379 static inline __u64 ll_ts2u64(struct timespec *time)
381 __u64 t = time->tv_sec;
385 #define ll_s2sbi(sb) ((struct ll_sb_info *)((sb)->u.generic_sbp))
386 #define ll_set_sbi(sb, sbi) ((sb)->u.generic_sbp = sbi)
387 static inline __u64 ll_ts2u64(time_t *time)
393 /* don't need an addref as the sb_info should be holding one */
394 static inline struct obd_export *ll_s2dtexp(struct super_block *sb)
396 return ll_s2sbi(sb)->ll_dt_exp;
399 /* don't need an addref as the sb_info should be holding one */
400 static inline struct obd_export *ll_s2mdexp(struct super_block *sb)
402 return ll_s2sbi(sb)->ll_md_exp;
405 static inline struct client_obd *sbi2md(struct ll_sb_info *sbi)
407 struct obd_device *obd = sbi->ll_md_exp->exp_obd;
413 // FIXME: replace the name of this with LL_SB to conform to kernel stuff
414 static inline struct ll_sb_info *ll_i2sbi(struct inode *inode)
416 return ll_s2sbi(inode->i_sb);
419 static inline struct obd_export *ll_i2dtexp(struct inode *inode)
421 return ll_s2dtexp(inode->i_sb);
424 static inline struct obd_export *ll_i2mdexp(struct inode *inode)
426 return ll_s2mdexp(inode->i_sb);
429 static inline int ll_mds_max_easize(struct super_block *sb)
431 return sbi2md(ll_s2sbi(sb))->cl_max_mds_easize;
434 static inline __u64 ll_file_maxbytes(struct inode *inode)
436 return ll_i2info(inode)->lli_maxbytes;
439 #endif /* LLITE_INTERNAL_H */