Cleanup macros for distinguishing mandatory locks
[linux-3.10.git] / fs / xfs / xfs_dir2_trace.c
1 /*
2  * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3  * All Rights Reserved.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it would be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write the Free Software Foundation,
16  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17  */
18 #include "xfs.h"
19 #include "xfs_fs.h"
20 #include "xfs_types.h"
21 #include "xfs_inum.h"
22 #include "xfs_dir2.h"
23 #include "xfs_da_btree.h"
24 #include "xfs_bmap_btree.h"
25 #include "xfs_dir2_sf.h"
26 #include "xfs_attr_sf.h"
27 #include "xfs_dinode.h"
28 #include "xfs_inode.h"
29 #include "xfs_dir2_trace.h"
30
31 #ifdef XFS_DIR2_TRACE
32 ktrace_t        *xfs_dir2_trace_buf;
33
34 /*
35  * Enter something in the trace buffers.
36  */
37 static void
38 xfs_dir2_trace_enter(
39         xfs_inode_t     *dp,
40         int             type,
41         char            *where,
42         char            *name,
43         int             namelen,
44         void            *a0,
45         void            *a1,
46         void            *a2,
47         void            *a3,
48         void            *a4,
49         void            *a5,
50         void            *a6,
51         void            *a7)
52 {
53         void            *n[5];
54
55         ASSERT(xfs_dir2_trace_buf);
56         ASSERT(dp->i_dir_trace);
57         if (name)
58                 memcpy(n, name, min((int)sizeof(n), namelen));
59         else
60                 memset((char *)n, 0, sizeof(n));
61         ktrace_enter(xfs_dir2_trace_buf,
62                 (void *)(long)type, (void *)where,
63                 (void *)a0, (void *)a1, (void *)a2, (void *)a3,
64                 (void *)a4, (void *)a5, (void *)a6, (void *)a7,
65                 (void *)(long)namelen,
66                 (void *)n[0], (void *)n[1], (void *)n[2],
67                 (void *)n[3], (void *)n[4]);
68         ktrace_enter(dp->i_dir_trace,
69                 (void *)(long)type, (void *)where,
70                 (void *)a0, (void *)a1, (void *)a2, (void *)a3,
71                 (void *)a4, (void *)a5, (void *)a6, (void *)a7,
72                 (void *)(long)namelen,
73                 (void *)n[0], (void *)n[1], (void *)n[2],
74                 (void *)n[3], (void *)n[4]);
75 }
76
77 void
78 xfs_dir2_trace_args(
79         char            *where,
80         xfs_da_args_t   *args)
81 {
82         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS, where,
83                 (char *)args->name, (int)args->namelen,
84                 (void *)(unsigned long)args->hashval,
85                 (void *)((unsigned long)(args->inumber >> 32)),
86                 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
87                 (void *)args->dp, (void *)args->trans,
88                 (void *)(unsigned long)args->justcheck, NULL, NULL);
89 }
90
91 void
92 xfs_dir2_trace_args_b(
93         char            *where,
94         xfs_da_args_t   *args,
95         xfs_dabuf_t     *bp)
96 {
97         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_B, where,
98                 (char *)args->name, (int)args->namelen,
99                 (void *)(unsigned long)args->hashval,
100                 (void *)((unsigned long)(args->inumber >> 32)),
101                 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
102                 (void *)args->dp, (void *)args->trans,
103                 (void *)(unsigned long)args->justcheck,
104                 (void *)(bp ? bp->bps[0] : NULL), NULL);
105 }
106
107 void
108 xfs_dir2_trace_args_bb(
109         char            *where,
110         xfs_da_args_t   *args,
111         xfs_dabuf_t     *lbp,
112         xfs_dabuf_t     *dbp)
113 {
114         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_BB, where,
115                 (char *)args->name, (int)args->namelen,
116                 (void *)(unsigned long)args->hashval,
117                 (void *)((unsigned long)(args->inumber >> 32)),
118                 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
119                 (void *)args->dp, (void *)args->trans,
120                 (void *)(unsigned long)args->justcheck,
121                 (void *)(lbp ? lbp->bps[0] : NULL),
122                 (void *)(dbp ? dbp->bps[0] : NULL));
123 }
124
125 void
126 xfs_dir2_trace_args_bibii(
127         char            *where,
128         xfs_da_args_t   *args,
129         xfs_dabuf_t     *bs,
130         int             ss,
131         xfs_dabuf_t     *bd,
132         int             sd,
133         int             c)
134 {
135         xfs_buf_t       *bpbs = bs ? bs->bps[0] : NULL;
136         xfs_buf_t       *bpbd = bd ? bd->bps[0] : NULL;
137
138         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_BIBII, where,
139                 (char *)args->name, (int)args->namelen,
140                 (void *)args->dp, (void *)args->trans,
141                 (void *)bpbs, (void *)(long)ss, (void *)bpbd, (void *)(long)sd,
142                 (void *)(long)c, NULL);
143 }
144
145 void
146 xfs_dir2_trace_args_db(
147         char            *where,
148         xfs_da_args_t   *args,
149         xfs_dir2_db_t   db,
150         xfs_dabuf_t     *bp)
151 {
152         xfs_buf_t       *dbp = bp ? bp->bps[0] : NULL;
153
154         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_DB, where,
155                 (char *)args->name, (int)args->namelen,
156                 (void *)(unsigned long)args->hashval,
157                 (void *)((unsigned long)(args->inumber >> 32)),
158                 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
159                 (void *)args->dp, (void *)args->trans,
160                 (void *)(unsigned long)args->justcheck, (void *)(long)db,
161                 (void *)dbp);
162 }
163
164 void
165 xfs_dir2_trace_args_i(
166         char            *where,
167         xfs_da_args_t   *args,
168         xfs_ino_t       i)
169 {
170         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_I, 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,
177                 (void *)((unsigned long)(i >> 32)),
178                 (void *)((unsigned long)(i & 0xFFFFFFFF)));
179 }
180
181 void
182 xfs_dir2_trace_args_s(
183         char            *where,
184         xfs_da_args_t   *args,
185         int             s)
186 {
187         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_S, where,
188                 (char *)args->name, (int)args->namelen,
189                 (void *)(unsigned long)args->hashval,
190                 (void *)((unsigned long)(args->inumber >> 32)),
191                 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
192                 (void *)args->dp, (void *)args->trans,
193                 (void *)(unsigned long)args->justcheck, (void *)(long)s, NULL);
194 }
195
196 void
197 xfs_dir2_trace_args_sb(
198         char            *where,
199         xfs_da_args_t   *args,
200         int             s,
201         xfs_dabuf_t     *bp)
202 {
203         xfs_buf_t       *dbp = bp ? bp->bps[0] : NULL;
204
205         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_SB, where,
206                 (char *)args->name, (int)args->namelen,
207                 (void *)(unsigned long)args->hashval,
208                 (void *)((unsigned long)(args->inumber >> 32)),
209                 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
210                 (void *)args->dp, (void *)args->trans,
211                 (void *)(unsigned long)args->justcheck, (void *)(long)s,
212                 (void *)dbp);
213 }
214 #endif  /* XFS_DIR2_TRACE */