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];
38 /* this protects pglist and max_r_a_pages. It isn't safe to grab from
39 * interrupt contexts. */
42 struct obd_uuid ll_sb_uuid;
43 struct obd_export *ll_lmv_exp;
44 struct lmv_desc ll_lmv_desc;
45 struct obd_export *ll_lov_exp;
46 struct lov_desc ll_lov_desc;
47 struct proc_dir_entry *ll_proc_root;
48 struct lustre_id ll_rootid; /* root lustre id */
50 struct lustre_mount_data *ll_lmd;
54 struct list_head ll_conn_chain; /* per-conn chain of SBs */
56 struct hlist_head ll_orphan_dentry_list; /*please don't ask -p*/
57 struct ll_close_queue *ll_lcq;
59 struct lprocfs_stats *ll_stats; /* lprocfs stats counter */
61 unsigned long ll_pglist_gen;
62 struct list_head ll_pglist;
64 struct ll_ra_info ll_ra_info;
66 /* times spent waiting for locks in each call site. These are
67 * all protected by the ll_lock */
68 struct obd_service_time ll_read_stime;
69 struct obd_service_time ll_write_stime;
70 struct obd_service_time ll_grouplock_stime;
71 struct obd_service_time ll_seek_stime;
72 struct obd_service_time ll_setattr_stime;
73 struct obd_service_time ll_brw_stime;
74 // struct obd_service_time ll_done_stime;
76 int ll_config_version; /* last-applied update */
78 /* list of GNS mounts; protected by the dcache_lock */
79 struct list_head ll_mnt_list;
81 struct semaphore ll_gns_sem;
82 wait_queue_head_t ll_gns_waitq;
83 struct completion ll_gns_completion;
85 struct timer_list ll_gns_timer;
86 struct list_head ll_gns_sbi_head;
89 #define LL_GNS_STATE_IDLE 1100
90 #define LL_GNS_STATE_MOUNTING 1101
91 #define LL_GNS_STATE_FINISHED 1102
93 struct ll_readahead_state {
95 unsigned long ras_last_readpage, ras_consecutive;
96 unsigned long ras_window_start, ras_window_len;
97 unsigned long ras_next_readahead;
101 extern kmem_cache_t *ll_file_data_slab;
102 struct lustre_handle;
103 struct ll_file_data {
104 struct obd_client_handle fd_mds_och;
105 struct ll_readahead_state fd_ras;
107 struct lustre_handle fd_cwlockh;
108 unsigned long fd_gid;
111 struct lov_stripe_md;
113 extern spinlock_t inode_lock;
115 extern void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi);
116 extern struct proc_dir_entry *proc_lustre_fs_root;
118 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
119 # define hlist_del_init list_del_init
122 static inline struct inode *ll_info2i(struct ll_inode_info *lli)
124 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
125 return &lli->lli_vfs_inode;
127 return list_entry(lli, struct inode, u.generic_ip);
133 struct inode *icbd_parent;
134 struct dentry **icbd_childp;
138 #define LLAP_MAGIC 98764321
140 struct ll_async_page {
143 struct page *llap_page;
144 struct list_head llap_pending_write;
145 /* only trust these if the page lock is providing exclusion */
146 unsigned llap_write_queued:1,
147 llap_defer_uptodate:1,
150 struct list_head llap_proc_item;
153 #define LL_CDEBUG_PAGE(mask, page, fmt, arg...) \
154 CDEBUG(mask, "page %p map %p ind %lu priv %0lx: " fmt, \
155 page, page->mapping, page->index, page->private, ## arg)
157 /* llite/lproc_llite.c */
158 int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
159 struct super_block *sb, char *lov,
161 void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi);
164 extern struct file_operations ll_dir_operations;
165 extern struct inode_operations ll_dir_inode_operations;
168 int ll_objects_destroy(struct ptlrpc_request *request,
169 struct inode *dir, int offset);
170 struct inode *ll_iget(struct super_block *sb, ino_t hash,
171 struct lustre_md *lic);
172 struct dentry *ll_find_alias(struct inode *, struct dentry *);
173 int ll_mdc_cancel_unused(struct lustre_handle *, struct inode *, int flags,
175 int ll_mdc_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *,
176 void *data, int flag);
178 int ll_prepare_write(struct file *, struct page *, unsigned from, unsigned to);
179 int ll_commit_write(struct file *, struct page *, unsigned from, unsigned to);
180 int ll_writepage(struct page *page);
181 void ll_inode_fill_obdo(struct inode *inode, int cmd, struct obdo *oa);
182 void ll_ap_completion(void *data, int cmd, struct obdo *oa, int rc);
183 void ll_removepage(struct page *page);
184 int ll_readpage(struct file *file, struct page *page);
185 struct ll_async_page *llap_from_cookie(void *cookie);
186 struct ll_async_page *llap_from_page(struct page *page);
187 struct ll_async_page *llap_cast_private(struct page *page);
188 void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras);
190 void ll_ra_accounting(struct page *page, struct address_space *mapping);
191 void ll_truncate(struct inode *inode);
194 extern struct file_operations ll_file_operations;
195 extern struct inode_operations ll_file_inode_operations;
196 extern int ll_inode_revalidate_it(struct dentry *, struct lookup_intent *);
197 int ll_refresh_lsm(struct inode *inode, struct lov_stripe_md *lsm);
198 int ll_extent_lock(struct ll_file_data *, struct inode *,
199 struct lov_stripe_md *, int mode, ldlm_policy_data_t *,
200 struct lustre_handle *, int ast_flags,
201 struct obd_service_time *);
202 int ll_extent_unlock(struct ll_file_data *, struct inode *,
203 struct lov_stripe_md *, int mode, struct lustre_handle *);
204 int ll_file_open(struct inode *inode, struct file *file);
205 int ll_file_release(struct inode *inode, struct file *file);
206 int ll_lsm_getattr(struct obd_export *, struct lov_stripe_md *, struct obdo *);
207 int ll_glimpse_size(struct inode *inode);
208 int ll_local_open(struct file *file, struct lookup_intent *it);
209 int ll_mdc_close(struct obd_export *lmv_exp, struct inode *inode,
211 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
212 int ll_getattr(struct vfsmount *mnt, struct dentry *de,
213 struct lookup_intent *it, struct kstat *stat);
215 void ll_stime_record(struct ll_sb_info *sbi, struct timeval *start,
216 struct obd_service_time *stime);
219 void ll_intent_drop_lock(struct lookup_intent *);
220 void ll_intent_release(struct lookup_intent *);
221 extern void ll_set_dd(struct dentry *de);
222 void ll_unhash_aliases(struct inode *);
223 void ll_frob_intent(struct lookup_intent **itp, struct lookup_intent *deft);
224 void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry);
225 int revalidate_it_finish(struct ptlrpc_request *request, int offset,
226 struct lookup_intent *it, struct dentry *de);
229 /* llite/llite_gns.c */
230 int ll_finish_gns(struct ll_sb_info *sbi);
231 int fill_page_with_path(struct dentry *, struct vfsmount *, char **pagep);
232 int ll_dir_process_mount_object(struct dentry *, struct vfsmount *);
233 int ll_gns_umount_all(struct ll_sb_info *sbi, int timeout);
234 void ll_gns_timer_callback(unsigned long data);
235 void ll_gns_add_timer(struct ll_sb_info *sbi);
236 void ll_gns_del_timer(struct ll_sb_info *sbi);
237 int ll_gns_start_thread(void);
238 void ll_gns_stop_thread(void);
240 /* llite/llite_lib.c */
241 extern struct super_operations lustre_super_operations;
243 char *ll_read_opt(const char *opt, char *data);
244 int ll_set_opt(const char *opt, char *data, int fl);
245 void ll_options(char *options, char **ost, char **mds, int *flags);
246 void ll_lli_init(struct ll_inode_info *lli);
247 int ll_fill_super(struct super_block *sb, void *data, int silent);
248 int lustre_fill_super(struct super_block *sb, void *data, int silent);
249 void lustre_put_super(struct super_block *sb);
250 struct inode *ll_inode_from_lock(struct ldlm_lock *lock);
251 void ll_clear_inode(struct inode *inode);
252 int ll_attr2inode(struct inode *inode, struct iattr *attr, int trunc);
253 int ll_setattr_raw(struct inode *inode, struct iattr *attr);
254 int ll_setattr(struct dentry *de, struct iattr *attr);
255 int ll_statfs(struct super_block *sb, struct kstatfs *sfs);
256 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
257 unsigned long maxage);
258 void ll_update_inode(struct inode *inode, struct lustre_md *);
259 int it_disposition(struct lookup_intent *it, int flag);
260 void it_set_disposition(struct lookup_intent *it, int flag);
261 void ll_read_inode2(struct inode *inode, void *opaque);
262 void ll_delete_inode(struct inode *inode);
263 int ll_iocontrol(struct inode *inode, struct file *file,
264 unsigned int cmd, unsigned long arg);
265 void ll_umount_begin(struct super_block *sb);
266 int ll_prep_inode(struct obd_export *, struct obd_export *, struct inode **inode,
267 struct ptlrpc_request *req, int offset, struct super_block *);
268 __u32 get_uuid2int(const char *name, int len);
269 struct dentry *ll_fh_to_dentry(struct super_block *sb, __u32 *data, int len,
270 int fhtype, int parent);
271 int ll_dentry_to_fh(struct dentry *, __u32 *datap, int *lenp, int need_parent);
272 int null_if_equal(struct ldlm_lock *lock, void *data);
273 int ll_process_config_update(struct ll_sb_info *sbi, int clean);
275 /* llite/special.c */
276 extern struct inode_operations ll_special_inode_operations;
277 extern struct file_operations ll_special_chr_inode_fops;
278 extern struct file_operations ll_special_chr_file_fops;
279 extern struct file_operations ll_special_blk_inode_fops;
280 extern struct file_operations ll_special_fifo_inode_fops;
281 extern struct file_operations ll_special_fifo_file_fops;
282 extern struct file_operations ll_special_sock_inode_fops;
284 /* llite/symlink.c */
285 extern struct inode_operations ll_fast_symlink_inode_operations;
287 /* llite/llite_close.c */
288 struct ll_close_queue {
290 struct list_head lcq_list;
291 wait_queue_head_t lcq_waitq;
292 struct completion lcq_comp;
295 void llap_write_pending(struct inode *inode, struct ll_async_page *llap);
296 void llap_write_complete(struct inode *inode, struct ll_async_page *llap);
297 void ll_open_complete(struct inode *inode);
298 int ll_is_inode_dirty(struct inode *inode);
299 void ll_try_done_writing(struct inode *inode);
300 void ll_queue_done_writing(struct inode *inode);
301 void ll_close_thread_shutdown(struct ll_close_queue *lcq);
302 int ll_close_thread_start(struct ll_close_queue **lcq_ret);
305 /* llite/llite_mmap.c */
306 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
307 typedef struct rb_root rb_root_t;
308 typedef struct rb_node rb_node_t;
311 struct ll_lock_tree_node;
312 struct ll_lock_tree {
314 struct list_head lt_locked_list;
315 struct ll_file_data *lt_fd;
317 int ll_teardown_mmaps(struct address_space *mapping, __u64 first,
319 int ll_file_mmap(struct file * file, struct vm_area_struct * vma);
320 struct ll_lock_tree_node * ll_node_from_inode(struct inode *inode, __u64 start,
321 __u64 end, ldlm_mode_t mode);
322 int ll_tree_lock(struct ll_lock_tree *tree,
323 struct ll_lock_tree_node *first_node, struct inode *inode,
324 const char *buf, size_t count, int ast_flags);
325 int ll_tree_unlock(struct ll_lock_tree *tree, struct inode *inode);
332 #define LL_SBI_NOLCK 0x1
333 #define LL_SBI_READAHEAD 0x2
334 #define LL_SUPER_MAGIC 0x0BD00BD0
335 #define LL_MAX_BLKSIZE (4UL * 1024 * 1024)
337 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
338 #define ll_s2sbi(sb) ((struct ll_sb_info *)((sb)->s_fs_info))
339 #define ll_set_sbi(sb, sbi) ((sb)->s_fs_info = sbi)
340 void __d_rehash(struct dentry * entry, int lock);
341 static inline __u64 ll_ts2u64(struct timespec *time)
343 __u64 t = time->tv_sec;
347 #define ll_s2sbi(sb) ((struct ll_sb_info *)((sb)->u.generic_sbp))
348 #define ll_set_sbi(sb, sbi) ((sb)->u.generic_sbp = sbi)
349 static inline __u64 ll_ts2u64(time_t *time)
355 /* don't need an addref as the sb_info should be holding one */
356 static inline struct obd_export *ll_s2obdexp(struct super_block *sb)
358 return ll_s2sbi(sb)->ll_lov_exp;
361 /* don't need an addref as the sb_info should be holding one */
362 static inline struct obd_export *ll_s2lmvexp(struct super_block *sb)
364 return ll_s2sbi(sb)->ll_lmv_exp;
367 static inline struct client_obd *sbi2lmv(struct ll_sb_info *sbi)
369 struct obd_device *obd = sbi->ll_lmv_exp->exp_obd;
375 // FIXME: replace the name of this with LL_SB to conform to kernel stuff
376 static inline struct ll_sb_info *ll_i2sbi(struct inode *inode)
378 return ll_s2sbi(inode->i_sb);
381 static inline struct obd_export *ll_i2obdexp(struct inode *inode)
383 return ll_s2obdexp(inode->i_sb);
386 static inline struct obd_export *ll_i2lmvexp(struct inode *inode)
388 return ll_s2lmvexp(inode->i_sb);
391 static inline int ll_mds_max_easize(struct super_block *sb)
393 return sbi2lmv(ll_s2sbi(sb))->cl_max_mds_easize;
396 static inline __u64 ll_file_maxbytes(struct inode *inode)
398 return ll_i2info(inode)->lli_maxbytes;
401 #endif /* LLITE_INTERNAL_H */