Whamcloud - gitweb
Cleanup : no more "sim" now "ext2"
[fs/lustre-release.git] / lustre / include / linux / obd_class.h
1 #ifndef __LINUX_CLASS_OBD_H
2 #define __LINUX_CLASS_OBD_H
3
4 #include <linux/fs.h>
5 #include <linux/ext2_fs.h>
6 #include <linux/time.h>
7 #include <linux/obd.h>
8
9 #include <linux/obd_sim.h>
10 #include <linux/obd_snap.h>
11 /* #include <linux/obd_fc.h> */
12 #include <linux/obd_raid1.h>
13 #include <linux/obd_rpc.h>
14
15
16 #define OBD_PSDEV_MAJOR 120
17 #define MAX_OBD_DEVICES 2
18 #define MAX_MULTI 16
19
20 typedef int objid;
21 typedef struct inode obdattr;
22
23 extern struct obd_device obd_dev[MAX_OBD_DEVICES];
24
25
26
27 #define OBD_ATTACHED 0x1
28 #define OBD_SET_UP   0x2
29
30 /* corresponds to one of the obdx */
31 struct obd_device {
32         struct obd_type *obd_type;
33         int obd_minor;
34         int obd_flags;
35         int obd_refcnt; 
36         int obd_multi_count;
37         struct obd_device *obd_multi_dev[MAX_MULTI];
38         struct obd_conn_info obd_multi_conns[MAX_MULTI];
39         unsigned int obd_gen_last_id;
40         unsigned long obd_gen_prealloc_quota;
41         struct list_head obd_gen_clients;
42         union {
43                 struct ext2_obd ext2;
44                 struct raid1_obd raid1;
45                 struct snap_obd snap;
46                 struct rpc_obd rpc;
47                 /* struct fc_obd fc; */
48         } u;
49 };
50
51 struct obd_ops {
52         int (*o_attach)(struct obd_device *, int len, void *);
53         int (*o_format)(struct obd_device *, int len, void *);
54         int (*o_partition)(struct obd_device *, int len, void *);
55         int (*o_connect)(struct obd_device *, struct obd_conn_info *info);
56         int (*o_disconnect)(unsigned int conn_id);
57         int (*o_setup) (struct obd_device *dev, int len, void *data);
58         int (*o_cleanup)(struct obd_device *dev);
59         int (*o_setattr)(unsigned int conn_id, unsigned long id, struct inode *iattr);
60         int (*o_getattr)(unsigned int conn_id, unsigned long id, struct inode *iattr);
61         int (*o_statfs)(unsigned int conn_id, struct statfs *statfs);
62         int (*o_create)(int conn_id, int prealloc_ino, int *er);
63         int (*o_destroy)(unsigned int conn_id, unsigned long ino);
64         unsigned long (*o_read)(unsigned int conn_id, unsigned long ino, char *buf, unsigned long count, loff_t offset, int *err);
65         unsigned long (*o_read2)(unsigned int conn_id, unsigned long ino, char *buf, unsigned long count, loff_t offset, int *err);
66         unsigned long (*o_write)(unsigned int conn_id, unsigned long ino, char *buf, unsigned long count, loff_t offset, int *err);
67         int (*o_brw)(int rw, int conn, obdattr *obj, struct page *page, int create);
68         long (*o_preallocate)(unsigned int conn_id, int req, long inodes[32], int *err);
69         int (*o_cleanup_device)(struct obd_device *);
70         int  (*o_get_info)(unsigned int conn_id, int keylen, void *key, int *vallen, void **val);
71         int  (*o_set_info)(unsigned int conn_id, int keylen, void *key, int vallen, void *val);
72 };
73
74 #define OBP(dev,op) dev->obd_type->typ_ops->o_ ## op
75
76 int obd_register_type(struct obd_ops *ops, char *nm);
77 int obd_unregister_type(char *nm);
78
79 struct obd_client {
80         struct list_head cli_chain;
81         struct obd_device *cli_obd;
82         unsigned int cli_id;
83         unsigned long cli_prealloc_quota;
84         struct list_head cli_prealloc_inodes;
85 };
86
87 struct obd_prealloc_inode {
88         struct list_head obd_prealloc_chain;
89         unsigned long inode;
90 };
91
92 /* generic operations shared by various OBD types */
93 int gen_connect (struct obd_device *obddev, 
94                      struct obd_conn_info * conninfo);
95 int gen_disconnect(unsigned int conn_id);
96 int gen_multi_setup(struct obd_device *obddev, int len, void *data);
97 int gen_multi_cleanup(struct obd_device *obddev);
98 int gen_multi_attach(struct obd_device *obddev, int len, void *data);
99 struct obd_client *gen_client(int cli_id);
100 int gen_multi_cleanup_device(struct obd_device *obddev);
101 int gen_cleanup(struct obd_device *obddev);
102
103
104
105 /*
106  * ioctl commands
107  */
108 struct oic_attach {
109         int  att_typelen;
110         void *att_type;
111         int  att_datalen;
112         void *att_data;
113 };
114
115 struct oic_prealloc_s {
116         unsigned long cli_id;
117         unsigned long alloc; /* user sets it to the number of inodes requesting
118                      * to be preallocated.  kernel sets it to the actual number
119                      * of succesfully preallocated inodes */
120         long inodes[32]; /* actual inode numbers */
121 };
122
123 struct oic_create_s {
124         unsigned int conn_id;
125         unsigned long prealloc;
126 };
127
128 struct oic_attr_s {
129         unsigned int conn_id;
130         unsigned long ino;
131         struct iattr iattr;
132 };
133 struct oic_rw_s {
134         unsigned int conn_id;
135         unsigned long inode;
136         char * buf;
137         unsigned long count;
138         loff_t offset;
139 };
140 struct oic_partition {
141         int partition;
142         unsigned int size;
143 };
144
145
146 #define OBD_IOC_CREATE                 _IOR ('f',  3, long)
147 #define OBD_IOC_SETUP_OBDDEV           _IOW ('f',  4, long)
148 #define OBD_IOC_CLEANUP                _IO  ('f',  5      )
149 #define OBD_IOC_DESTROY                _IOW ('f',  6, long)
150 #define OBD_IOC_PREALLOCATE            _IOWR('f',  7, long)
151 #define OBD_IOC_DEC_USE_COUNT          _IO  ('f',  8      )
152 #define OBD_IOC_SETATTR                _IOW ('f',  9, long)
153 #define OBD_IOC_GETATTR                _IOR ('f', 10, long)
154 #define OBD_IOC_READ                   _IOWR('f', 11, long)
155 #define OBD_IOC_WRITE                  _IOWR('f', 12, long)
156 #define OBD_IOC_CONNECT                _IOR ('f', 13, long)
157 #define OBD_IOC_DISCONNECT             _IOW ('f', 14, long)
158 #define OBD_IOC_STATFS                 _IOWR('f', 15, long)
159 #define OBD_IOC_SYNC                   _IOR ('f',  16, long)
160 #define OBD_IOC_READ2                  _IOWR('f', 17, long)
161 #define OBD_IOC_FORMAT                 _IOWR('f', 18, long)
162 #define OBD_IOC_PARTITION              _IOWR('f', 19, long)
163 #define OBD_IOC_ATTACH                 _IOWR('f', 20, long)
164
165 #define OBD_IOC_DEC_FS_USE_COUNT       _IO  ('f', 32      )
166
167
168 /* sysctl.c */
169 extern void obd_sysctl_init (void);
170 extern void obd_sysctl_clean (void);
171
172
173 #endif /* __LINUX_CLASS_OBD_H */