Whamcloud - gitweb
land v0.9.1 on HEAD, in preparation for a 1.0.x branch
[fs/lustre-release.git] / lustre / include / linux / lustre_lite.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * lustre lite cluster file system
5  *
6  * This code is issued under the GNU General Public License.
7  * See the file COPYING in this distribution
8  *
9  * Copyright (C) 2002 Cluster File Systems, Inc. <info@clusterfs.com>
10  */
11
12
13
14 #ifndef _LL_H
15 #define _LL_H
16
17 #ifdef __KERNEL__
18
19 #include <linux/version.h>
20
21 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
22 #include <asm/statfs.h>
23 #endif
24
25 #include <linux/fs.h>
26 #include <linux/dcache.h>
27 #include <linux/jbd.h>
28 #include <linux/ext3_fs.h>
29 #include <linux/proc_fs.h>
30
31 #include <linux/obd_class.h>
32 #include <linux/lustre_net.h>
33 #include <linux/lustre_mds.h>
34 #include <linux/lustre_ha.h>
35
36 #include <linux/rbtree.h>
37 #include <linux/lustre_compat25.h>
38 #include <linux/pagemap.h>
39
40 /* careful, this is easy to screw up */
41 #define PAGE_CACHE_MAXBYTES ((__u64)(~0UL) << PAGE_CACHE_SHIFT)
42
43 extern kmem_cache_t *ll_file_data_slab;
44 struct ll_file_data {
45         struct obd_client_handle fd_mds_och;
46         __u32 fd_flags;
47 };
48
49 /*
50 struct lustre_intent_data {
51         __u64 it_lock_handle[2];
52         __u32 it_disposition;
53         __u32 it_status;
54         __u32 it_lock_mode;
55         }; */
56
57 #define LL_IT2STR(it) ((it) ? ldlm_it2str((it)->it_op) : "0")
58
59 static inline struct lookup_intent *ll_nd2it(struct nameidata *nd)
60 {
61 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
62         return &nd->intent;
63 #else
64         return nd->intent;
65 #endif
66 }
67
68 struct ll_dentry_data {
69         int                      lld_cwd_count;
70         int                      lld_mnt_count;
71         struct obd_client_handle lld_cwd_och;
72         struct obd_client_handle lld_mnt_och;
73 };
74
75 #define ll_d2d(de) ((struct ll_dentry_data*) de->d_fsdata)
76
77 extern struct file_operations ll_pgcache_seq_fops;
78
79 #define LLI_F_HAVE_OST_SIZE_LOCK        0
80 #define LLI_F_HAVE_MDS_SIZE_LOCK        1
81 #define LLI_F_PREFER_EXTENDED_SIZE      2
82 struct ll_inode_info {
83         struct lov_stripe_md   *lli_smd;
84         char                   *lli_symlink_name;
85         struct semaphore        lli_open_sem;
86         __u64                   lli_maxbytes;
87         __u64                   lli_io_epoch;
88         unsigned long           lli_flags;
89
90         /* this lock protects s_d_w and p_w_ll */
91         spinlock_t              lli_lock;
92         int                     lli_send_done_writing;
93         struct list_head        lli_pending_write_llaps;
94
95         struct list_head        lli_close_item;
96         struct file_operations *ll_save_ifop;
97         struct file_operations *ll_save_ffop;
98         struct file_operations *ll_save_wfop;
99         struct file_operations *ll_save_wrfop;
100 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
101         struct inode            lli_vfs_inode;
102 #endif
103 };
104
105 // FIXME: replace the name of this with LL_I to conform to kernel stuff
106 // static inline struct ll_inode_info *LL_I(struct inode *inode)
107 static inline struct ll_inode_info *ll_i2info(struct inode *inode)
108 {
109 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
110         return container_of(inode, struct ll_inode_info, lli_vfs_inode);
111 #else
112         return (struct ll_inode_info *)&(inode->u.generic_ip);
113 #endif
114 }
115
116 /* lprocfs.c */
117 enum {
118          LPROC_LL_DIRTY_HITS = 0,
119          LPROC_LL_DIRTY_MISSES,
120          LPROC_LL_WB_WRITEPAGE,
121          LPROC_LL_WB_PRESSURE,
122          LPROC_LL_WB_OK,
123          LPROC_LL_WB_FAIL,
124          LPROC_LL_READ_BYTES,
125          LPROC_LL_WRITE_BYTES,
126          LPROC_LL_BRW_READ,
127          LPROC_LL_BRW_WRITE,
128          LPROC_LL_IOCTL,
129          LPROC_LL_OPEN,
130          LPROC_LL_RELEASE,
131          LPROC_LL_MAP,
132          LPROC_LL_LLSEEK,
133          LPROC_LL_FSYNC,
134          LPROC_LL_SETATTR,
135          LPROC_LL_TRUNC,
136
137 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
138          LPROC_LL_GETATTR,
139 #else
140          LPROC_LL_REVALIDATE,
141 #endif
142          LPROC_LL_STAFS,
143          LPROC_LL_ALLOC_INODE,
144
145          LPROC_LL_DIRECT_READ,
146          LPROC_LL_DIRECT_WRITE,
147          LPROC_LL_FILE_OPCODES
148 };
149
150 #else
151 #include <linux/lustre_idl.h>
152 #endif /* __KERNEL__ */
153
154 #include <linux/lustre_user.h>
155
156 #endif