Whamcloud - gitweb
Change the cleanup scripts to use the debug_kernel instead of get_debug.
[fs/lustre-release.git] / lustre / lib / debug.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Helper routines for dumping data structs for debugging.
5  *
6  * This code is issued under the GNU General Public License.
7  * See the file COPYING in this distribution
8  *
9  * Copryright (C) 2002 Cluster File Systems, Inc.
10  *
11  */
12
13 #define DEBUG_SUBSYSTEM D_OTHER
14
15 #include <linux/obd_ost.h>
16 #include <linux/lustre_debug.h>
17
18 int dump_ioo(struct obd_ioobj *ioo)
19 {
20         CERROR("obd_ioobj: ioo_id=%Ld, ioo_gr=%Ld, ioo_type=%d, ioo_bufct=%d\n",
21                ioo->ioo_id, ioo->ioo_gr, ioo->ioo_type, ioo->ioo_bufcnt);
22         return -EINVAL;
23 }
24
25 int dump_lniobuf(struct niobuf_local *nb)
26 {
27         CERROR("niobuf_local: addr=%Ld, offset=%Ld, len=%d, xid=%d\n",
28                nb->addr, nb->offset, nb->len, nb->xid);
29         CERROR("nb->page: index = %ld\n", ((struct page *)nb->page)->index);
30
31         return -EINVAL;
32 }
33
34 int dump_rniobuf(struct niobuf_remote *nb)
35 {
36         CERROR("niobuf_remote: offset=%Ld, len=%d, flags=%x, xid=%d\n",
37                nb->offset, nb->len, nb->flags, nb->xid);
38
39         return -EINVAL;
40 }
41
42 int dump_obdo(struct obdo *oa)
43 {
44         CERROR("obdo: o_valid = %08x\n", oa->o_valid);
45         if (oa->o_valid & OBD_MD_FLID)
46                 CERROR("obdo: o_id = %Ld\n", oa->o_id);
47         if (oa->o_valid & OBD_MD_FLATIME)
48                 CERROR("obdo: o_atime = %Ld\n", oa->o_atime);
49         if (oa->o_valid & OBD_MD_FLMTIME)
50                 CERROR("obdo: o_mtime = %Ld\n", oa->o_mtime);
51         if (oa->o_valid & OBD_MD_FLCTIME)
52                 CERROR("obdo: o_ctime = %Ld\n", oa->o_ctime);
53         if (oa->o_valid & OBD_MD_FLSIZE)
54                 CERROR("obdo: o_size = %Ld\n", oa->o_size);
55         if (oa->o_valid & OBD_MD_FLBLOCKS)   /* allocation of space */
56                 CERROR("obdo: o_blocks = %Ld\n", oa->o_blocks);
57         if (oa->o_valid & OBD_MD_FLBLKSZ)
58                 CERROR("obdo: o_blksize = %d\n", oa->o_blksize);
59         if (oa->o_valid & OBD_MD_FLMODE)
60                 CERROR("obdo: o_mode = %o\n", oa->o_mode);
61         if (oa->o_valid & OBD_MD_FLUID)
62                 CERROR("obdo: o_uid = %d\n", oa->o_uid);
63         if (oa->o_valid & OBD_MD_FLGID)
64                 CERROR("obdo: o_gid = %d\n", oa->o_gid);
65         if (oa->o_valid & OBD_MD_FLFLAGS)
66                 CERROR("obdo: o_flags = %x\n", oa->o_flags);
67         if (oa->o_valid & OBD_MD_FLNLINK)
68                 CERROR("obdo: o_nlink = %d\n", oa->o_nlink);
69         if (oa->o_valid & OBD_MD_FLGENER)
70                 CERROR("obdo: o_generation = %d\n", oa->o_generation);
71
72         return -EINVAL;
73 }
74
75 /* XXX assumes only a single page in request */
76 int dump_req(struct ptlrpc_request *req)
77 {
78         struct ost_body *body = lustre_msg_buf(req->rq_reqmsg, 0);
79         struct obd_ioobj *ioo = lustre_msg_buf(req->rq_reqmsg, 1);
80         //struct niobuf *nb = lustre_msg_buf(req->rq_reqmsg, 2);
81
82         CERROR("ost_body: connid = %d, data = %d\n", body->connid, body->data);
83         dump_obdo(&body->oa);
84         //dump_niobuf(nb);
85         dump_ioo(ioo);
86
87         return -EINVAL;
88 }
89