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 int dump_ioo(struct obd_ioobj *ioo)
57 CERROR("obd_ioobj: ioo_id="LPD64", ioo_gr="LPD64", ioo_type=%d, "
59 ioo->ioo_id, ioo->ioo_gr, ioo->ioo_type, ioo->ioo_bufcnt);
63 int dump_lniobuf(struct niobuf_local *nb)
65 CERROR("niobuf_local: offset="LPD64", len=%d, page=%p, rc=%d\n",
66 nb->offset, nb->len, nb->page, nb->rc);
67 CERROR("nb->page: index = %ld\n", nb->page ? cfs_page_index(nb->page) : -1);
72 int dump_rniobuf(struct niobuf_remote *nb)
74 CERROR("niobuf_remote: offset="LPU64", len=%d, flags=%x\n",
75 nb->offset, nb->len, nb->flags);
80 int dump_obdo(struct obdo *oa)
82 __u32 valid = oa->o_valid;
84 CERROR("obdo: o_valid = %08x\n", valid);
85 if (valid & OBD_MD_FLID)
86 CERROR("obdo: o_id = "LPD64"\n", oa->o_id);
87 if (valid & OBD_MD_FLATIME)
88 CERROR("obdo: o_atime = "LPD64"\n", oa->o_atime);
89 if (valid & OBD_MD_FLMTIME)
90 CERROR("obdo: o_mtime = "LPD64"\n", oa->o_mtime);
91 if (valid & OBD_MD_FLCTIME)
92 CERROR("obdo: o_ctime = "LPD64"\n", oa->o_ctime);
93 if (valid & OBD_MD_FLSIZE)
94 CERROR("obdo: o_size = "LPD64"\n", oa->o_size);
95 if (valid & OBD_MD_FLBLOCKS) /* allocation of space */
96 CERROR("obdo: o_blocks = "LPD64"\n", oa->o_blocks);
97 if (valid & OBD_MD_FLBLKSZ)
98 CERROR("obdo: o_blksize = %d\n", oa->o_blksize);
99 if (valid & (OBD_MD_FLTYPE | OBD_MD_FLMODE))
100 CERROR("obdo: o_mode = %o\n",
101 oa->o_mode & ((valid & OBD_MD_FLTYPE ? S_IFMT : 0) |
102 (valid & OBD_MD_FLMODE ? ~S_IFMT : 0)));
103 if (valid & OBD_MD_FLUID)
104 CERROR("obdo: o_uid = %u\n", oa->o_uid);
105 if (valid & OBD_MD_FLGID)
106 CERROR("obdo: o_gid = %u\n", oa->o_gid);
107 if (valid & OBD_MD_FLFLAGS)
108 CERROR("obdo: o_flags = %x\n", oa->o_flags);
109 if (valid & OBD_MD_FLNLINK)
110 CERROR("obdo: o_nlink = %u\n", oa->o_nlink);
111 if (valid & OBD_MD_FLGENER)
112 CERROR("obdo: o_generation = %u\n", oa->o_generation);
117 void dump_lsm(int level, struct lov_stripe_md *lsm)
119 CDEBUG(level, "lsm %p, objid "LPX64", maxbytes "LPX64", magic 0x%08X, "
120 "stripe_size %u, stripe_count %u pool "LOV_POOLNAMEF"\n", lsm,
121 lsm->lsm_object_id, lsm->lsm_maxbytes, lsm->lsm_magic,
122 lsm->lsm_stripe_size, lsm->lsm_stripe_count,
126 /* XXX assumes only a single page in request */
128 int dump_req(struct ptlrpc_request *req)
130 struct ost_body *body = lustre_msg_buf(req->rq_reqmsg, 0);
131 struct obd_ioobj *ioo = lustre_msg_buf(req->rq_reqmsg, 1);
132 //struct niobuf *nb = lustre_msg_buf(req->rq_reqmsg, 2);
134 dump_obdo(&body->oa);
142 #define LPDS sizeof(__u64)
143 int block_debug_setup(void *addr, int len, __u64 off, __u64 id)
147 off = cpu_to_le64 (off);
148 id = cpu_to_le64 (id);
149 memcpy(addr, (char *)&off, LPDS);
150 memcpy(addr + LPDS, (char *)&id, LPDS);
152 addr += len - LPDS - LPDS;
153 memcpy(addr, (char *)&off, LPDS);
154 memcpy(addr + LPDS, (char *)&id, LPDS);
159 int block_debug_check(char *who, void *addr, int end, __u64 off, __u64 id)
166 ne_off = le64_to_cpu (off);
167 id = le64_to_cpu (id);
168 if (memcmp(addr, (char *)&ne_off, LPDS)) {
169 CDEBUG(D_ERROR, "%s: id "LPX64" offset "LPU64" off: "LPX64" != "
170 LPX64"\n", who, id, off, *(__u64 *)addr, ne_off);
173 if (memcmp(addr + LPDS, (char *)&id, LPDS)) {
174 CDEBUG(D_ERROR, "%s: id "LPX64" offset "LPU64" id: "LPX64" != "LPX64"\n",
175 who, id, off, *(__u64 *)(addr + LPDS), id);
179 addr += end - LPDS - LPDS;
180 if (memcmp(addr, (char *)&ne_off, LPDS)) {
181 CDEBUG(D_ERROR, "%s: id "LPX64" offset "LPU64" end off: "LPX64" != "
182 LPX64"\n", who, id, off, *(__u64 *)addr, ne_off);
185 if (memcmp(addr + LPDS, (char *)&id, LPDS)) {
186 CDEBUG(D_ERROR, "%s: id "LPX64" offset "LPU64" end id: "LPX64" != "
187 LPX64"\n", who, id, off, *(__u64 *)(addr + LPDS), id);
195 EXPORT_SYMBOL(dump_lniobuf);
196 EXPORT_SYMBOL(dump_rniobuf);
197 EXPORT_SYMBOL(dump_ioo);
198 //EXPORT_SYMBOL(dump_req);
199 EXPORT_SYMBOL(dump_obdo);
200 EXPORT_SYMBOL(dump_lsm);
201 EXPORT_SYMBOL(block_debug_setup);
202 EXPORT_SYMBOL(block_debug_check);