1 #ifndef __LINUX_CLASS_OBD_H
2 #define __LINUX_CLASS_OBD_H
5 #include <linux/ext2_fs.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>
15 #define OBD_PSDEV_MAJOR 120
16 #define MAX_OBD_DEVICES 2
19 typedef unsigned long objid;
20 typedef struct inode obdattr;
22 extern struct obd_device obd_dev[MAX_OBD_DEVICES];
26 #define OBD_ATTACHED 0x1
27 #define OBD_SET_UP 0x2
29 /* corresponds to one of the obdx */
31 struct obd_type *obd_type;
36 struct obd_device *obd_multi_dev[MAX_MULTI];
37 struct obd_conn_info obd_multi_conns[MAX_MULTI];
38 unsigned int obd_gen_last_id;
39 unsigned long obd_gen_prealloc_quota;
40 struct list_head obd_gen_clients;
43 struct raid1_obd raid1;
45 /* struct fc_obd fc; */
50 int (*o_attach)(struct obd_device *, int len, void *);
51 int (*o_format)(struct obd_device *, int len, void *);
52 int (*o_partition)(struct obd_device *, int len, void *);
53 int (*o_connect)(struct obd_device *, struct obd_conn_info *info);
54 int (*o_disconnect)(unsigned int conn_id);
55 int (*o_setup) (struct obd_device *dev, int len, void *data);
56 int (*o_cleanup)(struct obd_device *dev);
57 int (*o_setattr)(unsigned int conn_id, unsigned long id, struct inode *iattr);
58 int (*o_getattr)(unsigned int conn_id, unsigned long id, struct inode *iattr);
59 int (*o_statfs)(unsigned int conn_id, struct statfs *statfs);
60 int (*o_create)(int conn_id, int prealloc_ino, int *er);
61 int (*o_destroy)(unsigned int conn_id, unsigned long ino);
62 unsigned long (*o_read)(unsigned int conn_id, unsigned long ino, char *buf, unsigned long count, loff_t offset, int *err);
63 unsigned long (*o_read2)(unsigned int conn_id, unsigned long ino, char *buf, unsigned long count, loff_t offset, int *err);
64 unsigned long (*o_write)(unsigned int conn_id, unsigned long ino, char *buf, unsigned long count, loff_t offset, int *err);
65 int (*o_brw)(int rw, int conn, int objectid, struct page *page, int create);
66 long (*o_preallocate)(unsigned int conn_id, int req, long inodes[32], int *err);
67 int (*o_cleanup_device)(struct obd_device *);
68 int (*o_get_info)(unsigned int conn_id, int keylen, void *key, int *vallen, void **val);
69 int (*o_set_info)(unsigned int conn_id, int keylen, void *key, int vallen, void *val);
72 #define OBP(dev,op) dev->obd_type->typ_ops->o_ ## op
74 int obd_register_type(struct obd_ops *ops, char *nm);
75 int obd_unregister_type(char *nm);
78 struct list_head cli_chain;
79 struct obd_device *cli_obd;
81 unsigned long cli_prealloc_quota;
82 struct list_head cli_prealloc_inodes;
85 struct obd_prealloc_inode {
86 struct list_head obd_prealloc_chain;
90 /* generic operations shared by various OBD types */
91 int gen_connect (struct obd_device *obddev,
92 struct obd_conn_info * conninfo);
93 int gen_disconnect(unsigned int conn_id);
94 int gen_multi_setup(struct obd_device *obddev, int len, void *data);
95 int gen_multi_cleanup(struct obd_device *obddev);
96 int gen_multi_attach(struct obd_device *obddev, int len, void *data);
97 struct obd_client *gen_client(int cli_id);
98 int gen_multi_cleanup_device(struct obd_device *obddev);
99 int gen_cleanup(struct obd_device *obddev);
113 struct oic_prealloc_s {
114 unsigned long cli_id;
115 unsigned long alloc; /* user sets it to the number of inodes requesting
116 * to be preallocated. kernel sets it to the actual number
117 * of succesfully preallocated inodes */
118 long inodes[32]; /* actual inode numbers */
121 struct oic_create_s {
122 unsigned int conn_id;
123 unsigned long prealloc;
127 unsigned int conn_id;
132 unsigned int conn_id;
138 struct oic_partition {
144 #define OBD_IOC_CREATE _IOR ('f', 3, long)
145 #define OBD_IOC_SETUP_OBDDEV _IOW ('f', 4, long)
146 #define OBD_IOC_CLEANUP _IO ('f', 5 )
147 #define OBD_IOC_DESTROY _IOW ('f', 6, long)
148 #define OBD_IOC_PREALLOCATE _IOWR('f', 7, long)
149 #define OBD_IOC_DEC_USE_COUNT _IO ('f', 8 )
150 #define OBD_IOC_SETATTR _IOW ('f', 9, long)
151 #define OBD_IOC_GETATTR _IOR ('f', 10, long)
152 #define OBD_IOC_READ _IOWR('f', 11, long)
153 #define OBD_IOC_WRITE _IOWR('f', 12, long)
154 #define OBD_IOC_CONNECT _IOR ('f', 13, long)
155 #define OBD_IOC_DISCONNECT _IOW ('f', 14, long)
156 #define OBD_IOC_STATFS _IOWR('f', 15, long)
157 #define OBD_IOC_SYNC _IOR ('f', 16, long)
158 #define OBD_IOC_READ2 _IOWR('f', 17, long)
159 #define OBD_IOC_FORMAT _IOWR('f', 18, long)
160 #define OBD_IOC_PARTITION _IOWR('f', 19, long)
161 #define OBD_IOC_ATTACH _IOWR('f', 20, long)
163 #define OBD_IOC_DEC_FS_USE_COUNT _IO ('f', 32 )
167 extern void obd_sysctl_init (void);
168 extern void obd_sysctl_clean (void);
171 #endif /* __LINUX_CLASS_OBD_H */