Whamcloud - gitweb
A couple days of changes--much improvement.
[fs/lustre-release.git] / lustre / include / linux / sym_obd.h
index 10f2b53..87c86b2 100755 (executable)
@@ -9,22 +9,99 @@
 /*
  * Debug code
  */
 /*
  * Debug code
  */
+/* global variables */
+extern int obd_debug_level;
+extern int obd_print_entry;
+
+/* debugging masks */
+#define D_PSDEV       1 /* debug information from psdev.c */
+#define D_UNUSED1     2
+#define D_UNUSED2     4
+#define D_UNUSED3     8
+#define D_UNUSED4    16
+#define D_UNUSED5    32
+#define D_UNUSED6    64
+#define D_MALLOC    128 /* print malloc, free information */
+#define D_CACHE     256 /* cache-related items */
+#define D_INFO      512 /* general information, especially from interface.c */
+#define D_IOCTL    1024 /* ioctl related information */
+#define D_BLOCKS   2048 /* ext2 block allocation */
 #ifdef SYM_OBD_DEBUG
 #ifdef SYM_OBD_DEBUG
-#      define obd_debug(f, a...)       { \
-                                       printk ("SYM OBD DEBUG (%s, %d): %s:", \
-                                               __FILE__, __LINE__, __FUNCTION__); \
-                                       printk (f, ## a); \
-                                       }
-#else
-#      define obd_debug(f, a...)       /**/
-#endif
+#define CDEBUG(mask, format, a...)                                     \
+        do {                                                           \
+       if (obd_debug_level & mask) {                                   \
+               printk("(%s,l. %d): ",  __FUNCTION__, __LINE__);        \
+               printk(format, ## a); }                                 \
+       } while (0);
+
+#define ENTRY                                                                \
+        if (obd_print_entry)                                                 \
+                printk("Process %d entered %s\n", current->pid, __FUNCTION__)
+
+#define EXIT                                                                 \
+        if (obd_print_entry)                                                 \
+                printk("Process %d leaving %s\n", current->pid, __FUNCTION__)
+
+#else /* SYM_OBD_DEBUG */
+
+#       define CDEBUG(mask, format, a...) ;
+#       define ENTRY ;
+#       define EXIT ;
+
+#endif /* SYM_OBD_DEBUG */
+
+
+
+#define OBD_ALLOC(ptr, cast, size)                                     \
+do {                                                                   \
+       if (size <= 4096) {                                             \
+               ptr = (cast)kmalloc((unsigned long) size, GFP_KERNEL);  \
+                CDEBUG(D_MALLOC, "kmalloced: %x at %x.\n",             \
+                      (int) size, (int) ptr);                          \
+       } else {                                                        \
+               ptr = (cast)vmalloc((unsigned long) size);              \
+               CDEBUG(D_MALLOC, "vmalloced: %x at %x.\n",              \
+                      (int) size, (int) ptr);                          \
+       }                                                               \
+       if (ptr == 0) {                                                 \
+               printk("kernel malloc returns 0 at %s:%d\n",            \
+                      __FILE__, __LINE__);                             \
+       }                                                               \
+       memset(ptr, 0, size);                                           \
+} while (0)
+
+#define OBD_FREE(ptr,size)                             \
+do {                                                   \
+       if (size <= 4096) {                             \
+               kfree_s((ptr), (size));                 \
+               CDEBUG(D_MALLOC, "kfreed: %x at %x.\n", \
+                      (int) size, (int) ptr);          \
+       } else {                                        \
+               vfree((ptr));                           \
+               CDEBUG(D_MALLOC, "vfreed: %x at %x.\n", \
+                      (int) size, (int) ptr);          \
+       }                                               \
+} while (0)
+
 
 /*
  * ioctl commands
  */
 
 /*
  * ioctl commands
  */
+struct ioc_prealloc {
+       long alloc; /* user sets it to the number of inodes requesting to be
+                    * preallocated.  kernel sets it to the actual number of
+                    * succesfully preallocate inodes */
+       long inodes[32]; /* actual inode numbers */
+};
+
 #define OBD_IOC_CREATE                 _IOR('f', 3, long)
 #define OBD_IOC_SETUP                  _IOW('f', 4, long)
 #define OBD_IOC_SYNC                   _IOR('f', 5, long)
 #define OBD_IOC_CREATE                 _IOR('f', 3, long)
 #define OBD_IOC_SETUP                  _IOW('f', 4, long)
 #define OBD_IOC_SYNC                   _IOR('f', 5, long)
+#define OBD_IOC_DESTROY                _IOW('f', 6, long)
+
+#define OBD_IOC_DEC_USE_COUNT          _IO('f', 8)
+
 
 /* balloc.c */
 int obd_new_block (const struct inode * inode, unsigned long goal,
 
 /* balloc.c */
 int obd_new_block (const struct inode * inode, unsigned long goal,
@@ -33,9 +110,23 @@ void obd_free_blocks (const struct inode * inode, unsigned long block,
                       unsigned long count);
 unsigned long obd_count_free_blocks (struct super_block * sb);
 int ext2_group_sparse(int group);
                       unsigned long count);
 unsigned long obd_count_free_blocks (struct super_block * sb);
 int ext2_group_sparse(int group);
+struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb,
+                                            unsigned int block_group,
+                                            struct buffer_head ** bh);
+
+
+/* bitmap.c */
+unsigned long ext2_count_free(struct buffer_head * map, unsigned int numchars);
 
 /* fsync.c */
 
 /* fsync.c */
-int obd_sync_file(struct file * file, struct dentry *dentry);
+extern int obd_sync_file(struct file * file, struct dentry *dentry);
+
+/* ialloc.c */
+extern void ext2_free_inode (struct inode * inode);
+extern struct inode * ext2_new_inode (const struct inode * dir, int mode,
+                                    int * err);
+extern unsigned long ext2_count_free_inodes (struct super_block * sb);
+extern void ext2_check_inodes_bitmap (struct super_block * sb);
 
 /* inode.c */
 void obd_read_inode (struct inode * inode);
 
 /* inode.c */
 void obd_read_inode (struct inode * inode);
@@ -50,11 +141,8 @@ struct buffer_head * obd_getblk (struct inode * inode, long block,
                                  int create, int * err);
 
 /* interface.c */
                                  int create, int * err);
 
 /* interface.c */
-extern struct inode * obd_inode_new (int inode_hint, int * err);
-extern void obd_inode_destroy (struct inode * inode);
-extern unsigned long obd_count_free_inodes (struct super_block * sb);
-extern void obd_check_inodes_bitmap (struct super_block * sb);
-unsigned long obd_count_free_inodes (struct super_block * sb);
+extern int obd_create (struct super_block * sb, int inode_hint, int * err);
+extern void obd_unlink (struct inode * inode);
 
 /* ioctl.c */
 int obd_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
 
 /* ioctl.c */
 int obd_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
@@ -69,6 +157,10 @@ int obd_remount (struct super_block * sb, int * flags, char * data);
 struct super_block * obd_read_super (struct super_block * sb, void * data,
                                     int silent);
 
 struct super_block * obd_read_super (struct super_block * sb, void * data,
                                     int silent);
 
+/* sysctl.c */
+extern void obd_sysctl_init (void);
+extern void obd_sysctl_clean (void);
+
 /* truncate.c */
 void obd_truncate (struct inode * inode);
 
 /* truncate.c */
 void obd_truncate (struct inode * inode);