Whamcloud - gitweb
Much cleaner separation of the class and simulated obd code.
[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 #define OBD_PSDEV_MAJOR 120
8 #define MAX_OBD_DEVICES 2
9
10 struct obd_conn_info {
11         unsigned int conn_id;     /* handle */
12         unsigned long conn_ino;   /* root inode number */
13         unsigned long conn_blocksize; 
14         unsigned char conn_blocksize_bits;
15 };
16
17 struct obd_type {
18         struct list_head typ_chain;
19         struct obd_ops *typ_ops;
20         char *typ_name;
21         int  typ_refcount;
22 };
23
24 struct obd_device {
25         struct obd_type *obd_type;
26         int refcnt;
27         struct super_block * sb;
28         unsigned int last_id;
29         unsigned long prealloc_quota;
30         struct list_head clients;
31 };
32
33 #define OBD_FL_SETUP 0x1
34
35 struct obd_ops {
36         int (*o_connect)(int minor, struct obd_conn_info *info);
37         int (*o_disconnect)(unsigned int conn_id);
38         int (*o_setup) (struct obd_device *dev, void *data);
39         int (*o_cleanup)(struct obd_device *dev);
40         int (*o_setattr)(unsigned int conn_id, unsigned long id, struct iattr *iattr);
41         int (*o_getattr)(unsigned int conn_id, unsigned long id, struct iattr *iattr);
42         int (*o_statfs)(unsigned int conn_id, struct statfs *statfs);
43         int (*o_create)(struct obd_device *, int prealloc_ino, int *er);
44         int (*o_destroy)(unsigned int conn_id, unsigned long ino);
45         unsigned long (*o_read)(unsigned int conn_id, unsigned long ino, char *buf, unsigned long count, loff_t offset, int *err);
46         unsigned long (*o_write)(unsigned int conn_id, unsigned long ino, char *buf, unsigned long count, loff_t offset, int *err);
47         long (*o_preallocate)(unsigned int conn_id, int req, long inodes[32], int *err);
48         void (*o_cleanup_device)(int dev);
49 };
50
51 int obd_register_type(struct obd_ops *ops, char *nm);
52
53
54 struct obd_client {
55         struct list_head cli_chain;
56         kdev_t minor;
57         unsigned int cli_id;
58         unsigned long cli_prealloc_quota;
59         struct list_head cli_prealloc_inodes;
60 };
61
62 struct obd_prealloc_inode {
63         struct list_head obd_prealloc_chain;
64         unsigned long inode;
65 };
66
67 /*
68  * ioctl commands
69  */
70 struct oic_prealloc_s {
71         unsigned long cli_id;
72         unsigned long alloc; /* user sets it to the number of inodes requesting
73                      * to be preallocated.  kernel sets it to the actual number
74                      * of succesfully preallocated inodes */
75         long inodes[32]; /* actual inode numbers */
76 };
77 struct oic_attr_s {
78         unsigned int conn_id;
79         unsigned long inode;
80
81         struct iattr iattr;
82 };
83 struct oic_rw_s {
84         unsigned int conn_id;
85         unsigned long inode;
86         char * buf;
87         unsigned long count;
88         loff_t offset;
89 };
90
91 #define OBD_IOC_CREATE                 _IOR ('f',  3, long)
92 #define OBD_IOC_SETUP_SUPER            _IOW ('f',  4, long)
93 #define OBD_IOC_CLEANUP_SUPER          _IO  ('f',  5      )
94 #define OBD_IOC_DESTROY                _IOW ('f',  6, long)
95 #define OBD_IOC_PREALLOCATE            _IOWR('f',  7, long)
96 #define OBD_IOC_DEC_USE_COUNT          _IO  ('f',  8      )
97 #define OBD_IOC_SETATTR                _IOW ('f',  9, long)
98 #define OBD_IOC_GETATTR                _IOR ('f', 10, long)
99 #define OBD_IOC_READ                   _IOWR('f', 11, long)
100 #define OBD_IOC_WRITE                  _IOWR('f', 12, long)
101 #define OBD_IOC_CONNECT                _IOR ('f', 13, long)
102 #define OBD_IOC_DISCONNECT             _IOW ('f', 14, long)
103 #define OBD_IOC_STATFS                 _IOWR('f', 15, long)
104 #define OBD_IOC_SYNC                   _IOR ('f',  16, long)
105
106 #define OBD_IOC_DEC_FS_USE_COUNT       _IO  ('f', 32      )
107
108
109 /* sysctl.c */
110 extern void obd_sysctl_init (void);
111 extern void obd_sysctl_clean (void);
112
113
114 #endif /* __LINUX_SIM_OBD_H */