Whamcloud - gitweb
- brought lustre-debugging.lyx up to date
[fs/lustre-release.git] / lustre / include / linux / obd_support.h
1 #ifndef _OBD_SUPPORT
2 #define _OBD_SUPPORT
3 /*
4  * Copyright (C) 2001  Cluster File Systems, Inc.
5  *
6  * This code is issued under the GNU General Public License.
7  * See the file COPYING in this distribution
8  */
9
10 #include <linux/autoconf.h>
11 #include <linux/slab.h>
12 #include <linux/kp30.h>
13
14 /* global variables */
15 extern int obd_debug_level;
16 extern unsigned long obd_memory;
17
18 #define OBD_ALLOC(ptr, size)                                    \
19 do {                                                            \
20         long s = (size);                                        \
21         (ptr) = kmalloc(s, GFP_KERNEL);                         \
22         if ((ptr) == NULL) {                                    \
23                 CERROR("kernel malloc of %ld bytes failed at "  \
24                        "%s:%d\n", s, __FILE__, __LINE__);       \
25         } else {                                                \
26                 memset((ptr), 0, s);                            \
27                 obd_memory += s;                                \
28         }                                                       \
29         CDEBUG(D_MALLOC, "kmalloced: %ld at %x (tot %ld).\n",   \
30                s, (int)(ptr), obd_memory);                      \
31 } while (0)
32
33 #define OBD_FREE(ptr, size)                                     \
34 do {                                                            \
35         int s = (size);                                         \
36         kfree((ptr));                                           \
37         CDEBUG(D_MALLOC, "kfreed: %d at %x (tot %ld).\n",       \
38                s, (int)(ptr), obd_memory);                      \
39         obd_memory -= s;                                        \
40 } while (0)
41
42 #endif