1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Helper routines for dumping data structs for debugging.
6 * This code is issued under the GNU General Public License.
7 * See the file COPYING in this distribution
9 * Copryright (C) 2002 Cluster File Systems, Inc.
13 #define DEBUG_SUBSYSTEM D_OTHER
16 #include <linux/obd_ost.h>
17 #include <linux/lustre_debug.h>
18 #include <linux/lustre_net.h>
20 int dump_ioo(struct obd_ioobj *ioo)
22 CERROR("obd_ioobj: ioo_id=%Ld, ioo_gr=%Ld, ioo_type=%d, ioo_bufct=%d\n",
23 ioo->ioo_id, ioo->ioo_gr, ioo->ioo_type, ioo->ioo_bufcnt);
27 int dump_lniobuf(struct niobuf_local *nb)
29 CERROR("niobuf_local: addr=%p, offset=%Ld, len=%d, xid=%d, page=%p\n",
30 nb->addr, nb->offset, nb->len, nb->xid, nb->page);
31 CERROR("nb->page: index = %ld\n", nb->page ? nb->page->index : -1);
36 int dump_rniobuf(struct niobuf_remote *nb)
38 CERROR("niobuf_remote: offset=%Ld, len=%d, flags=%x, xid=%d\n",
39 nb->offset, nb->len, nb->flags, nb->xid);
44 int dump_obdo(struct obdo *oa)
46 CERROR("obdo: o_valid = %08x\n", oa->o_valid);
47 if (oa->o_valid & OBD_MD_FLID)
48 CERROR("obdo: o_id = %Ld\n", oa->o_id);
49 if (oa->o_valid & OBD_MD_FLATIME)
50 CERROR("obdo: o_atime = %Ld\n", oa->o_atime);
51 if (oa->o_valid & OBD_MD_FLMTIME)
52 CERROR("obdo: o_mtime = %Ld\n", oa->o_mtime);
53 if (oa->o_valid & OBD_MD_FLCTIME)
54 CERROR("obdo: o_ctime = %Ld\n", oa->o_ctime);
55 if (oa->o_valid & OBD_MD_FLSIZE)
56 CERROR("obdo: o_size = %Ld\n", oa->o_size);
57 if (oa->o_valid & OBD_MD_FLBLOCKS) /* allocation of space */
58 CERROR("obdo: o_blocks = %Ld\n", oa->o_blocks);
59 if (oa->o_valid & OBD_MD_FLBLKSZ)
60 CERROR("obdo: o_blksize = %d\n", oa->o_blksize);
61 if (oa->o_valid & OBD_MD_FLMODE)
62 CERROR("obdo: o_mode = %o\n", oa->o_mode);
63 if (oa->o_valid & OBD_MD_FLUID)
64 CERROR("obdo: o_uid = %d\n", oa->o_uid);
65 if (oa->o_valid & OBD_MD_FLGID)
66 CERROR("obdo: o_gid = %d\n", oa->o_gid);
67 if (oa->o_valid & OBD_MD_FLFLAGS)
68 CERROR("obdo: o_flags = %x\n", oa->o_flags);
69 if (oa->o_valid & OBD_MD_FLNLINK)
70 CERROR("obdo: o_nlink = %d\n", oa->o_nlink);
71 if (oa->o_valid & OBD_MD_FLGENER)
72 CERROR("obdo: o_generation = %d\n", oa->o_generation);
77 /* XXX assumes only a single page in request */
79 int dump_req(struct ptlrpc_request *req)
81 struct ost_body *body = lustre_msg_buf(req->rq_reqmsg, 0);
82 struct obd_ioobj *ioo = lustre_msg_buf(req->rq_reqmsg, 1);
83 //struct niobuf *nb = lustre_msg_buf(req->rq_reqmsg, 2);
93 #define LPDS sizeof(__u64)
94 int page_debug_setup(void *addr, int len, __u64 off, __u64 id)
100 memcpy(addr, (char *)&off, LPDS);
101 memcpy(addr + LPDS, (char *)&id, LPDS);
103 addr += len - LPDS - LPDS;
104 memcpy(addr, (char *)&off, LPDS);
105 memcpy(addr + LPDS, (char *)&id, LPDS);
110 int page_debug_check(char *who, void *addr, int end, __u64 off, __u64 id)
117 ne_off = HTON__u64(off);
119 if (memcmp(addr, (char *)&ne_off, LPDS)) {
120 CERROR("%s: offset "LPU64" off: "LPX64" != "LPX64"\n",
121 who, off, *(__u64 *)addr, ne_off);
124 if (memcmp(addr + LPDS, (char *)&id, LPDS)) {
125 CERROR("%s: offset "LPU64" id: "LPX64" != "LPX64"\n",
126 who, off, *(__u64 *)(addr + LPDS), id);
130 addr += end - LPDS - LPDS;
131 if (memcmp(addr, (char *)&ne_off, LPDS)) {
132 CERROR("%s: offset "LPU64" end off: "LPX64" != "LPX64"\n",
133 who, off, *(__u64 *)addr, ne_off);
136 if (memcmp(addr + LPDS, (char *)&id, LPDS)) {
137 CERROR("%s: offset "LPU64" end id: "LPX64" != "LPX64"\n",
138 who, off, *(__u64 *)(addr + LPDS), id);
146 EXPORT_SYMBOL(dump_lniobuf);
147 EXPORT_SYMBOL(dump_rniobuf);
148 EXPORT_SYMBOL(dump_ioo);
149 //EXPORT_SYMBOL(dump_req);
150 EXPORT_SYMBOL(dump_obdo);
151 EXPORT_SYMBOL(page_debug_setup);
152 EXPORT_SYMBOL(page_debug_check);