1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * lustre lite cluster file system
6 * This code is issued under the GNU General Public License.
7 * See the file COPYING in this distribution
9 * Copyright (C) 2002 Cluster File Systems, Inc. <info@clusterfs.com>
19 #include <linux/version.h>
21 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
22 #include <asm/statfs.h>
26 #include <linux/dcache.h>
27 #include <linux/ext2_fs.h>
28 #include <linux/proc_fs.h>
30 #include <linux/obd_class.h>
31 #include <linux/lustre_net.h>
32 #include <linux/lustre_mds.h>
33 #include <linux/lustre_ha.h>
35 #include <linux/rbtree.h>
36 #include <linux/lustre_compat25.h>
37 #include <linux/pagemap.h>
39 /* careful, this is easy to screw up */
40 #define PAGE_CACHE_MAXBYTES ((__u64)(~0UL) << PAGE_CACHE_SHIFT)
42 extern kmem_cache_t *ll_file_data_slab;
44 struct obd_client_handle fd_mds_och;
45 struct obd_client_handle fd_ost_och;
49 struct lustre_intent_data {
50 __u64 it_lock_handle[2];
56 #define LL_IT2STR(it) ((it) ? ldlm_it2str((it)->it_op) : "0")
58 static inline struct lookup_intent *ll_nd2it(struct nameidata *nd)
60 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
67 struct ll_dentry_data {
70 struct obd_client_handle lld_cwd_och;
71 struct obd_client_handle lld_mnt_och;
74 #define ll_d2d(de) ((struct ll_dentry_data*) de->d_fsdata)
76 extern struct file_operations ll_pgcache_seq_fops;
79 * XXX used in obdecho/echo_client.c must move (pjb)
80 *'p' list as its a list of pages linked together
89 struct ll_dirty_offsets {
92 unsigned long do_num_dirty;
95 struct ll_writeback_pages {
97 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
100 struct brw_page pga[0];
102 struct brw_page *pga;
106 struct ll_inode_info {
107 struct lov_stripe_md *lli_smd;
108 char *lli_symlink_name;
109 struct semaphore lli_open_sem;
110 struct list_head lli_read_extents;
112 spinlock_t lli_read_extent_lock;
113 unsigned long lli_flags;
114 #define LLI_F_HAVE_SIZE_LOCK 0
116 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
117 struct inode lli_vfs_inode;
122 * this lets ll_file_read tell ll_readpages how far ahead it can read
123 * and still be covered by ll_file_read's lock. 2.5 won't need this, but
124 * we have the other problem of other readpage callers making sure that
125 * they're covered by a lock..
127 struct ll_read_extent {
128 struct list_head re_lli_item;
129 struct task_struct *re_task;
130 struct ldlm_extent re_extent;
133 #define LL_SUPER_MAGIC 0x0BD00BD0
135 #define LL_COMMITCBD_STOPPING 0x1
136 #define LL_COMMITCBD_STOPPED 0x2
137 #define LL_COMMITCBD_RUNNING 0x4
139 #define LL_SBI_NOLCK 0x1
142 struct obd_uuid ll_sb_uuid;
143 struct lustre_handle ll_mdc_conn;
144 struct lustre_handle ll_osc_conn;
145 struct proc_dir_entry* ll_proc_root;
146 obd_id ll_rootino; /* number of root inode */
149 wait_queue_head_t ll_commitcbd_waitq;
150 wait_queue_head_t ll_commitcbd_ctl_waitq;
151 int ll_commitcbd_flags;
152 struct task_struct *ll_commitcbd_thread;
153 time_t ll_commitcbd_waketime;
154 time_t ll_commitcbd_timeout;
155 spinlock_t ll_commitcbd_lock;
156 struct list_head ll_conn_chain; /* per-conn chain of SBs */
158 struct list_head ll_orphan_dentry_list; /*please don't ask -p*/
160 struct lprocfs_stats *ll_stats; /* lprocfs stats counter */
164 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
165 #define ll_s2sbi(sb) ((struct ll_sb_info *)((sb)->s_fs_info))
166 void __d_rehash(struct dentry * entry, int lock);
167 static inline __u64 ll_ts2u64(struct timespec *time)
169 __u64 t = time->tv_sec;
173 #define ll_s2sbi(sb) ((struct ll_sb_info *)((sb)->u.generic_sbp))
174 static inline __u64 ll_ts2u64(time_t *time)
180 static inline struct lustre_handle *ll_s2obdconn(struct super_block *sb)
182 return &(ll_s2sbi(sb))->ll_osc_conn;
185 static inline struct client_obd *sbi2mdc(struct ll_sb_info *sbi)
187 struct obd_device *obd = class_conn2obd(&sbi->ll_mdc_conn);
193 // FIXME: replace the name of this with LL_SB to conform to kernel stuff
194 static inline struct ll_sb_info *ll_i2sbi(struct inode *inode)
196 return ll_s2sbi(inode->i_sb);
199 // FIXME: replace the name of this with LL_I to conform to kernel stuff
200 // static inline struct ll_inode_info *LL_I(struct inode *inode)
201 static inline struct ll_inode_info *ll_i2info(struct inode *inode)
203 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
204 return container_of(inode, struct ll_inode_info, lli_vfs_inode);
206 return (struct ll_inode_info *)&(inode->u.generic_ip);
210 static inline struct lustre_handle *ll_i2obdconn(struct inode *inode)
212 return ll_s2obdconn(inode->i_sb);
215 static inline void ll_ino2fid(struct ll_fid *fid, obd_id ino, __u32 generation,
218 static inline void ll_inode2fid(struct ll_fid *fid, struct inode *inode)
220 ll_ino2fid(fid, inode->i_ino, inode->i_generation,
221 inode->i_mode & S_IFMT);
224 static inline int ll_mds_max_easize(struct super_block *sb)
226 return sbi2mdc(ll_s2sbi(sb))->cl_max_mds_easize;
229 static inline __u64 ll_file_maxbytes(struct inode *inode)
231 return ll_i2info(inode)->lli_maxbytes;
235 typedef int (*intent_finish_cb)(struct ptlrpc_request *,
236 struct inode *parent, struct dentry **,
237 struct lookup_intent *, int offset, obd_id ino);
238 int ll_intent_lock(struct inode *parent, struct dentry **,
239 struct lookup_intent *, int, intent_finish_cb);
240 int ll_mdc_blocking_ast(struct ldlm_lock *lock,
241 struct ldlm_lock_desc *desc,
242 void *data, int flag);
243 void ll_mdc_lock_set_inode(struct lustre_handle *lock, struct inode *inode);
244 void ll_prepare_mdc_op_data(struct mdc_op_data *data,
245 struct inode *i1, struct inode *i2,
246 const char *name, int namelen, int mode);
250 LPROC_LL_DIRTY_HITS = 0,
251 LPROC_LL_DIRTY_MISSES,
252 LPROC_LL_WB_WRITEPAGE,
253 LPROC_LL_WB_PRESSURE,
257 LPROC_LL_WRITE_BYTES,
266 LPROC_LL_SETATTR_RAW,
270 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
276 LPROC_LL_ALLOC_INODE,
278 LPROC_LL_DIRECT_READ,
279 LPROC_LL_DIRECT_WRITE,
280 LPROC_LL_FILE_OPCODES
283 int ll_have_md_lock(struct dentry *de);
286 extern struct file_operations ll_dir_operations;
287 extern struct inode_operations ll_dir_inode_operations;
290 extern struct file_operations ll_file_operations;
291 extern struct inode_operations ll_file_inode_operations;
292 extern struct inode_operations ll_special_inode_operations;
294 int ll_extent_lock_no_validate(struct ll_file_data *fd, struct inode *inode,
295 struct lov_stripe_md *lsm, int mode,
296 struct ldlm_extent *extent, struct lustre_handle *lockh);
297 int ll_extent_lock(struct ll_file_data *fd, struct inode *inode,
298 struct lov_stripe_md *lsm, int mode,
299 struct ldlm_extent *extent, struct lustre_handle *lockh);
300 int ll_extent_unlock(struct ll_file_data *fd, struct inode *inode,
301 struct lov_stripe_md *lsm, int mode,
302 struct lustre_handle *lockh);
303 int ll_create_objects(struct super_block *sb, obd_id id, uid_t uid,
304 gid_t gid, struct lov_stripe_md **lsmp);
305 int ll_file_open(struct inode *inode, struct file *file);
306 int ll_file_release(struct inode *inode, struct file *file);
311 void ll_update_inode(struct inode *, struct mds_body *, struct lov_stripe_md *);
312 int ll_setattr_raw(struct inode *inode, struct iattr *attr);
313 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
314 unsigned long maxage);
317 extern struct inode_operations ll_fast_symlink_inode_operations;
318 extern struct inode_operations ll_symlink_inode_operations;
321 #include <linux/lustre_idl.h>
322 #endif /* __KERNEL__ */
324 static inline void ll_ino2fid(struct ll_fid *fid, obd_id ino, __u32 generation,
328 fid->generation = generation;
332 #include <asm/types.h>
334 #define LL_IOC_GETFLAGS _IOR ('f', 151, long)
335 #define LL_IOC_SETFLAGS _IOW ('f', 152, long)
336 #define LL_IOC_CLRFLAGS _IOW ('f', 153, long)
337 #define LL_IOC_LOV_SETSTRIPE _IOW ('f', 154, long)
338 #define LL_IOC_LOV_GETSTRIPE _IOW ('f', 155, long)
340 #define O_LOV_DELAY_CREATE 0100000000 /* hopefully this does not conflict */
342 #define LL_FILE_IGNORE_LOCK 0x00000001