Whamcloud - gitweb
Fix locking with filter. This changes the way objects are looked up in
[fs/lustre-release.git] / lustre / include / linux / obd.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Copyright (C) 2001  Cluster File Systems, Inc.
5  *
6  * This code is issued under the GNU General Public License.
7  * See the file COPYING in this distribution
8  */
9
10 #ifndef __OBD_H
11 #define __OBD_H
12 #include <linux/fs.h>
13 #include <linux/list.h>
14 #include <linux/smp_lock.h>
15
16 #include <linux/lustre_idl.h>
17
18 struct obd_conn_info {
19         unsigned int conn_id;     /* handle */
20 };
21
22 struct obd_type {
23         struct list_head typ_chain;
24         struct obd_ops *typ_ops;
25         char *typ_name;
26         int  typ_refcnt;
27 };
28
29 struct obd_run_ctxt {
30         struct vfsmount *pwdmnt;
31         struct dentry   *pwd;
32         mm_segment_t     fs;
33 };
34
35 struct obd_conn {
36         struct obd_device *oc_dev;
37         uint32_t oc_id;
38 };
39
40 struct obd_devicename {
41         uint32_t len;
42         char *name;
43         struct dentry *dentry;   /* file system obd device names */
44         __u8 _uuid[16];          /* uuid obd device names */
45 };
46
47
48 /* Individual type definitions */
49
50 struct ext2_obd {
51         struct super_block *e2_sb;
52         struct vfsmount *e2_vfsmnt;
53 };
54
55 struct filter_obd {
56         char *fo_fstype;
57         struct super_block *fo_sb;
58         struct vfsmount *fo_vfsmnt;
59         struct obd_run_ctxt fo_ctxt;
60         struct dentry *fo_dentry_O;
61         struct dentry *fo_dentry_O_mode[16];
62         spinlock_t fo_lock;
63         __u64 fo_lastino;
64         struct file_operations *fo_fop;
65         struct inode_operations *fo_iop;
66         struct address_space_operations *fo_aops;
67 };
68
69 struct mds_client_info;
70 struct mds_server_data;
71
72 struct mds_obd {
73         struct ptlrpc_service *mds_service;
74
75         char *mds_fstype;
76         struct super_block *mds_sb;
77         struct vfsmount *mds_vfsmnt;
78         struct obd_run_ctxt mds_ctxt;
79         struct file_operations *mds_fop;
80         struct inode_operations *mds_iop;
81         struct address_space_operations *mds_aops;
82         struct mds_fs_operations *mds_fsops;
83         struct file *mds_rcvd_filp;
84         __u64 mds_last_committed;
85         __u64 mds_last_rcvd;
86         __u64 mds_mount_count;
87         struct ll_fid mds_rootfid;
88         int mds_client_count;
89         struct list_head mds_client_info;
90         struct mds_server_data *mds_server_data;
91 };
92
93 struct ldlm_obd {
94         struct ptlrpc_service *ldlm_service;
95         struct ptlrpc_client *ldlm_client;
96         struct ptlrpc_connection *ldlm_server_conn;
97 };
98
99 struct echo_obd {
100         char *eo_fstype;
101         struct super_block *eo_sb;
102         struct vfsmount *eo_vfsmnt;
103         struct obd_run_ctxt eo_ctxt;
104         spinlock_t eo_lock;
105         __u64 eo_lastino;
106         struct file_operations *eo_fop;
107         struct inode_operations *eo_iop;
108         struct address_space_operations *eo_aops;
109 };
110
111 struct recovd_obd {
112         time_t                recovd_waketime;
113         time_t                recovd_timeout;
114         struct ptlrpc_service *recovd_service;
115         struct ptlrpc_client  *recovd_client;
116         __u32                  recovd_flags; 
117         __u32                  recovd_wakeup_flag; 
118         spinlock_t             recovd_lock;
119         struct list_head      recovd_clients_lh; /* clients managed  */
120         struct list_head      recovd_troubled_lh; /* clients in trouble */
121         wait_queue_head_t     recovd_recovery_waitq;
122         wait_queue_head_t     recovd_ctl_waitq;
123         wait_queue_head_t     recovd_waitq;
124         struct task_struct    *recovd_thread;
125 };
126
127 struct trace_obd {
128         struct obdtrace_opstats *stats;
129 };
130
131 #if 0
132 struct snap_obd {
133         unsigned int snap_index;  /* which snapshot index are we accessing */
134         int snap_tableno;
135 };
136
137 struct raid1_obd {
138         unsigned int raid1_count; /* how many replicas */
139         /* devices to replicate on */
140         struct obd_device *raid1_devlist[MAX_RAID1];
141         /* connections we make */
142         struct obd_conn_info raid1_connections[MAX_RAID1];
143         struct list_head raid1_clients;  /* clients we have */
144 };
145 #endif
146
147 struct ost_obd {
148         struct ptlrpc_service *ost_service;
149
150         struct obd_device *ost_tgt;
151         struct obd_conn ost_conn;
152 };
153
154 struct osc_obd {
155         struct obd_device *osc_tgt;
156         struct ptlrpc_client *osc_client;
157         struct ptlrpc_client *osc_ldlm_client;
158         struct ptlrpc_connection *osc_conn;
159 };
160
161 struct lov_obd {
162         int lov_count;
163         struct obd_conn *lov_targets;
164 };
165
166 /* corresponds to one of the obd's */
167 #define MAX_MULTI       16
168 struct obd_device {
169         struct obd_type *obd_type;
170         char *obd_name;
171         __u8 obd_uuid[37];
172
173         int obd_minor;
174         int obd_flags;
175         int obd_refcnt;
176         struct obd_devicename obd_fsname;
177         struct proc_dir_entry *obd_proc_entry;
178         int obd_multi_count;
179         struct obd_conn obd_multi_conn[MAX_MULTI];
180         unsigned int obd_gen_last_id;
181         unsigned long obd_gen_prealloc_quota;
182         struct list_head obd_gen_clients;
183         struct list_head obd_req_list;
184         wait_queue_head_t obd_req_waitq;
185         struct ldlm_namespace *obd_namespace;
186         union {
187                 struct ext2_obd ext2;
188                 struct filter_obd filter;
189                 struct mds_obd mds;
190                 struct ost_obd ost;
191                 struct osc_obd osc;
192                 struct ldlm_obd ldlm;
193                 struct echo_obd echo;
194                 struct recovd_obd recovd;
195                 struct trace_obd trace;
196                 struct lov_obd lov;
197 #if 0
198                 struct raid1_obd raid1;
199                 struct snap_obd snap;
200 #endif
201         } u;
202 };
203
204 struct obd_ops {
205         int (*o_iocontrol)(int cmd, struct obd_conn *, int len, void *karg,
206                            void *uarg);
207         int (*o_get_info)(struct obd_conn *, obd_count keylen, void *key,
208                           obd_count *vallen, void **val);
209         int (*o_set_info)(struct obd_conn *, obd_count keylen, void *key,
210                           obd_count vallen, void *val);
211         int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
212         int (*o_detach)(struct obd_device *dev);
213         int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
214         int (*o_cleanup)(struct obd_device *dev);
215         int (*o_connect)(struct obd_conn *conn);
216         int (*o_disconnect)(struct obd_conn *conn);
217
218
219         int (*o_statfs)(struct obd_conn *conn, struct statfs *statfs);
220         int (*o_preallocate)(struct obd_conn *, obd_count *req, obd_id *ids);
221         int (*o_create)(struct obd_conn *conn,  struct obdo *oa);
222         int (*o_destroy)(struct obd_conn *conn, struct obdo *oa);
223         int (*o_setattr)(struct obd_conn *conn, struct obdo *oa);
224         int (*o_getattr)(struct obd_conn *conn, struct obdo *oa);
225         int (*o_open)(struct obd_conn *conn, struct obdo *oa);
226         int (*o_close)(struct obd_conn *conn, struct obdo *oa);
227         int (*o_read)(struct obd_conn *conn, struct obdo *oa, char *buf,
228                       obd_size *count, obd_off offset);
229         int (*o_write)(struct obd_conn *conn, struct obdo *oa, char *buf,
230                        obd_size *count, obd_off offset);
231         int (*o_brw)(int rw, struct obd_conn *conn, obd_count num_oa,
232                      struct obdo **oa, obd_count *oa_bufs, struct page **buf,
233                      obd_size *count, obd_off *offset, obd_flag *flags);
234         int (*o_punch)(struct obd_conn *conn, struct obdo *tgt, obd_size count,
235                        obd_off offset);
236         int (*o_sync)(struct obd_conn *conn, struct obdo *tgt, obd_size count,
237                       obd_off offset);
238         int (*o_migrate)(struct obd_conn *conn, struct obdo *dst,
239                          struct obdo *src, obd_size count, obd_off offset);
240         int (*o_copy)(struct obd_conn *dstconn, struct obdo *dst,
241                       struct obd_conn *srconn, struct obdo *src,
242                       obd_size count, obd_off offset);
243         int (*o_iterate)(struct obd_conn *conn, int (*)(obd_id, obd_gr, void *),
244                          obd_id *startid, obd_gr group, void *data);
245         int (*o_preprw)(int cmd, struct obd_conn *conn,
246                         int objcount, struct obd_ioobj *obj,
247                         int niocount, struct niobuf_remote *remote,
248                         struct niobuf_local *local);
249         int (*o_commitrw)(int cmd, struct obd_conn *conn,
250                           int objcount, struct obd_ioobj *obj,
251                           int niocount, struct niobuf_local *local);
252         int (*o_enqueue)(struct obd_conn *conn, struct ldlm_namespace *ns,
253                          struct ldlm_handle *parent_lock, __u64 *res_id,
254                          __u32 type, struct ldlm_extent *, __u32 mode,
255                          int *flags, void *data, int datalen,
256                          struct ldlm_handle *lockh);
257         int (*o_cancel)(struct obd_conn *, __u32 mode, struct ldlm_handle *);
258 };
259
260 #endif