Whamcloud - gitweb
- more of the locking infrastructure.
[fs/lustre-release.git] / lustre / include / linux / obd.h
1 #ifndef __OBD_H
2 #define __OBD_H
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 #include <linux/fs.h>
11 #include <linux/list.h>
12 #include <linux/smp_lock.h>
13
14 #include <linux/lustre_idl.h>
15
16 struct obd_conn_info {
17         unsigned int conn_id;     /* handle */
18 };
19
20 struct obd_type {
21         struct list_head typ_chain;
22         struct obd_ops *typ_ops;
23         char *typ_name;
24         int  typ_refcnt;
25 };
26
27 struct obd_run_ctxt { 
28         struct vfsmount *pwdmnt;
29         struct dentry   *pwd;
30         mm_segment_t     fs;
31 };
32
33 struct obd_conn {
34         struct obd_device *oc_dev;
35         uint32_t oc_id;
36 };
37
38 struct obd_devicename {
39         uint32_t len;
40         char *   name;
41         struct dentry *dentry;   /* file system obd device names */
42         __u8           _uuid[16]; /* uuid obd device names */
43 };
44
45
46 /* Individual type definitions */
47
48 struct ext2_obd {
49         struct super_block * e2_sb;
50         struct vfsmount *e2_vfsmnt;
51 };
52
53 struct filter_obd {
54         char *fo_fstype;
55         struct super_block * fo_sb;
56         struct vfsmount *fo_vfsmnt;
57         struct obd_run_ctxt fo_ctxt;
58         spinlock_t fo_lock;
59         __u64 fo_lastino;
60         struct file_operations *fo_fop; 
61         struct inode_operations *fo_iop;
62         struct address_space_operations *fo_aops;
63 };
64
65 struct mds_obd {
66         struct ptlrpc_service *mds_service;
67
68         char *mds_fstype;
69         struct super_block * mds_sb;
70         struct vfsmount *mds_vfsmnt;
71         struct obd_run_ctxt mds_ctxt;
72         struct file_operations *mds_fop; 
73         struct inode_operations *mds_iop;
74         struct address_space_operations *mds_aops;
75 };
76
77 struct ldlm_obd {
78         struct ptlrpc_service *ldlm_service;
79
80         struct list_head ldlm_namespaces;
81         spinlock_t       ldlm_lock;
82 };
83
84 struct echo_obd {
85         char *eo_fstype;
86         struct super_block *eo_sb;
87         struct vfsmount *eo_vfsmnt;
88         struct obd_run_ctxt eo_ctxt;
89         spinlock_t eo_lock;
90         __u64 eo_lastino;
91         struct file_operations *eo_fop; 
92         struct inode_operations *eo_iop;
93         struct address_space_operations *eo_aops;
94 };
95
96 struct trace_obd {
97         struct obdtrace_opstats *stats;
98 };
99
100 #if 0
101 struct snap_obd {
102         unsigned int snap_index;  /* which snapshot index are we accessing */
103         int snap_tableno;
104 };
105
106 struct raid1_obd {
107         unsigned int raid1_count; /* how many replicas */
108         /* devices to replicate on */
109         struct obd_device *raid1_devlist[MAX_RAID1];
110         /* connections we make */
111         struct obd_conn_info raid1_connections[MAX_RAID1];
112         struct list_head raid1_clients;  /* clients we have */
113 };
114 #endif
115
116 struct ost_obd {
117         struct ptlrpc_service *ost_service;
118
119         struct obd_device *ost_tgt;
120         struct obd_conn ost_conn;
121 };
122
123 struct osc_obd {
124         struct obd_device *osc_tgt;
125         struct ptlrpc_client *osc_peer;
126 };
127
128 /* corresponds to one of the obd's */
129 #define MAX_MULTI       16
130 struct obd_device {
131         struct obd_type *obd_type;
132         int obd_minor;
133         int obd_flags;
134         int obd_refcnt; 
135         struct obd_devicename obd_fsname; 
136         struct proc_dir_entry *obd_proc_entry;
137         int obd_multi_count;
138         struct obd_conn obd_multi_conn[MAX_MULTI];
139         unsigned int obd_gen_last_id;
140         unsigned long obd_gen_prealloc_quota;
141         struct list_head obd_gen_clients;
142         struct list_head obd_req_list;
143         wait_queue_head_t obd_req_waitq;
144         union {
145                 struct ext2_obd ext2;
146                 struct filter_obd filter;
147                 struct mds_obd mds;
148                 struct ost_obd ost;
149                 struct osc_obd osc;
150                 struct ldlm_obd ldlm;
151                 struct echo_obd echo;
152                 struct trace_obd trace;
153 #if 0
154                 struct raid1_obd raid1;
155                 struct snap_obd snap;
156 #endif
157         } u;
158 };
159
160 struct obd_ops {
161         int (*o_iocontrol)(int cmd, struct obd_conn *, int len, void *karg,
162                            void *uarg);
163         int (*o_get_info)(struct obd_conn *, obd_count keylen, void *key,
164                           obd_count *vallen, void **val);
165         int (*o_set_info)(struct obd_conn *, obd_count keylen, void *key,
166                           obd_count vallen, void *val);
167         int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
168         int (*o_detach)(struct obd_device *dev);
169         int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
170         int (*o_cleanup)(struct obd_device *dev);
171         int (*o_connect)(struct obd_conn *conn);
172         int (*o_disconnect)(struct obd_conn *conn);
173         int (*o_statfs)(struct obd_conn *conn, struct statfs *statfs);
174         int (*o_preallocate)(struct obd_conn *, obd_count *req, obd_id *ids);
175         int (*o_create)(struct obd_conn *conn,  struct obdo *oa);
176         int (*o_destroy)(struct obd_conn *conn, struct obdo *oa);
177         int (*o_setattr)(struct obd_conn *conn, struct obdo *oa);
178         int (*o_getattr)(struct obd_conn *conn, struct obdo *oa);
179         int (*o_open)(struct obd_conn *conn, struct obdo *oa);
180         int (*o_close)(struct obd_conn *conn, struct obdo *oa);
181         int (*o_read)(struct obd_conn *conn, struct obdo *oa, char *buf,
182                       obd_size *count, obd_off offset);
183         int (*o_write)(struct obd_conn *conn, struct obdo *oa, char *buf,
184                        obd_size *count, obd_off offset);
185         int (*o_brw)(int rw, struct obd_conn *conn, obd_count num_oa,
186                      struct obdo **oa, obd_count *oa_bufs, struct page **buf,
187                      obd_size *count, obd_off *offset, obd_flag *flags);
188         int (*o_punch)(struct obd_conn *conn, struct obdo *tgt, obd_size count,
189                        obd_off offset);
190         int (*o_sync)(struct obd_conn *conn, struct obdo *tgt, obd_size count,
191                       obd_off offset);
192         int (*o_migrate)(struct obd_conn *conn, struct obdo *dst,
193                          struct obdo *src, obd_size count, obd_off offset);
194         int (*o_copy)(struct obd_conn *dstconn, struct obdo *dst,
195                       struct obd_conn *srconn, struct obdo *src,
196                       obd_size count, obd_off offset);
197         int (*o_iterate)(struct obd_conn *conn, int (*)(obd_id, obd_gr, void *),
198                          obd_id *startid, obd_gr group, void *data);
199         int (*o_preprw)(int cmd, struct obd_conn *conn, 
200                         int objcount, struct obd_ioobj *obj, 
201                         int niocount, struct niobuf *nb, 
202                         struct niobuf *res);
203         int (*o_commitrw)(int cmd, struct obd_conn *conn, 
204                           int objcount, struct obd_ioobj *obj, 
205                           int niocount, struct niobuf *res);
206 };
207
208 #endif