Whamcloud - gitweb
200e45b446a420d30a71e8e2a41ccdbafe8b6da3
[fs/lustre-release.git] / lustre / include / linux / obd_class.h
1 #ifndef __LINUX_SIM_OBD_H
2 #define __LINUX_SIM_OBD_H
3
4 #include <linux/fs.h>
5 #include <linux/ext2_fs.h>
6
7 #include <linux/obd_sim.h>
8 /* #include <linux/obd_fc.h> */
9
10 #define OBD_PSDEV_MAJOR 120
11 #define MAX_OBD_DEVICES 2
12
13 extern struct obd_device obd_dev[MAX_OBD_DEVICES];
14
15 struct obd_conn_info {
16         unsigned int conn_id;     /* handle */
17 };
18
19 struct obd_type {
20         struct list_head typ_chain;
21         struct obd_ops *typ_ops;
22         char *typ_name;
23         int  typ_refcnt;
24 };
25
26 #define OBD_ATTACHED 0x1
27 #define OBD_SET_UP   0x2
28
29 /* corresponds to one of the obdx */
30 struct obd_device {
31         struct obd_type *obd_type;
32         int obd_minor;
33         int obd_flags;
34         int obd_refcnt; 
35         union {
36                 struct sim_obd sim;
37                 /* struct fc_obd fc; */
38         } u;
39 };
40
41 struct obd_ops {
42         int (*o_attach)(struct obd_device *, int len, void *);
43         int (*o_format)(struct obd_device *, int len, void *);
44         int (*o_partition)(struct obd_device *, int len, void *);
45         int (*o_connect)(struct obd_device *, struct obd_conn_info *info);
46         int (*o_disconnect)(unsigned int conn_id);
47         int (*o_setup) (struct obd_device *dev, int len, void *data);
48         int (*o_cleanup)(struct obd_device *dev);
49         int (*o_setattr)(unsigned int conn_id, unsigned long id, struct inode *iattr);
50         int (*o_getattr)(unsigned int conn_id, unsigned long id, struct inode *iattr);
51         int (*o_statfs)(unsigned int conn_id, struct statfs *statfs);
52         int (*o_create)(struct obd_device *, int prealloc_ino, int *er);
53         int (*o_destroy)(unsigned int conn_id, unsigned long ino);
54         unsigned long (*o_read)(unsigned int conn_id, unsigned long ino, char *buf, unsigned long count, loff_t offset, int *err);
55         unsigned long (*o_read2)(unsigned int conn_id, unsigned long ino, char *buf, unsigned long count, loff_t offset, int *err);
56         unsigned long (*o_write)(unsigned int conn_id, unsigned long ino, char *buf, unsigned long count, loff_t offset, int *err);
57         int (*o_brw)(int rw, int conn, int objectid, struct page *page, int create);
58         long (*o_preallocate)(unsigned int conn_id, int req, long inodes[32], int *err);
59         void (*o_cleanup_device)(int dev);
60         int  (*o_get_info)(unsigned int conn_id, int keylen, void *key, int *vallen, void **val);
61         int  (*o_set_info)(unsigned int conn_id, int keylen, void *key, int vallen, void *val);
62 };
63
64 int obd_register_type(struct obd_ops *ops, char *nm);
65 int obd_unregister_type(char *nm);
66
67 struct obd_client {
68         struct list_head cli_chain;
69         struct obd_device *cli_obd;
70         unsigned int cli_id;
71         unsigned long cli_prealloc_quota;
72         struct list_head cli_prealloc_inodes;
73 };
74
75 struct obd_prealloc_inode {
76         struct list_head obd_prealloc_chain;
77         unsigned long inode;
78 };
79
80 /*
81  * ioctl commands
82  */
83 struct oic_attach {
84         int  att_typelen;
85         void *att_type;
86         int  att_datalen;
87         void *att_data;
88 };
89
90 struct oic_prealloc_s {
91         unsigned long cli_id;
92         unsigned long alloc; /* user sets it to the number of inodes requesting
93                      * to be preallocated.  kernel sets it to the actual number
94                      * of succesfully preallocated inodes */
95         long inodes[32]; /* actual inode numbers */
96 };
97 struct oic_attr_s {
98         unsigned int conn_id;
99         unsigned long inode;
100
101         struct iattr iattr;
102 };
103 struct oic_rw_s {
104         unsigned int conn_id;
105         unsigned long inode;
106         char * buf;
107         unsigned long count;
108         loff_t offset;
109 };
110 struct oic_partition {
111         int partition;
112         unsigned int size;
113 };
114
115
116 #define OBD_IOC_CREATE                 _IOR ('f',  3, long)
117 #define OBD_IOC_SETUP_OBDDEV           _IOW ('f',  4, long)
118 #define OBD_IOC_CLEANUP_OBDDEV         _IO  ('f',  5      )
119 #define OBD_IOC_DESTROY                _IOW ('f',  6, long)
120 #define OBD_IOC_PREALLOCATE            _IOWR('f',  7, long)
121 #define OBD_IOC_DEC_USE_COUNT          _IO  ('f',  8      )
122 #define OBD_IOC_SETATTR                _IOW ('f',  9, long)
123 #define OBD_IOC_GETATTR                _IOR ('f', 10, long)
124 #define OBD_IOC_READ                   _IOWR('f', 11, long)
125 #define OBD_IOC_WRITE                  _IOWR('f', 12, long)
126 #define OBD_IOC_CONNECT                _IOR ('f', 13, long)
127 #define OBD_IOC_DISCONNECT             _IOW ('f', 14, long)
128 #define OBD_IOC_STATFS                 _IOWR('f', 15, long)
129 #define OBD_IOC_SYNC                   _IOR ('f',  16, long)
130 #define OBD_IOC_READ2                  _IOWR('f', 17, long)
131 #define OBD_IOC_FORMAT                 _IOWR('f', 18, long)
132 #define OBD_IOC_PARTITION              _IOWR('f', 19, long)
133 #define OBD_IOC_ATTACH                 _IOWR('f', 20, long)
134
135 #define OBD_IOC_DEC_FS_USE_COUNT       _IO  ('f', 32      )
136
137
138 /* sysctl.c */
139 extern void obd_sysctl_init (void);
140 extern void obd_sysctl_clean (void);
141
142
143 #endif /* __LINUX_SIM_OBD_H */