1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2002 Cluster File Systems, Inc.
6 * This file is part of the Lustre file system, http://www.lustre.org
7 * Lustre is a trademark of Cluster File Systems, Inc.
9 * You may have signed or agreed to another license before downloading
10 * this software. If so, you are bound by the terms and conditions
11 * of that agreement, and the following does not apply to you. See the
12 * LICENSE file included with this distribution for more information.
14 * If you did not agree to a different license, then this copy of Lustre
15 * is open source software; you can redistribute it and/or modify it
16 * under the terms of version 2 of the GNU General Public License as
17 * published by the Free Software Foundation.
19 * In either case, Lustre is distributed in the hope that it will be
20 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
21 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * license text for more details.
24 * Helper routines for dumping data structs for debugging.
27 #define DEBUG_SUBSYSTEM D_OTHER
30 # define EXPORT_SYMTAB
33 # include <liblustre.h>
37 #include <obd_support.h>
38 #include <lustre_debug.h>
39 #include <lustre_net.h>
41 int dump_ioo(struct obd_ioobj *ioo)
43 CERROR("obd_ioobj: ioo_id="LPD64", ioo_gr="LPD64", ioo_type=%d, "
45 ioo->ioo_id, ioo->ioo_gr, ioo->ioo_type, ioo->ioo_bufcnt);
49 int dump_lniobuf(struct niobuf_local *nb)
51 CERROR("niobuf_local: offset="LPD64", len=%d, page=%p, rc=%d\n",
52 nb->offset, nb->len, nb->page, nb->rc);
53 CERROR("nb->page: index = %ld\n", nb->page ? cfs_page_index(nb->page) : -1);
58 int dump_rniobuf(struct niobuf_remote *nb)
60 CERROR("niobuf_remote: offset="LPU64", len=%d, flags=%x\n",
61 nb->offset, nb->len, nb->flags);
66 int dump_obdo(struct obdo *oa)
68 __u32 valid = oa->o_valid;
70 CERROR("obdo: o_valid = %08x\n", valid);
71 if (valid & OBD_MD_FLID)
72 CERROR("obdo: o_id = "LPD64"\n", oa->o_id);
73 if (valid & OBD_MD_FLATIME)
74 CERROR("obdo: o_atime = "LPD64"\n", oa->o_atime);
75 if (valid & OBD_MD_FLMTIME)
76 CERROR("obdo: o_mtime = "LPD64"\n", oa->o_mtime);
77 if (valid & OBD_MD_FLCTIME)
78 CERROR("obdo: o_ctime = "LPD64"\n", oa->o_ctime);
79 if (valid & OBD_MD_FLSIZE)
80 CERROR("obdo: o_size = "LPD64"\n", oa->o_size);
81 if (valid & OBD_MD_FLBLOCKS) /* allocation of space */
82 CERROR("obdo: o_blocks = "LPD64"\n", oa->o_blocks);
83 if (valid & OBD_MD_FLBLKSZ)
84 CERROR("obdo: o_blksize = %d\n", oa->o_blksize);
85 if (valid & (OBD_MD_FLTYPE | OBD_MD_FLMODE))
86 CERROR("obdo: o_mode = %o\n",
87 oa->o_mode & ((valid & OBD_MD_FLTYPE ? S_IFMT : 0) |
88 (valid & OBD_MD_FLMODE ? ~S_IFMT : 0)));
89 if (valid & OBD_MD_FLUID)
90 CERROR("obdo: o_uid = %u\n", oa->o_uid);
91 if (valid & OBD_MD_FLGID)
92 CERROR("obdo: o_gid = %u\n", oa->o_gid);
93 if (valid & OBD_MD_FLFLAGS)
94 CERROR("obdo: o_flags = %x\n", oa->o_flags);
95 if (valid & OBD_MD_FLNLINK)
96 CERROR("obdo: o_nlink = %u\n", oa->o_nlink);
97 if (valid & OBD_MD_FLGENER)
98 CERROR("obdo: o_generation = %u\n", oa->o_generation);
103 void dump_lsm(int level, struct lov_stripe_md *lsm)
105 CDEBUG(level, "lsm %p, objid "LPX64", maxbytes "LPX64", magic 0x%08X, "
106 "stripe_size %u, stripe_count %u\n", lsm,
107 lsm->lsm_object_id, lsm->lsm_maxbytes, lsm->lsm_magic,
108 lsm->lsm_stripe_size, lsm->lsm_stripe_count);
111 /* XXX assumes only a single page in request */
113 int dump_req(struct ptlrpc_request *req)
115 struct ost_body *body = lustre_msg_buf(req->rq_reqmsg, 0);
116 struct obd_ioobj *ioo = lustre_msg_buf(req->rq_reqmsg, 1);
117 //struct niobuf *nb = lustre_msg_buf(req->rq_reqmsg, 2);
119 dump_obdo(&body->oa);
127 #define LPDS sizeof(__u64)
128 int block_debug_setup(void *addr, int len, __u64 off, __u64 id)
132 off = cpu_to_le64 (off);
133 id = cpu_to_le64 (id);
134 memcpy(addr, (char *)&off, LPDS);
135 memcpy(addr + LPDS, (char *)&id, LPDS);
137 addr += len - LPDS - LPDS;
138 memcpy(addr, (char *)&off, LPDS);
139 memcpy(addr + LPDS, (char *)&id, LPDS);
144 int block_debug_check(char *who, void *addr, int end, __u64 off, __u64 id)
151 ne_off = le64_to_cpu (off);
152 id = le64_to_cpu (id);
153 if (memcmp(addr, (char *)&ne_off, LPDS)) {
154 CDEBUG(D_ERROR, "%s: id "LPX64" offset "LPU64" off: "LPX64" != "
155 LPX64"\n", who, id, off, *(__u64 *)addr, ne_off);
158 if (memcmp(addr + LPDS, (char *)&id, LPDS)) {
159 CDEBUG(D_ERROR, "%s: id "LPX64" offset "LPU64" id: "LPX64" != "LPX64"\n",
160 who, id, off, *(__u64 *)(addr + LPDS), id);
164 addr += end - LPDS - LPDS;
165 if (memcmp(addr, (char *)&ne_off, LPDS)) {
166 CDEBUG(D_ERROR, "%s: id "LPX64" offset "LPU64" end off: "LPX64" != "
167 LPX64"\n", who, id, off, *(__u64 *)addr, ne_off);
170 if (memcmp(addr + LPDS, (char *)&id, LPDS)) {
171 CDEBUG(D_ERROR, "%s: id "LPX64" offset "LPU64" end id: "LPX64" != "
172 LPX64"\n", who, id, off, *(__u64 *)(addr + LPDS), id);
180 EXPORT_SYMBOL(dump_lniobuf);
181 EXPORT_SYMBOL(dump_rniobuf);
182 EXPORT_SYMBOL(dump_ioo);
183 //EXPORT_SYMBOL(dump_req);
184 EXPORT_SYMBOL(dump_obdo);
185 EXPORT_SYMBOL(dump_lsm);
186 EXPORT_SYMBOL(block_debug_setup);
187 EXPORT_SYMBOL(block_debug_check);