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