4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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
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
27 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2011, 2012, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lustre/obdclass/debug.c
38 * Helper routines for dumping data structs for debugging.
41 #define DEBUG_SUBSYSTEM D_OTHER
43 #include <asm/unaligned.h>
45 #include "../include/obd_support.h"
46 #include "../include/lustre_debug.h"
47 #include "../include/lustre_net.h"
49 #define LPDS sizeof(__u64)
50 int block_debug_setup(void *addr, int len, __u64 off, __u64 id)
54 put_unaligned_le64(off, addr);
55 put_unaligned_le64(id, addr+LPDS);
56 addr += len - LPDS - LPDS;
57 put_unaligned_le64(off, addr);
58 put_unaligned_le64(id, addr+LPDS);
62 EXPORT_SYMBOL(block_debug_setup);
64 int block_debug_check(char *who, void *addr, int end, __u64 off, __u64 id)
71 ne_off = le64_to_cpu (off);
72 id = le64_to_cpu (id);
73 if (memcmp(addr, (char *)&ne_off, LPDS)) {
74 CDEBUG(D_ERROR, "%s: id %#llx offset %llu off: %#llx != %#llx\n",
75 who, id, off, *(__u64 *)addr, ne_off);
78 if (memcmp(addr + LPDS, (char *)&id, LPDS)) {
79 CDEBUG(D_ERROR, "%s: id %#llx offset %llu id: %#llx != %#llx\n",
80 who, id, off, *(__u64 *)(addr + LPDS), id);
84 addr += end - LPDS - LPDS;
85 if (memcmp(addr, (char *)&ne_off, LPDS)) {
86 CDEBUG(D_ERROR, "%s: id %#llx offset %llu end off: %#llx != %#llx\n",
87 who, id, off, *(__u64 *)addr, ne_off);
90 if (memcmp(addr + LPDS, (char *)&id, LPDS)) {
91 CDEBUG(D_ERROR, "%s: id %#llx offset %llu end id: %#llx != %#llx\n",
92 who, id, off, *(__u64 *)(addr + LPDS), id);
98 EXPORT_SYMBOL(block_debug_check);