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 Lustre, http://www.lustre.org.
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * Helper routines for dumping data structs for debugging.
24 #define DEBUG_SUBSYSTEM D_OTHER
27 # define EXPORT_SYMTAB
30 # include <liblustre.h>
33 #include <linux/obd_ost.h>
34 #include <linux/obd_support.h>
35 #include <linux/lustre_debug.h>
36 #include <linux/lustre_net.h>
38 int dump_ioo(struct obd_ioobj *ioo)
40 CERROR("obd_ioobj: ioo_id="LPD64", ioo_gr="LPD64", ioo_type=%d, "
42 ioo->ioo_id, ioo->ioo_gr, ioo->ioo_type, ioo->ioo_bufcnt);
46 int dump_lniobuf(struct niobuf_local *nb)
48 CERROR("niobuf_local: offset="LPD64", len=%d, page=%p, rc=%d\n",
49 nb->offset, nb->len, nb->page, nb->rc);
50 CERROR("nb->page: index = %ld\n", nb->page ? nb->page->index : -1);
55 int dump_rniobuf(struct niobuf_remote *nb)
57 CERROR("niobuf_remote: offset="LPU64", len=%d, flags=%x\n",
58 nb->offset, nb->len, nb->flags);
63 int dump_obdo(struct obdo *oa)
65 __u64 valid = oa->o_valid;
67 CERROR("obdo: o_valid = "LPX64"\n", valid);
68 if (valid & OBD_MD_FLID)
69 CERROR("obdo: o_id = "LPD64"\n", oa->o_id);
70 if (valid & OBD_MD_FLATIME)
71 CERROR("obdo: o_atime = "LPD64"\n", oa->o_atime);
72 if (valid & OBD_MD_FLMTIME)
73 CERROR("obdo: o_mtime = "LPD64"\n", oa->o_mtime);
74 if (valid & OBD_MD_FLCTIME)
75 CERROR("obdo: o_ctime = "LPD64"\n", oa->o_ctime);
76 if (valid & OBD_MD_FLSIZE)
77 CERROR("obdo: o_size = "LPD64"\n", oa->o_size);
78 if (valid & OBD_MD_FLBLOCKS) /* allocation of space */
79 CERROR("obdo: o_blocks = "LPD64"\n", oa->o_blocks);
80 if (valid & OBD_MD_FLBLKSZ)
81 CERROR("obdo: o_blksize = %d\n", oa->o_blksize);
82 if (valid & (OBD_MD_FLTYPE | OBD_MD_FLMODE))
83 CERROR("obdo: o_mode = %o\n",
84 oa->o_mode & ((valid & OBD_MD_FLTYPE ? S_IFMT : 0) |
85 (valid & OBD_MD_FLMODE ? ~S_IFMT : 0)));
86 if (valid & OBD_MD_FLUID)
87 CERROR("obdo: o_uid = %u\n", oa->o_uid);
88 if (valid & OBD_MD_FLGID)
89 CERROR("obdo: o_gid = %u\n", oa->o_gid);
90 if (valid & OBD_MD_FLFLAGS)
91 CERROR("obdo: o_flags = 0x%x\n", oa->o_flags);
92 if (valid & OBD_MD_FLNLINK)
93 CERROR("obdo: o_nlink = %u\n", oa->o_nlink);
94 if (valid & OBD_MD_FLGENER)
95 CERROR("obdo: o_generation = %u\n", oa->o_generation);
100 /* XXX assumes only a single page in request */
102 int dump_req(struct ptlrpc_request *req)
104 struct ost_body *body = lustre_msg_buf(req->rq_reqmsg, 0);
105 struct obd_ioobj *ioo = lustre_msg_buf(req->rq_reqmsg, 1);
106 //struct niobuf *nb = lustre_msg_buf(req->rq_reqmsg, 2);
108 dump_obdo(&body->oa);
116 #define LPDS sizeof(__u64)
117 int block_debug_setup(void *addr, int len, __u64 off, __u64 id)
121 off = cpu_to_le64 (off);
122 id = cpu_to_le64 (id);
123 memcpy(addr, (char *)&off, LPDS);
124 memcpy(addr + LPDS, (char *)&id, LPDS);
126 addr += len - LPDS - LPDS;
127 memcpy(addr, (char *)&off, LPDS);
128 memcpy(addr + LPDS, (char *)&id, LPDS);
133 int block_debug_check(char *who, void *addr, int end, __u64 off, __u64 id)
140 ne_off = le64_to_cpu (off);
141 id = le64_to_cpu (id);
142 if (memcmp(addr, (char *)&ne_off, LPDS)) {
143 CERROR("%s: id "LPX64" offset "LPU64" off: "LPX64" != "
144 LPX64"\n", who, id, off, *(__u64 *)addr, ne_off);
147 if (memcmp(addr + LPDS, (char *)&id, LPDS)) {
148 CERROR("%s: id "LPX64" offset "LPU64" id: "LPX64" != "LPX64"\n",
149 who, id, off, *(__u64 *)(addr + LPDS), id);
153 addr += end - LPDS - LPDS;
154 if (memcmp(addr, (char *)&ne_off, LPDS)) {
155 CERROR("%s: id "LPX64" offset "LPU64" end off: "LPX64" != "
156 LPX64"\n", who, id, off, *(__u64 *)addr, ne_off);
159 if (memcmp(addr + LPDS, (char *)&id, LPDS)) {
160 CERROR("%s: id "LPX64" offset "LPU64" end id: "LPX64" != "
161 LPX64"\n", who, id, off, *(__u64 *)(addr + LPDS), id);
169 EXPORT_SYMBOL(dump_lniobuf);
170 EXPORT_SYMBOL(dump_rniobuf);
171 EXPORT_SYMBOL(dump_ioo);
172 //EXPORT_SYMBOL(dump_req);
173 EXPORT_SYMBOL(dump_obdo);
174 EXPORT_SYMBOL(block_debug_setup);
175 EXPORT_SYMBOL(block_debug_check);