Whamcloud - gitweb
land lustre part of b_hd_sec on HEAD.
[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 #include <linux/namei.h>
40
41
42 /* careful, this is easy to screw up */
43 #define PAGE_CACHE_MAXBYTES ((__u64)(~0UL) << PAGE_CACHE_SHIFT)
44
45 #define LL_IT2STR(it) ((it) ? ldlm_it2str((it)->it_op) : "0")
46
47 static inline struct lookup_intent *ll_nd2it(struct nameidata *nd)
48 {
49 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
50         return &nd->intent.open;
51 #else
52         return nd->intent;
53 #endif
54 }
55
56 struct ll_dentry_data {
57         int                      lld_cwd_count;
58         int                      lld_mnt_count;
59         struct obd_client_handle lld_cwd_och;
60         struct obd_client_handle lld_mnt_och;
61 };
62
63 #define ll_d2d(de) ((struct ll_dentry_data*) de->d_fsdata)
64
65 extern struct file_operations ll_pgcache_seq_fops;
66
67 #define LLI_INODE_MAGIC                 0x111d0de5
68 #define LLI_INODE_DEAD                  0xdeadd00d
69 #define LLI_F_HAVE_OST_SIZE_LOCK        0
70 #define LLI_F_HAVE_MDS_SIZE_LOCK        1
71 #define LLI_F_PREFER_EXTENDED_SIZE      2
72
73 struct ll_inode_info {
74         int                     lli_inode_magic;
75         struct lov_stripe_md   *lli_smd;
76         struct mea             *lli_mea;
77         struct lustre_id        lli_id;    /* full lustre_id */
78         char                   *lli_symlink_name;
79         struct semaphore        lli_open_sem;
80         __u64                   lli_maxbytes;
81         __u64                   lli_io_epoch;
82         unsigned long           lli_flags;
83
84         /* this lock protects s_d_w and p_w_ll */
85         spinlock_t              lli_lock;
86         int                     lli_send_done_writing;
87         
88         int                     lli_snap_index;
89         
90         struct list_head        lli_pending_write_llaps;
91
92         struct list_head        lli_close_item;
93
94         struct file_operations *ll_save_ifop;
95         struct file_operations *ll_save_ffop;
96         struct file_operations *ll_save_wfop;
97         struct file_operations *ll_save_wrfop;
98 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
99         struct inode            lli_vfs_inode;
100 #endif
101         struct posix_acl       *lli_acl_access;
102 };
103
104 // FIXME: replace the name of this with LL_I to conform to kernel stuff
105 // static inline struct ll_inode_info *LL_I(struct inode *inode)
106 static inline struct ll_inode_info *ll_i2info(struct inode *inode)
107 {
108 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
109         return container_of(inode, struct ll_inode_info, lli_vfs_inode);
110 #else
111         return (struct ll_inode_info *)&(inode->u.generic_ip);
112 #endif
113 }
114
115 /* lprocfs.c */
116 enum {
117          LPROC_LL_DIRTY_HITS = 0,
118          LPROC_LL_DIRTY_MISSES,
119          LPROC_LL_WB_WRITEPAGE,
120          LPROC_LL_WB_PRESSURE,
121          LPROC_LL_WB_OK,
122          LPROC_LL_WB_FAIL,
123          LPROC_LL_READ_BYTES,
124          LPROC_LL_WRITE_BYTES,
125          LPROC_LL_BRW_READ,
126          LPROC_LL_BRW_WRITE,
127          LPROC_LL_IOCTL,
128          LPROC_LL_OPEN,
129          LPROC_LL_RELEASE,
130          LPROC_LL_MAP,
131          LPROC_LL_LLSEEK,
132          LPROC_LL_FSYNC,
133          LPROC_LL_SETATTR,
134          LPROC_LL_TRUNC,
135
136 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
137          LPROC_LL_GETATTR,
138 #else
139          LPROC_LL_REVALIDATE,
140 #endif
141          LPROC_LL_STAFS,
142          LPROC_LL_ALLOC_INODE,
143
144          LPROC_LL_DIRECT_READ,
145          LPROC_LL_DIRECT_WRITE,
146          LPROC_LL_SETXATTR,
147          LPROC_LL_GETXATTR,
148          LPROC_LL_FILE_OPCODES,
149 };
150
151 struct lustre_intent_data {
152         int     it_disposition;
153         int     it_status;
154         __u64   it_lock_handle;
155         void    *it_data;
156         int     it_lock_mode;
157 };
158 #define LUSTRE_IT(it) ((struct lustre_intent_data *)((it)->d.fs_data))
159
160 static inline void
161 ll_inode2id(struct lustre_id *id, struct inode *inode)
162 {
163         struct lustre_id *lid = &ll_i2info(inode)->lli_id;
164
165         mdc_pack_id(id, inode->i_ino, inode->i_generation,
166                     (inode->i_mode & S_IFMT), id_group(lid),
167                     id_fid(lid));
168 }
169
170 static inline void 
171 ll_prepare_mdc_data(struct mdc_op_data *data, struct inode *i1,
172                     struct inode *i2, const char *name, int namelen,
173                     int mode)
174 {
175         LASSERT(i1);
176
177         ll_inode2id(&data->id1, i1);
178
179         /* it could be directory with mea */
180         data->mea1 = ll_i2info(i1)->lli_mea;
181
182         if (i2) {
183                 ll_inode2id(&data->id2, i2);
184                 data->mea2 = ll_i2info(i2)->lli_mea;
185         }
186
187         data->valid = 0;
188         data->name = name;
189         data->namelen = namelen;
190         data->create_mode = mode;
191         data->mod_time = LTIME_S(CURRENT_TIME);
192 }
193
194 #else
195 #include <linux/lustre_idl.h>
196 #endif /* __KERNEL__ */
197
198 #include <lustre/lustre_user.h>
199
200 #endif