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 */
22 #define D_WARNING 32 /* misc warnings */
23 #define D_EXT2 64 /* anything from ext2_debug */
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 */
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)
104 #define OBD_IOC_SETATTR _IOR('f', 9, long)
105 #define OBD_IOC_READ _IOWR('f', 10, long)
108 int ext2_new_block (const struct inode * inode, unsigned long goal,
109 u32 * prealloc_count, u32 * prealloc_block, int * err);
110 void ext2_free_blocks (const struct inode * inode, unsigned long block,
111 unsigned long count);
112 unsigned long ext2_count_free_blocks (struct super_block * sb);
113 int ext2_group_sparse(int group);
114 struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
115 unsigned int block_group,
116 struct buffer_head ** bh);
120 unsigned long ext2_count_free(struct buffer_head * map, unsigned int numchars);
123 extern int obd_sync_file(struct file * file, struct dentry *dentry);
126 extern void ext2_free_inode (struct inode * inode);
127 extern struct inode * ext2_new_inode (const struct inode * dir, int mode,
129 extern unsigned long ext2_count_free_inodes (struct super_block * sb);
130 extern void ext2_check_inodes_bitmap (struct super_block * sb);
133 void obd_read_inode (struct inode * inode);
134 void obd_write_inode (struct inode * inode);
135 void obd_put_inode (struct inode * inode);
136 void obd_delete_inode (struct inode * inode);
137 void obd_discard_prealloc_blocks (struct inode * inode);
138 int obd_sync_inode (struct inode *inode);
139 struct buffer_head * obd_bread (struct inode * inode, int block,
140 int create, int *err);
141 struct buffer_head * obd_getblk (struct inode * inode, long block,
142 int create, int * err);
145 extern int obd_create (struct super_block * sb, int inode_hint, int * err);
146 extern void obd_unlink (struct inode * inode);
149 struct oic_setattr_s {
159 int obd_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
163 #define ext2_warning obd_warning
164 #define ext2_error obd_warning
165 #define ext2_panic obd_warning
169 # define ext2_debug(format, a...) CDEBUG(D_EXT2, format, ## a)
172 #define obd_error obd_warning
173 #define obd_panic obd_warning
174 #define obd_warning(sb, func, format, a...) CDEBUG(D_WARNING, format, ## a)
176 int obd_remount (struct super_block * sb, int * flags, char * data);
177 struct super_block * ext2_read_super (struct super_block * sb, void * data,
181 extern void obd_sysctl_init (void);
182 extern void obd_sysctl_clean (void);
185 void obd_truncate (struct inode * inode);
189 extern struct inode_operations ext2_dir_inode_operations;
192 extern struct file_operations ext2_file_operations;
193 extern struct inode_operations ext2_file_inode_operations;
195 #endif /* __LINUX_SYM_OBD_H */