1 #ifndef __LINUX_SIM_OBD_H
2 #define __LINUX_SIM_OBD_H
5 #include <linux/ext2_fs.h>
6 #include <linux/malloc.h>
7 #include <linux/vmalloc.h>
14 /* global variables */
15 extern int obd_debug_level;
16 extern int obd_print_entry;
19 #define D_PSDEV 1 /* debug information from psdev.c */
24 #define D_WARNING 32 /* misc warnings */
25 #define D_EXT2 64 /* anything from ext2_debug */
26 #define D_MALLOC 128 /* print malloc, free information */
27 #define D_CACHE 256 /* cache-related items */
28 #define D_INFO 512 /* general information, especially from interface.c */
29 #define D_IOCTL 1024 /* ioctl related information */
30 #define D_BLOCKS 2048 /* ext2 block allocation */
33 #define CDEBUG(mask, format, a...) \
35 if (obd_debug_level & mask) { \
36 printk("(%s,l. %d): ", __FUNCTION__, __LINE__); \
37 printk(format, ## a); } \
41 if (obd_print_entry) \
42 printk("Process %d entered %s\n", current->pid, __FUNCTION__)
45 if (obd_print_entry) \
46 printk("Process %d leaving %s\n", current->pid, __FUNCTION__)
48 #else /* SIM_OBD_DEBUG */
54 #endif /* SIM_OBD_DEBUG */
58 #define OBD_ALLOC(ptr, cast, size) \
61 ptr = (cast)kmalloc((unsigned long) size, GFP_KERNEL); \
62 CDEBUG(D_MALLOC, "kmalloced: %x at %x.\n", \
63 (int) size, (int) ptr); \
65 ptr = (cast)vmalloc((unsigned long) size); \
66 CDEBUG(D_MALLOC, "vmalloced: %x at %x.\n", \
67 (int) size, (int) ptr); \
70 printk("kernel malloc returns 0 at %s:%d\n", \
71 __FILE__, __LINE__); \
73 memset(ptr, 0, size); \
76 #define OBD_FREE(ptr,size) \
79 kfree_s((ptr), (size)); \
80 CDEBUG(D_MALLOC, "kfreed: %x at %x.\n", \
81 (int) size, (int) ptr); \
84 CDEBUG(D_MALLOC, "vfreed: %x at %x.\n", \
85 (int) size, (int) ptr); \
90 #define MAX_DEVICES 128
91 struct obd_conn_info {
93 unsigned long conn_ino;
94 unsigned long conn_blocksize;
95 unsigned char conn_blocksize_bits;
100 struct super_block * sb;
101 unsigned int last_id;
102 unsigned long prealloc_quota;
103 struct list_head clients;
107 struct list_head cli_chain;
110 unsigned long cli_prealloc_quota;
111 struct list_head cli_prealloc_inodes;
114 struct obd_prealloc_inode {
115 struct list_head obd_prealloc_chain;
122 struct oic_prealloc_s {
123 unsigned long cli_id;
124 unsigned long alloc; /* user sets it to the number of inodes requesting
125 * to be preallocated. kernel sets it to the actual number
126 * of succesfully preallocated inodes */
127 long inodes[32]; /* actual inode numbers */
130 unsigned int conn_id;
136 unsigned int conn_id;
143 #define OBD_IOC_CREATE _IOR ('f', 3, long)
144 #define OBD_IOC_SETUP _IOW ('f', 4, long)
145 #define OBD_IOC_SYNC _IOR ('f', 5, long)
146 #define OBD_IOC_DESTROY _IOW ('f', 6, long)
147 #define OBD_IOC_PREALLOCATE _IOWR('f', 7, long)
148 #define OBD_IOC_DEC_USE_COUNT _IO ('f', 8 )
149 #define OBD_IOC_SETATTR _IOW ('f', 9, long)
150 #define OBD_IOC_GETATTR _IOR ('f', 10, long)
151 #define OBD_IOC_READ _IOWR('f', 11, long)
152 #define OBD_IOC_WRITE _IOWR('f', 12, long)
153 #define OBD_IOC_CONNECT _IOR ('f', 13, long)
154 #define OBD_IOC_DISCONNECT _IOW ('f', 14, long)
155 #define OBD_IOC_STATFS _IOWR('f', 15, long)
156 #define OBD_IOC_DEC_FS_USE_COUNT _IO ('f', 16 )
159 int ext2_new_block (const struct inode * inode, unsigned long goal,
160 u32 * prealloc_count, u32 * prealloc_block, int * err);
161 void ext2_free_blocks (const struct inode * inode, unsigned long block,
162 unsigned long count);
163 unsigned long ext2_count_free_blocks (struct super_block * sb);
164 int ext2_group_sparse(int group);
165 struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
166 unsigned int block_group,
167 struct buffer_head ** bh);
171 unsigned long ext2_count_free(struct buffer_head * map, unsigned int numchars);
174 extern int obd_sync_file(struct file * file, struct dentry *dentry);
177 extern void ext2_free_inode (struct inode * inode);
178 extern struct inode * ext2_new_inode (const struct inode * dir, int mode,
180 extern unsigned long ext2_count_free_inodes (struct super_block * sb);
181 extern void ext2_check_inodes_bitmap (struct super_block * sb);
182 extern int load_inode_bitmap (struct super_block * sb,
183 unsigned int block_group);
186 void obd_read_inode (struct inode * inode);
187 void obd_write_inode (struct inode * inode);
188 void obd_put_inode (struct inode * inode);
189 void obd_delete_inode (struct inode * inode);
190 void obd_discard_prealloc_blocks (struct inode * inode);
191 int obd_sync_inode (struct inode *inode);
192 struct buffer_head * obd_bread (struct inode * inode, int block,
193 int create, int *err);
194 struct buffer_head * obd_getblk (struct inode * inode, long block,
195 int create, int * err);
198 extern int obd_create (struct super_block * sb, int inode_hint, int * err);
199 extern void obd_unlink (struct inode * inode);
200 extern struct obd_client * obd_client(int cli_id);
201 extern void obd_cleanup_client (struct obd_device * obddev,
202 struct obd_client * cli);
203 void obd_cleanup_device(int dev);
204 long obd_preallocate_inodes(unsigned int conn_id,
205 int req, long inodes[32], int * err);
206 long obd_preallocate_quota(struct super_block * sb, struct obd_client * cli,
207 unsigned long req, int * err);
208 int obd_connect (int minor, struct obd_conn_info * conninfo);
209 int obd_disconnect (unsigned int conn_id);
210 int obd_setattr(unsigned int conn_id, unsigned long ino, struct iattr * iattr);
211 int obd_getattr(unsigned int conn_id, unsigned long ino, struct iattr * iattr);
212 int obd_destroy(unsigned int conn_id, unsigned long ino);
213 int obd_statfs(unsigned int conn_id, struct statfs * statfs);
214 unsigned long obd_read(unsigned int conn_id, unsigned long ino, char * buf,
215 unsigned long count, loff_t offset, int * err);
216 unsigned long obd_write (unsigned int conn_id, unsigned long ino, char * buf,
217 unsigned long count, loff_t offset, int * err);
220 int obd_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
224 #define ext2_warning obd_warning
226 #define ext2_error obd_warning
227 #define ext2_panic obd_warning
231 # define ext2_debug(format, a...) CDEBUG(D_EXT2, format, ## a)
234 #define obd_error obd_warning
235 #define obd_panic obd_warning
236 #define obd_warning(sb, func, format, a...) CDEBUG(D_WARNING, format, ## a)
238 int obd_remount (struct super_block * sb, int * flags, char * data);
239 struct super_block * ext2_read_super (struct super_block * sb, void * data,
243 extern void obd_sysctl_init (void);
244 extern void obd_sysctl_clean (void);
247 void obd_truncate (struct inode * inode);
251 extern struct inode_operations ext2_dir_inode_operations;
254 extern struct file_operations ext2_file_operations;
255 extern struct inode_operations ext2_file_inode_operations;
258 extern struct super_operations ext2_sops;
260 #endif /* __LINUX_SIM_OBD_H */