1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
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
44 # define EXPORT_SYMTAB
47 # include <liblustre.h>
51 #include <obd_support.h>
52 #include <lustre_debug.h>
53 #include <lustre_net.h>
55 void dump_lniobuf(struct niobuf_local *nb)
58 "niobuf_local: offset="LPD64", len=%d, page=%p, rc=%d\n",
59 nb->offset, nb->len, nb->page, nb->rc);
60 CDEBUG(D_RPCTRACE, "nb->page: index = %ld\n",
61 nb->page ? cfs_page_index(nb->page) : -1);
63 EXPORT_SYMBOL(dump_lniobuf);
65 void dump_lsm(int level, struct lov_stripe_md *lsm)
67 CDEBUG(level, "lsm %p, objid "LPX64", maxbytes "LPX64", magic 0x%08X, "
68 "stripe_size %u, stripe_count %u pool "LOV_POOLNAMEF"\n", lsm,
69 lsm->lsm_object_id, lsm->lsm_maxbytes, lsm->lsm_magic,
70 lsm->lsm_stripe_size, lsm->lsm_stripe_count,
74 #define LPDS sizeof(__u64)
75 int block_debug_setup(void *addr, int len, __u64 off, __u64 id)
79 off = cpu_to_le64 (off);
80 id = cpu_to_le64 (id);
81 memcpy(addr, (char *)&off, LPDS);
82 memcpy(addr + LPDS, (char *)&id, LPDS);
84 addr += len - LPDS - LPDS;
85 memcpy(addr, (char *)&off, LPDS);
86 memcpy(addr + LPDS, (char *)&id, LPDS);
91 int block_debug_check(char *who, void *addr, int end, __u64 off, __u64 id)
98 ne_off = le64_to_cpu (off);
99 id = le64_to_cpu (id);
100 if (memcmp(addr, (char *)&ne_off, LPDS)) {
101 CDEBUG(D_ERROR, "%s: id "LPX64" offset "LPU64" off: "LPX64" != "
102 LPX64"\n", who, id, off, *(__u64 *)addr, ne_off);
105 if (memcmp(addr + LPDS, (char *)&id, LPDS)) {
106 CDEBUG(D_ERROR, "%s: id "LPX64" offset "LPU64" id: "LPX64" != "LPX64"\n",
107 who, id, off, *(__u64 *)(addr + LPDS), id);
111 addr += end - LPDS - LPDS;
112 if (memcmp(addr, (char *)&ne_off, LPDS)) {
113 CDEBUG(D_ERROR, "%s: id "LPX64" offset "LPU64" end off: "LPX64" != "
114 LPX64"\n", who, id, off, *(__u64 *)addr, ne_off);
117 if (memcmp(addr + LPDS, (char *)&id, LPDS)) {
118 CDEBUG(D_ERROR, "%s: id "LPX64" offset "LPU64" end id: "LPX64" != "
119 LPX64"\n", who, id, off, *(__u64 *)(addr + LPDS), id);
127 //EXPORT_SYMBOL(dump_req);
128 EXPORT_SYMBOL(dump_lsm);
129 EXPORT_SYMBOL(block_debug_setup);
130 EXPORT_SYMBOL(block_debug_check);