aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2013-08-12 16:19:27 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2013-08-22 08:58:21 -0400
commit42113a75399353d87baf63956ab8f450958f1c8f (patch)
treef6829bd87220a89d633764ac0cc4d0d746bde120 /fs
parentc6d01c6f9bf94075a726b3103a7e90d981017326 (diff)
NFSv4: Add tracepoints for debugging file open
Set up basic tracepoints for debugging NFSv4 file open/close Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfs/nfs4proc.c4
-rw-r--r--fs/nfs/nfs4trace.h125
2 files changed, 129 insertions, 0 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 5f228edbb876..d609198724ed 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -1442,6 +1442,7 @@ static int nfs4_do_open_reclaim(struct nfs_open_context *ctx, struct nfs4_state
1442 int err; 1442 int err;
1443 do { 1443 do {
1444 err = _nfs4_do_open_reclaim(ctx, state); 1444 err = _nfs4_do_open_reclaim(ctx, state);
1445 trace_nfs4_open_reclaim(ctx, 0, err);
1445 if (nfs4_clear_cap_atomic_open_v1(server, err, &exception)) 1446 if (nfs4_clear_cap_atomic_open_v1(server, err, &exception))
1446 continue; 1447 continue;
1447 if (err != -NFS4ERR_DELAY) 1448 if (err != -NFS4ERR_DELAY)
@@ -1897,6 +1898,7 @@ static int nfs4_do_open_expired(struct nfs_open_context *ctx, struct nfs4_state
1897 1898
1898 do { 1899 do {
1899 err = _nfs4_open_expired(ctx, state); 1900 err = _nfs4_open_expired(ctx, state);
1901 trace_nfs4_open_expired(ctx, 0, err);
1900 if (nfs4_clear_cap_atomic_open_v1(server, err, &exception)) 1902 if (nfs4_clear_cap_atomic_open_v1(server, err, &exception))
1901 continue; 1903 continue;
1902 switch (err) { 1904 switch (err) {
@@ -2199,6 +2201,7 @@ static struct nfs4_state *nfs4_do_open(struct inode *dir,
2199 do { 2201 do {
2200 status = _nfs4_do_open(dir, ctx, flags, sattr, label); 2202 status = _nfs4_do_open(dir, ctx, flags, sattr, label);
2201 res = ctx->state; 2203 res = ctx->state;
2204 trace_nfs4_open_file(ctx, flags, status);
2202 if (status == 0) 2205 if (status == 0)
2203 break; 2206 break;
2204 /* NOTE: BAD_SEQID means the server and client disagree about the 2207 /* NOTE: BAD_SEQID means the server and client disagree about the
@@ -2389,6 +2392,7 @@ static void nfs4_close_done(struct rpc_task *task, void *data)
2389 dprintk("%s: begin!\n", __func__); 2392 dprintk("%s: begin!\n", __func__);
2390 if (!nfs4_sequence_done(task, &calldata->res.seq_res)) 2393 if (!nfs4_sequence_done(task, &calldata->res.seq_res))
2391 return; 2394 return;
2395 trace_nfs4_close(state, &calldata->arg, &calldata->res, task->tk_status);
2392 /* hmm. we are done with the inode, and in the process of freeing 2396 /* hmm. we are done with the inode, and in the process of freeing
2393 * the state_owner. we keep this around to process errors 2397 * the state_owner. we keep this around to process errors
2394 */ 2398 */
diff --git a/fs/nfs/nfs4trace.h b/fs/nfs/nfs4trace.h
index 9653feb8ff07..a558dc9c7c52 100644
--- a/fs/nfs/nfs4trace.h
+++ b/fs/nfs/nfs4trace.h
@@ -161,6 +161,19 @@
161 { -NFS4ERR_WRONG_TYPE, "WRONG_TYPE" }, \ 161 { -NFS4ERR_WRONG_TYPE, "WRONG_TYPE" }, \
162 { -NFS4ERR_XDEV, "XDEV" }) 162 { -NFS4ERR_XDEV, "XDEV" })
163 163
164#define show_open_flags(flags) \
165 __print_flags(flags, "|", \
166 { O_CREAT, "O_CREAT" }, \
167 { O_EXCL, "O_EXCL" }, \
168 { O_TRUNC, "O_TRUNC" }, \
169 { O_DIRECT, "O_DIRECT" })
170
171#define show_fmode_flags(mode) \
172 __print_flags(mode, "|", \
173 { ((__force unsigned long)FMODE_READ), "READ" }, \
174 { ((__force unsigned long)FMODE_WRITE), "WRITE" }, \
175 { ((__force unsigned long)FMODE_EXEC), "EXEC" })
176
164DECLARE_EVENT_CLASS(nfs4_clientid_event, 177DECLARE_EVENT_CLASS(nfs4_clientid_event,
165 TP_PROTO( 178 TP_PROTO(
166 const struct nfs_client *clp, 179 const struct nfs_client *clp,
@@ -211,6 +224,118 @@ DEFINE_NFS4_CLIENTID_EVENT(nfs4_sequence);
211DEFINE_NFS4_CLIENTID_EVENT(nfs4_reclaim_complete); 224DEFINE_NFS4_CLIENTID_EVENT(nfs4_reclaim_complete);
212#endif /* CONFIG_NFS_V4_1 */ 225#endif /* CONFIG_NFS_V4_1 */
213 226
227DECLARE_EVENT_CLASS(nfs4_open_event,
228 TP_PROTO(
229 const struct nfs_open_context *ctx,
230 int flags,
231 int error
232 ),
233
234 TP_ARGS(ctx, flags, error),
235
236 TP_STRUCT__entry(
237 __field(int, error)
238 __field(unsigned int, flags)
239 __field(unsigned int, fmode)
240 __field(dev_t, dev)
241 __field(u32, fhandle)
242 __field(u64, fileid)
243 __field(u64, dir)
244 __string(name, ctx->dentry->d_name.name)
245 ),
246
247 TP_fast_assign(
248 const struct nfs4_state *state = ctx->state;
249 const struct inode *inode = NULL;
250
251 __entry->error = error;
252 __entry->flags = flags;
253 __entry->fmode = (__force unsigned int)ctx->mode;
254 __entry->dev = ctx->dentry->d_sb->s_dev;
255 if (!IS_ERR(state))
256 inode = state->inode;
257 if (inode != NULL) {
258 __entry->fileid = NFS_FILEID(inode);
259 __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
260 } else {
261 __entry->fileid = 0;
262 __entry->fhandle = 0;
263 }
264 __entry->dir = NFS_FILEID(ctx->dentry->d_parent->d_inode);
265 __assign_str(name, ctx->dentry->d_name.name);
266 ),
267
268 TP_printk(
269 "error=%d (%s) flags=%d (%s) fmode=%s "
270 "fileid=%02x:%02x:%llu fhandle=0x%08x "
271 "name=%02x:%02x:%llu/%s",
272 __entry->error,
273 show_nfsv4_errors(__entry->error),
274 __entry->flags,
275 show_open_flags(__entry->flags),
276 show_fmode_flags(__entry->fmode),
277 MAJOR(__entry->dev), MINOR(__entry->dev),
278 (unsigned long long)__entry->fileid,
279 __entry->fhandle,
280 MAJOR(__entry->dev), MINOR(__entry->dev),
281 (unsigned long long)__entry->dir,
282 __get_str(name)
283 )
284);
285
286#define DEFINE_NFS4_OPEN_EVENT(name) \
287 DEFINE_EVENT(nfs4_open_event, name, \
288 TP_PROTO( \
289 const struct nfs_open_context *ctx, \
290 int flags, \
291 int error \
292 ), \
293 TP_ARGS(ctx, flags, error))
294DEFINE_NFS4_OPEN_EVENT(nfs4_open_reclaim);
295DEFINE_NFS4_OPEN_EVENT(nfs4_open_expired);
296DEFINE_NFS4_OPEN_EVENT(nfs4_open_file);
297
298TRACE_EVENT(nfs4_close,
299 TP_PROTO(
300 const struct nfs4_state *state,
301 const struct nfs_closeargs *args,
302 const struct nfs_closeres *res,
303 int error
304 ),
305
306 TP_ARGS(state, args, res, error),
307
308 TP_STRUCT__entry(
309 __field(dev_t, dev)
310 __field(u32, fhandle)
311 __field(u64, fileid)
312 __field(unsigned int, fmode)
313 __field(int, error)
314 ),
315
316 TP_fast_assign(
317 const struct inode *inode = state->inode;
318
319 __entry->dev = inode->i_sb->s_dev;
320 __entry->fileid = NFS_FILEID(inode);
321 __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode));
322 __entry->fmode = (__force unsigned int)state->state;
323 __entry->error = error;
324 ),
325
326 TP_printk(
327 "error=%d (%s) fmode=%s fileid=%02x:%02x:%llu "
328 "fhandle=0x%08x",
329 __entry->error,
330 show_nfsv4_errors(__entry->error),
331 __entry->fmode ? show_fmode_flags(__entry->fmode) :
332 "closed",
333 MAJOR(__entry->dev), MINOR(__entry->dev),
334 (unsigned long long)__entry->fileid,
335 __entry->fhandle
336 )
337);
338
214#endif /* _TRACE_NFS4_H */ 339#endif /* _TRACE_NFS4_H */
215 340
216#undef TRACE_INCLUDE_PATH 341#undef TRACE_INCLUDE_PATH