Whamcloud - gitweb
* landing 11667 (debug_peer_on_timeout) and 11684 (liblustre block for asynch
[fs/lustre-release.git] / lustre / include / lustre_debug.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2002 Cluster File Systems, Inc.
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  */
22
23 #ifndef _LUSTRE_DEBUG_H
24 #define _LUSTRE_DEBUG_H
25
26 #include <lustre_net.h>
27
28 #if defined(__linux__)
29 #include <linux/lustre_debug.h>
30 #elif defined(__APPLE__)
31 #include <darwin/lustre_debug.h>
32 #elif defined(__WINNT__)
33 #include <winnt/lustre_debug.h>
34 #else
35 #error Unsupported operating system.
36 #endif
37
38 #define ASSERT_MAX_SIZE_MB 60000ULL
39 #define ASSERT_PAGE_INDEX(index, OP)                                    \
40 do { if (index > ASSERT_MAX_SIZE_MB << (20 - CFS_PAGE_SHIFT)) {         \
41         CERROR("bad page index %lu > %Lu\n", index,                     \
42                ASSERT_MAX_SIZE_MB << (20 - CFS_PAGE_SHIFT));            \
43         libcfs_debug = ~0UL;                                            \
44         OP;                                                             \
45 }} while(0)
46
47 #define ASSERT_FILE_OFFSET(offset, OP)                                  \
48 do { if (offset > ASSERT_MAX_SIZE_MB << 20) {                           \
49         CERROR("bad file offset %Lu > %Lu\n", offset,                   \
50                ASSERT_MAX_SIZE_MB << 20);                               \
51         libcfs_debug = ~0UL;                                            \
52         OP;                                                             \
53 }} while(0)
54
55 /* lib/debug.c */
56 int dump_lniobuf(struct niobuf_local *lnb);
57 int dump_rniobuf(struct niobuf_remote *rnb);
58 int dump_ioo(struct obd_ioobj *nb);
59 int dump_req(struct ptlrpc_request *req);
60 int dump_obdo(struct obdo *oa);
61 void dump_lsm(int level, struct lov_stripe_md *lsm);
62 int block_debug_setup(void *addr, int len, __u64 off, __u64 id);
63 int block_debug_check(char *who, void *addr, int len, __u64 off, __u64 id);
64 #endif