1 #ifndef __LINUX_SYM_OBD_H
2 #define __LINUX_SYM_OBD_H
5 #include <linux/ext2_fs.h>
12 /* global variables */
13 extern int obd_debug_level;
14 extern int obd_print_entry;
17 #define D_PSDEV 1 /* debug information from psdev.c */
24 #define D_MALLOC 128 /* print malloc, free information */
25 #define D_CACHE 256 /* cache-related items */
26 #define D_INFO 512 /* general information, especially from interface.c */
27 #define D_IOCTL 1024 /* ioctl related information */
28 #define D_BLOCKS 2048 /* ext2 block allocation */
31 #define CDEBUG(mask, format, a...) \
33 if (obd_debug_level & mask) { \
34 printk("(%s,l. %d): ", __FUNCTION__, __LINE__); \
35 printk(format, ## a); } \
39 if (obd_print_entry) \
40 printk("Process %d entered %s\n", current->pid, __FUNCTION__)
43 if (obd_print_entry) \
44 printk("Process %d leaving %s\n", current->pid, __FUNCTION__)
46 #else /* SYM_OBD_DEBUG */
48 # define CDEBUG(mask, format, a...) ;
52 #endif /* SYM_OBD_DEBUG */
56 #define OBD_ALLOC(ptr, cast, size) \
59 ptr = (cast)kmalloc((unsigned long) size, GFP_KERNEL); \
60 CDEBUG(D_MALLOC, "kmalloced: %x at %x.\n", \
61 (int) size, (int) ptr); \
63 ptr = (cast)vmalloc((unsigned long) size); \
64 CDEBUG(D_MALLOC, "vmalloced: %x at %x.\n", \
65 (int) size, (int) ptr); \
68 printk("kernel malloc returns 0 at %s:%d\n", \
69 __FILE__, __LINE__); \
71 memset(ptr, 0, size); \
74 #define OBD_FREE(ptr,size) \
77 kfree_s((ptr), (size)); \
78 CDEBUG(D_MALLOC, "kfreed: %x at %x.\n", \
79 (int) size, (int) ptr); \
82 CDEBUG(D_MALLOC, "vfreed: %x at %x.\n", \
83 (int) size, (int) ptr); \
92 long alloc; /* user sets it to the number of inodes requesting to be
93 * preallocated. kernel sets it to the actual number of
94 * succesfully preallocate inodes */
95 long inodes[32]; /* actual inode numbers */
98 #define OBD_IOC_CREATE _IOR('f', 3, long)
99 #define OBD_IOC_SETUP _IOW('f', 4, long)
100 #define OBD_IOC_SYNC _IOR('f', 5, long)
101 #define OBD_IOC_DESTROY _IOW('f', 6, long)
103 #define OBD_IOC_DEC_USE_COUNT _IO('f', 8)
107 int obd_new_block (const struct inode * inode, unsigned long goal,
108 u32 * prealloc_count, u32 * prealloc_block, int * err);
109 void obd_free_blocks (const struct inode * inode, unsigned long block,
110 unsigned long count);
111 unsigned long obd_count_free_blocks (struct super_block * sb);
112 int ext2_group_sparse(int group);
113 struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
114 unsigned int block_group,
115 struct buffer_head ** bh);
119 unsigned long ext2_count_free(struct buffer_head * map, unsigned int numchars);
122 extern int obd_sync_file(struct file * file, struct dentry *dentry);
125 extern void ext2_free_inode (struct inode * inode);
126 extern struct inode * ext2_new_inode (const struct inode * dir, int mode,
128 extern unsigned long ext2_count_free_inodes (struct super_block * sb);
129 extern void ext2_check_inodes_bitmap (struct super_block * sb);
132 void obd_read_inode (struct inode * inode);
133 void obd_write_inode (struct inode * inode);
134 void obd_put_inode (struct inode * inode);
135 void obd_delete_inode (struct inode * inode);
136 void obd_discard_prealloc_blocks (struct inode * inode);
137 int obd_sync_inode (struct inode *inode);
138 struct buffer_head * obd_bread (struct inode * inode, int block,
139 int create, int *err);
140 struct buffer_head * obd_getblk (struct inode * inode, long block,
141 int create, int * err);
144 extern int obd_create (struct super_block * sb, int inode_hint, int * err);
145 extern void obd_unlink (struct inode * inode);
148 int obd_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
152 #define obd_error obd_warning
153 #define obd_panic obd_warning
154 extern void obd_warning (struct super_block *, const char *, const char *, ...)
155 __attribute__ ((format (printf, 3, 4)));
156 int obd_remount (struct super_block * sb, int * flags, char * data);
157 struct super_block * obd_read_super (struct super_block * sb, void * data,
161 extern void obd_sysctl_init (void);
162 extern void obd_sysctl_clean (void);
165 void obd_truncate (struct inode * inode);
169 extern struct inode_operations obd_dir_inode_operations;
172 extern struct inode_operations obd_file_inode_operations;
174 #endif /* __LINUX_SYM_OBD_H */