Whamcloud - gitweb
* Protect d_it with a semaphore, Part I
[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/fs.h>
20 #include <linux/ext2_fs.h>
21
22 #include <linux/obd_class.h>
23 #include <linux/lustre_net.h>
24 #include <linux/lustre_mds.h>
25 #include <linux/lustre_ha.h>
26
27 extern kmem_cache_t *ll_file_data_slab;
28 struct ll_file_data {
29         struct lustre_handle fd_mdshandle;
30         struct lustre_handle fd_osthandle;
31         struct ptlrpc_request *fd_req;
32         __u32 fd_flags;
33 };
34
35 struct ll_dentry_data {
36         struct semaphore      lld_it_sem;
37 };
38
39 #define ll_d2d(dentry) ((struct ll_dentry_data*) dentry->d_fsdata)
40
41 struct ll_read_inode2_cookie {
42         struct mds_body *lic_body;
43         struct lov_mds_md *lic_lmm;
44 };
45
46 #define LL_INLINESZ      60
47 struct ll_inode_info {
48         struct lov_stripe_md *lli_smd;
49         char                 *lli_symlink_name;
50         struct lustre_handle  lli_intent_lock_handle;
51         struct semaphore      lli_open_sem;
52         __u32                 lli_mount_epoch;
53 };
54
55 #define LL_SUPER_MAGIC 0x0BD00BD0
56
57 #define LL_COMMITCBD_STOPPING  0x1
58 #define LL_COMMITCBD_STOPPED   0x2
59 #define LL_COMMITCBD_RUNNING   0x4
60
61 #define LL_SBI_NOLCK   0x1
62
63 struct ll_sb_info {
64         obd_uuid_t                ll_sb_uuid;
65         struct lustre_handle      ll_mdc_conn;
66         struct lustre_handle      ll_osc_conn;
67         obd_id                    ll_rootino; /* number of root inode */
68
69         int                       ll_flags;
70         wait_queue_head_t         ll_commitcbd_waitq;
71         wait_queue_head_t         ll_commitcbd_ctl_waitq;
72         int                       ll_commitcbd_flags;
73         struct task_struct       *ll_commitcbd_thread;
74         time_t                    ll_commitcbd_waketime;
75         time_t                    ll_commitcbd_timeout;
76         spinlock_t                ll_commitcbd_lock;
77         struct list_head          ll_conn_chain; /* per-conn chain of SBs */
78         __u32                     ll_mount_epoch;
79 };
80
81 #define CHECK_MOUNT_EPOCH(i)                                                  \
82 do {                                                                          \
83         if (ll_i2info(i)->lli_mount_epoch != ll_i2sbi(i)->ll_mount_epoch)     \
84                 RETURN(-EIO);                                                 \
85 } while(0)
86
87 static inline struct ll_sb_info *ll_s2sbi(struct super_block *sb)
88 {
89         return (struct ll_sb_info *)(sb->u.generic_sbp);
90 }
91
92 static inline struct lustre_handle *ll_s2obdconn(struct super_block *sb)
93 {
94         return &(ll_s2sbi(sb))->ll_osc_conn;
95 }
96
97 static inline struct client_obd *sbi2mdc(struct ll_sb_info *sbi)
98 {
99         struct obd_device *obd = class_conn2obd(&sbi->ll_mdc_conn);
100         if (obd == NULL)
101                 LBUG();
102         return &obd->u.cli;
103 }
104
105 static inline struct ll_sb_info *ll_i2sbi(struct inode *inode)
106 {
107         return ll_s2sbi(inode->i_sb);
108 }
109
110 static inline struct ll_inode_info *ll_i2info(struct inode *inode)
111 {
112         return (struct ll_inode_info *)&(inode->u.generic_ip);
113 }
114
115 static inline struct lustre_handle *ll_i2obdconn(struct inode *inode)
116 {
117         return ll_s2obdconn(inode->i_sb);
118 }
119
120 static inline void ll_ino2fid(struct ll_fid *fid, obd_id ino, __u32 generation,
121                               int type)
122 {
123         fid->id = ino;
124         fid->generation = generation;
125         fid->f_type = type;
126 }
127
128 static inline void ll_inode2fid(struct ll_fid *fid, struct inode *inode)
129 {
130         ll_ino2fid(fid, inode->i_ino, inode->i_generation,
131                    inode->i_mode & S_IFMT);
132 }
133
134 static inline int ll_mds_easize(struct super_block *sb)
135 {
136         return sbi2mdc(ll_s2sbi(sb))->cl_max_mds_easize;
137 }
138
139 static inline int ll_ost_easize(struct super_block *sb)
140 {
141         return sbi2mdc(ll_s2sbi(sb))->cl_max_ost_easize;
142 }
143
144 /* namei.c */
145 int ll_lock(struct inode *dir, struct dentry *dentry,
146             struct lookup_intent *it, struct lustre_handle *lockh);
147 int ll_unlock(__u32 mode, struct lustre_handle *lockh);
148
149 /* dcache.c */
150 void ll_intent_release(struct dentry *de);
151 int ll_set_dd(struct dentry *de);
152
153 /* dir.c */
154 extern struct file_operations ll_dir_operations;
155 extern struct inode_operations ll_dir_inode_operations;
156
157 /* file.c */
158 extern struct file_operations ll_file_operations;
159 extern struct inode_operations ll_file_inode_operations;
160 struct ldlm_lock;
161 int ll_lock_callback(struct ldlm_lock *, struct ldlm_lock_desc *, void *data,
162                      __u32 data_len, int flag);
163 int ll_size_lock(struct inode *, struct lov_stripe_md *, __u64 start, int mode,
164                  struct lustre_handle **);
165 int ll_size_unlock(struct inode *, struct lov_stripe_md *, int mode,
166                    struct lustre_handle *);
167 int ll_file_size(struct inode *inode, struct lov_stripe_md *md);
168
169 /* rw.c */
170 struct page *ll_getpage(struct inode *inode, unsigned long offset,
171                         int create, int locked);
172 void ll_truncate(struct inode *inode);
173
174 /* super.c */
175 void ll_update_inode(struct inode *, struct mds_body *);
176
177 /* symlink.c */
178 extern struct inode_operations ll_fast_symlink_inode_operations;
179 extern struct inode_operations ll_symlink_inode_operations;
180
181 /* sysctl.c */
182 void ll_sysctl_init(void);
183 void ll_sysctl_clean(void);
184
185 #endif /* __KERNEL__ */
186
187 #define LL_IOC_GETFLAGS                 _IOR ('f', 151, long)
188 #define LL_IOC_SETFLAGS                 _IOW ('f', 152, long)
189 #define LL_IOC_CLRFLAGS                 _IOW ('f', 153, long)
190
191 #define LL_FILE_IGNORE_LOCK             0x00000001
192
193 #endif