#ifndef _OBD_SUPPORT
#define _OBD_SUPPORT
-#include <linux/malloc.h>
-#include <linux/vmalloc.h>
-
-#define SIM_OBD_DEBUG
-
/*
- * Debug code
+ * Copyright (C) 2001 Cluster File Systems, Inc.
+ *
+ * This code is issued under the GNU General Public License.
+ * See the file COPYING in this distribution
*/
+
+#include <linux/autoconf.h>
+#include <linux/slab.h>
+#include <linux/kp30.h>
+
/* 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_INODE 2
-#define D_UNUSED2 4
-#define D_UNUSED3 8
-#define D_UNUSED4 16
-#define D_WARNING 32 /* misc warnings */
-#define D_EXT2 64 /* anything from ext2_debug */
-#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 SIM_OBD_DEBUG
-#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 /* SIM_OBD_DEBUG */
-
-# define CDEBUG ;
-# define ENTRY ;
-# define EXIT ;
-
-#endif /* SIM_OBD_DEBUG */
-
-#define PDEBUG(page,cmd) {\
- char *command = ( cmd == READ ) ? "read" : "write";\
- char *uptodate = (Page_Uptodate(page)) ? "yes" : "no";\
- char *locked = (PageLocked(page)) ? "yes" : "no";\
- int count = page->count.counter;\
- long ino = (page->inode) ? page->inode->i_ino : -1;\
- \
- CDEBUG(D_IOCTL, " ** %s, cmd: %s, ino: %ld, uptodate: %s, "\
- "locked: %s, cnt %d ** \n", __FUNCTION__,\
- command, ino, uptodate, locked, count);\
- }
-
-
-#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); \
+extern unsigned long obd_memory;
+
+#define OBD_ALLOC(ptr, size) \
+do { \
+ (ptr) = kmalloc((unsigned long)(size), GFP_KERNEL); \
+ obd_memory += (size); \
+ CDEBUG(D_MALLOC, "kmalloced: %ld at %x (tot %ld).\n", \
+ (long)(size), (int)(ptr), obd_memory); \
+ if (ptr == NULL) { \
+ CERROR("kernel malloc failed at %s:%d\n", \
+ __FILE__, __LINE__); \
+ } else { \
+ 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); \
- } \
+#define OBD_FREE(ptr, size) \
+do { \
+ kfree((ptr)); \
+ obd_memory -= (size); \
+ CDEBUG(D_MALLOC, "kfreed: %d at %x (tot %ld).\n", \
+ (int)(size), (int)(ptr), obd_memory); \
} while (0)
#endif