1 #ifndef __LINUX_CLASS_OBD_H
2 #define __LINUX_CLASS_OBD_H
5 #include <linux/ext2_fs.h>
6 #include <linux/time.h>
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>
16 #define OBD_PSDEV_MAJOR 120
17 #define MAX_OBD_DEVICES 2
21 typedef struct inode obdattr;
23 extern struct obd_device obd_dev[MAX_OBD_DEVICES];
27 #define OBD_ATTACHED 0x1
28 #define OBD_SET_UP 0x2
30 /* corresponds to one of the obdx */
32 struct obd_type *obd_type;
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;
44 struct raid1_obd raid1;
47 /* struct fc_obd fc; */
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);
74 #define OBP(dev,op) dev->obd_type->typ_ops->o_ ## op
76 int obd_register_type(struct obd_ops *ops, char *nm);
77 int obd_unregister_type(char *nm);
80 struct list_head cli_chain;
81 struct obd_device *cli_obd;
83 unsigned long cli_prealloc_quota;
84 struct list_head cli_prealloc_inodes;
87 struct obd_prealloc_inode {
88 struct list_head obd_prealloc_chain;
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);
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 */
123 struct oic_create_s {
124 unsigned int conn_id;
125 unsigned long prealloc;
129 unsigned int conn_id;
134 unsigned int conn_id;
140 struct oic_partition {
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)
165 #define OBD_IOC_DEC_FS_USE_COUNT _IO ('f', 32 )
169 extern void obd_sysctl_init (void);
170 extern void obd_sysctl_clean (void);
173 #endif /* __LINUX_CLASS_OBD_H */