[XFS] Remove xfs_macros.c, xfs_macros.h, rework headers a whole lot.
[powerpc.git] / fs / xfs / xfs_dir2_trace.c
1 /*
2  * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of version 2 of the GNU General Public License as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it would be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  *
12  * Further, this software is distributed without any warranty that it is
13  * free of the rightful claim of any third person regarding infringement
14  * or the like.  Any license provided herein, whether implied or
15  * otherwise, applies only to this software file.  Patent licenses, if
16  * any, provided herein do not apply to combinations of this program with
17  * other software, or any other product whatsoever.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write the Free Software Foundation, Inc., 59
21  * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22  *
23  * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24  * Mountain View, CA  94043, or:
25  *
26  * http://www.sgi.com
27  *
28  * For further information regarding this notice, see:
29  *
30  * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31  */
32 #include "xfs.h"
33 #include "xfs_fs.h"
34 #include "xfs_types.h"
35 #include "xfs_inum.h"
36 #include "xfs_dir.h"
37 #include "xfs_dir2.h"
38 #include "xfs_da_btree.h"
39 #include "xfs_bmap_btree.h"
40 #include "xfs_dir_sf.h"
41 #include "xfs_dir2_sf.h"
42 #include "xfs_attr_sf.h"
43 #include "xfs_dinode.h"
44 #include "xfs_inode.h"
45 #include "xfs_dir2_trace.h"
46
47 #ifdef XFS_DIR2_TRACE
48 ktrace_t        *xfs_dir2_trace_buf;
49
50 /*
51  * Enter something in the trace buffers.
52  */
53 static void
54 xfs_dir2_trace_enter(
55         xfs_inode_t     *dp,
56         int             type,
57         char            *where,
58         char            *name,
59         int             namelen,
60         void            *a0,
61         void            *a1,
62         void            *a2,
63         void            *a3,
64         void            *a4,
65         void            *a5,
66         void            *a6,
67         void            *a7)
68 {
69         void            *n[5];
70
71         ASSERT(xfs_dir2_trace_buf);
72         ASSERT(dp->i_dir_trace);
73         if (name)
74                 memcpy(n, name, min((int)sizeof(n), namelen));
75         else
76                 memset((char *)n, 0, sizeof(n));
77         ktrace_enter(xfs_dir2_trace_buf,
78                 (void *)(long)type, (void *)where,
79                 (void *)a0, (void *)a1, (void *)a2, (void *)a3,
80                 (void *)a4, (void *)a5, (void *)a6, (void *)a7,
81                 (void *)(long)namelen,
82                 (void *)n[0], (void *)n[1], (void *)n[2],
83                 (void *)n[3], (void *)n[4]);
84         ktrace_enter(dp->i_dir_trace,
85                 (void *)(long)type, (void *)where,
86                 (void *)a0, (void *)a1, (void *)a2, (void *)a3,
87                 (void *)a4, (void *)a5, (void *)a6, (void *)a7,
88                 (void *)(long)namelen,
89                 (void *)n[0], (void *)n[1], (void *)n[2],
90                 (void *)n[3], (void *)n[4]);
91 }
92
93 void
94 xfs_dir2_trace_args(
95         char            *where,
96         xfs_da_args_t   *args)
97 {
98         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS, where,
99                 (char *)args->name, (int)args->namelen,
100                 (void *)(unsigned long)args->hashval,
101                 (void *)((unsigned long)(args->inumber >> 32)),
102                 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
103                 (void *)args->dp, (void *)args->trans,
104                 (void *)(unsigned long)args->justcheck, NULL, NULL);
105 }
106
107 void
108 xfs_dir2_trace_args_b(
109         char            *where,
110         xfs_da_args_t   *args,
111         xfs_dabuf_t     *bp)
112 {
113         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_B, where,
114                 (char *)args->name, (int)args->namelen,
115                 (void *)(unsigned long)args->hashval,
116                 (void *)((unsigned long)(args->inumber >> 32)),
117                 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
118                 (void *)args->dp, (void *)args->trans,
119                 (void *)(unsigned long)args->justcheck,
120                 (void *)(bp ? bp->bps[0] : NULL), NULL);
121 }
122
123 void
124 xfs_dir2_trace_args_bb(
125         char            *where,
126         xfs_da_args_t   *args,
127         xfs_dabuf_t     *lbp,
128         xfs_dabuf_t     *dbp)
129 {
130         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_BB, where,
131                 (char *)args->name, (int)args->namelen,
132                 (void *)(unsigned long)args->hashval,
133                 (void *)((unsigned long)(args->inumber >> 32)),
134                 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
135                 (void *)args->dp, (void *)args->trans,
136                 (void *)(unsigned long)args->justcheck,
137                 (void *)(lbp ? lbp->bps[0] : NULL),
138                 (void *)(dbp ? dbp->bps[0] : NULL));
139 }
140
141 void
142 xfs_dir2_trace_args_bibii(
143         char            *where,
144         xfs_da_args_t   *args,
145         xfs_dabuf_t     *bs,
146         int             ss,
147         xfs_dabuf_t     *bd,
148         int             sd,
149         int             c)
150 {
151         xfs_buf_t       *bpbs = bs ? bs->bps[0] : NULL;
152         xfs_buf_t       *bpbd = bd ? bd->bps[0] : NULL;
153
154         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_BIBII, where,
155                 (char *)args->name, (int)args->namelen,
156                 (void *)args->dp, (void *)args->trans,
157                 (void *)bpbs, (void *)(long)ss, (void *)bpbd, (void *)(long)sd,
158                 (void *)(long)c, NULL);
159 }
160
161 void
162 xfs_dir2_trace_args_db(
163         char            *where,
164         xfs_da_args_t   *args,
165         xfs_dir2_db_t   db,
166         xfs_dabuf_t     *bp)
167 {
168         xfs_buf_t       *dbp = bp ? bp->bps[0] : NULL;
169
170         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_DB, where,
171                 (char *)args->name, (int)args->namelen,
172                 (void *)(unsigned long)args->hashval,
173                 (void *)((unsigned long)(args->inumber >> 32)),
174                 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
175                 (void *)args->dp, (void *)args->trans,
176                 (void *)(unsigned long)args->justcheck, (void *)(long)db,
177                 (void *)dbp);
178 }
179
180 void
181 xfs_dir2_trace_args_i(
182         char            *where,
183         xfs_da_args_t   *args,
184         xfs_ino_t       i)
185 {
186         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_I, where,
187                 (char *)args->name, (int)args->namelen,
188                 (void *)(unsigned long)args->hashval,
189                 (void *)((unsigned long)(args->inumber >> 32)),
190                 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
191                 (void *)args->dp, (void *)args->trans,
192                 (void *)(unsigned long)args->justcheck,
193                 (void *)((unsigned long)(i >> 32)),
194                 (void *)((unsigned long)(i & 0xFFFFFFFF)));
195 }
196
197 void
198 xfs_dir2_trace_args_s(
199         char            *where,
200         xfs_da_args_t   *args,
201         int             s)
202 {
203         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_S, where,
204                 (char *)args->name, (int)args->namelen,
205                 (void *)(unsigned long)args->hashval,
206                 (void *)((unsigned long)(args->inumber >> 32)),
207                 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
208                 (void *)args->dp, (void *)args->trans,
209                 (void *)(unsigned long)args->justcheck, (void *)(long)s, NULL);
210 }
211
212 void
213 xfs_dir2_trace_args_sb(
214         char            *where,
215         xfs_da_args_t   *args,
216         int             s,
217         xfs_dabuf_t     *bp)
218 {
219         xfs_buf_t       *dbp = bp ? bp->bps[0] : NULL;
220
221         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_SB, where,
222                 (char *)args->name, (int)args->namelen,
223                 (void *)(unsigned long)args->hashval,
224                 (void *)((unsigned long)(args->inumber >> 32)),
225                 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
226                 (void *)args->dp, (void *)args->trans,
227                 (void *)(unsigned long)args->justcheck, (void *)(long)s,
228                 (void *)dbp);
229 }
230 #endif  /* XFS_DIR2_TRACE */