Whamcloud - gitweb
- add open and close calls: initial purpose is to support I/O to open,
[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 int obd_print_entry;
17 extern unsigned long obd_memory;
18
19 #define OBD_ALLOC(ptr, size)                                    \
20 do {                                                            \
21         (ptr) = kmalloc((unsigned long)(size), GFP_KERNEL);     \
22         if ((ptr) == NULL) {                                    \
23                 CERROR("kernel malloc failed at %s:%d\n",       \
24                        __FILE__, __LINE__);                     \
25         } else {                                                \
26                 memset((ptr), 0, (size));                       \
27                 obd_memory += (size);                           \
28         }                                                       \
29         CDEBUG(D_MALLOC, "kmalloced: %ld at %x (tot %ld).\n",   \
30                (long)(size), (int)(ptr), obd_memory);           \
31 } while (0)
32
33 #define OBD_FREE(ptr, size)                                  \
34 do {                                                         \
35         kfree((ptr));                                        \
36         CDEBUG(D_MALLOC, "kfreed: %d at %x (tot %ld).\n",    \
37                (int)(size), (int)(ptr), obd_memory);         \
38         obd_memory -= (size);                                \
39 } while (0)
40
41 #endif