Commit | Line | Data |
---|---|---|
d7e09d03 PT |
1 | /* |
2 | * GPL HEADER START | |
3 | * | |
4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License version 2 only, | |
8 | * as published by the Free Software Foundation. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, but | |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * General Public License version 2 for more details (a copy is included | |
14 | * in the LICENSE file that accompanied this code). | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * version 2 along with this program; If not, see | |
18 | * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf | |
19 | * | |
20 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
21 | * CA 95054 USA or visit www.sun.com if you need additional information or | |
22 | * have any questions. | |
23 | * | |
24 | * GPL HEADER END | |
25 | */ | |
26 | /* | |
27 | * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. | |
28 | * Use is subject to license terms. | |
29 | * | |
30 | * Copyright (c) 2011, 2012, Intel Corporation. | |
31 | */ | |
32 | /* | |
33 | * This file is part of Lustre, http://www.lustre.org/ | |
34 | * Lustre is a trademark of Sun Microsystems, Inc. | |
35 | * | |
36 | * lustre/obdclass/debug.c | |
37 | * | |
38 | * Helper routines for dumping data structs for debugging. | |
39 | */ | |
40 | ||
41 | #define DEBUG_SUBSYSTEM D_OTHER | |
42 | ||
43 | ||
610f7377 GKH |
44 | #include "../include/obd_ost.h" |
45 | #include "../include/obd_support.h" | |
46 | #include "../include/lustre_debug.h" | |
47 | #include "../include/lustre_net.h" | |
d7e09d03 PT |
48 | |
49 | void dump_lniobuf(struct niobuf_local *nb) | |
50 | { | |
51 | CDEBUG(D_RPCTRACE, | |
f537dd2c | 52 | "niobuf_local: file_offset=%lld, len=%d, page=%p, rc=%d\n", |
d7e09d03 PT |
53 | nb->lnb_file_offset, nb->len, nb->page, nb->rc); |
54 | CDEBUG(D_RPCTRACE, "nb->page: index = %ld\n", | |
55 | nb->page ? page_index(nb->page) : -1); | |
56 | } | |
57 | EXPORT_SYMBOL(dump_lniobuf); | |
58 | ||
d7e09d03 PT |
59 | #define LPDS sizeof(__u64) |
60 | int block_debug_setup(void *addr, int len, __u64 off, __u64 id) | |
61 | { | |
62 | LASSERT(addr); | |
63 | ||
64 | off = cpu_to_le64 (off); | |
65 | id = cpu_to_le64 (id); | |
66 | memcpy(addr, (char *)&off, LPDS); | |
67 | memcpy(addr + LPDS, (char *)&id, LPDS); | |
68 | ||
69 | addr += len - LPDS - LPDS; | |
70 | memcpy(addr, (char *)&off, LPDS); | |
71 | memcpy(addr + LPDS, (char *)&id, LPDS); | |
72 | ||
73 | return 0; | |
74 | } | |
75 | EXPORT_SYMBOL(block_debug_setup); | |
76 | ||
77 | int block_debug_check(char *who, void *addr, int end, __u64 off, __u64 id) | |
78 | { | |
79 | __u64 ne_off; | |
80 | int err = 0; | |
81 | ||
82 | LASSERT(addr); | |
83 | ||
84 | ne_off = le64_to_cpu (off); | |
85 | id = le64_to_cpu (id); | |
86 | if (memcmp(addr, (char *)&ne_off, LPDS)) { | |
55f5a824 GKH |
87 | CDEBUG(D_ERROR, "%s: id %#llx offset %llu off: %#llx != %#llx\n", |
88 | who, id, off, *(__u64 *)addr, ne_off); | |
d7e09d03 PT |
89 | err = -EINVAL; |
90 | } | |
91 | if (memcmp(addr + LPDS, (char *)&id, LPDS)) { | |
55f5a824 | 92 | CDEBUG(D_ERROR, "%s: id %#llx offset %llu id: %#llx != %#llx\n", |
d7e09d03 PT |
93 | who, id, off, *(__u64 *)(addr + LPDS), id); |
94 | err = -EINVAL; | |
95 | } | |
96 | ||
97 | addr += end - LPDS - LPDS; | |
98 | if (memcmp(addr, (char *)&ne_off, LPDS)) { | |
55f5a824 GKH |
99 | CDEBUG(D_ERROR, "%s: id %#llx offset %llu end off: %#llx != %#llx\n", |
100 | who, id, off, *(__u64 *)addr, ne_off); | |
d7e09d03 PT |
101 | err = -EINVAL; |
102 | } | |
103 | if (memcmp(addr + LPDS, (char *)&id, LPDS)) { | |
55f5a824 GKH |
104 | CDEBUG(D_ERROR, "%s: id %#llx offset %llu end id: %#llx != %#llx\n", |
105 | who, id, off, *(__u64 *)(addr + LPDS), id); | |
d7e09d03 PT |
106 | err = -EINVAL; |
107 | } | |
108 | ||
109 | return err; | |
110 | } | |
111 | EXPORT_SYMBOL(block_debug_check); | |
112 | #undef LPDS |