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 (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
30 * Use is subject to license terms.
32 * Copyright (c) 2012, Whamcloud, Inc.
35 * This file is part of Lustre, http://www.lustre.org/
36 * Lustre is a trademark of Sun Microsystems, Inc.
38 * lustre/obdclass/debug.c
40 * Helper routines for dumping data structs for debugging.
43 #define DEBUG_SUBSYSTEM D_OTHER
46 # define EXPORT_SYMTAB
49 # include <liblustre.h>
53 #include <obd_support.h>
54 #include <lustre_debug.h>
55 #include <lustre_net.h>
57 void dump_lniobuf(struct niobuf_local *nb)
60 "niobuf_local: offset="LPD64", len=%d, page=%p, rc=%d\n",
61 nb->offset, nb->len, nb->page, nb->rc);
62 CDEBUG(D_RPCTRACE, "nb->page: index = %ld\n",
63 nb->page ? cfs_page_index(nb->page) : -1);
65 EXPORT_SYMBOL(dump_lniobuf);
67 void dump_lsm(int level, struct lov_stripe_md *lsm)
69 CDEBUG(level, "lsm %p, objid "LPX64", maxbytes "LPX64", magic 0x%08X, "
70 "stripe_size %u, stripe_count %u, "
71 "layout_gen %u, pool ["LOV_POOLNAMEF"]\n", lsm,
72 lsm->lsm_object_id, lsm->lsm_maxbytes, lsm->lsm_magic,
73 lsm->lsm_stripe_size, lsm->lsm_stripe_count,
74 lsm->lsm_layout_gen, lsm->lsm_pool_name);
77 #define LPDS sizeof(__u64)
78 int block_debug_setup(void *addr, int len, __u64 off, __u64 id)
82 off = cpu_to_le64 (off);
83 id = cpu_to_le64 (id);
84 memcpy(addr, (char *)&off, LPDS);
85 memcpy(addr + LPDS, (char *)&id, LPDS);
87 addr += len - LPDS - LPDS;
88 memcpy(addr, (char *)&off, LPDS);
89 memcpy(addr + LPDS, (char *)&id, LPDS);
94 int block_debug_check(char *who, void *addr, int end, __u64 off, __u64 id)
101 ne_off = le64_to_cpu (off);
102 id = le64_to_cpu (id);
103 if (memcmp(addr, (char *)&ne_off, LPDS)) {
104 CDEBUG(D_ERROR, "%s: id "LPX64" offset "LPU64" off: "LPX64" != "
105 LPX64"\n", who, id, off, *(__u64 *)addr, ne_off);
108 if (memcmp(addr + LPDS, (char *)&id, LPDS)) {
109 CDEBUG(D_ERROR, "%s: id "LPX64" offset "LPU64" id: "LPX64" != "LPX64"\n",
110 who, id, off, *(__u64 *)(addr + LPDS), id);
114 addr += end - LPDS - LPDS;
115 if (memcmp(addr, (char *)&ne_off, LPDS)) {
116 CDEBUG(D_ERROR, "%s: id "LPX64" offset "LPU64" end off: "LPX64" != "
117 LPX64"\n", who, id, off, *(__u64 *)addr, ne_off);
120 if (memcmp(addr + LPDS, (char *)&id, LPDS)) {
121 CDEBUG(D_ERROR, "%s: id "LPX64" offset "LPU64" end id: "LPX64" != "
122 LPX64"\n", who, id, off, *(__u64 *)(addr + LPDS), id);
130 //EXPORT_SYMBOL(dump_req);
131 EXPORT_SYMBOL(dump_lsm);
132 EXPORT_SYMBOL(block_debug_setup);
133 EXPORT_SYMBOL(block_debug_check);