aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2013-08-20 11:26:17 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2013-08-22 08:58:18 -0400
commit6e0d0be715fe041fc7121b0b44cde3015d1cc846 (patch)
tree406e7b0a1494a330d4cb4a1b5855af94c95e966a
parent1472b83eae0bf09ab76ebcb1373dbd210e97f911 (diff)
NFS: Add event tracing for generic NFS lookups
Add tracepoints for lookup, lookup_revalidate and atomic_open Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--fs/nfs/dir.c7
-rw-r--r--fs/nfs/nfstrace.c1
-rw-r--r--fs/nfs/nfstrace.h195
3 files changed, 203 insertions, 0 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 29d5463dcd65..2263a6ba36af 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1102,7 +1102,9 @@ static int nfs_lookup_revalidate(struct dentry *dentry, unsigned int flags)
1102 if (IS_ERR(label)) 1102 if (IS_ERR(label))
1103 goto out_error; 1103 goto out_error;
1104 1104
1105 trace_nfs_lookup_revalidate_enter(dir, dentry, flags);
1105 error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr, label); 1106 error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr, label);
1107 trace_nfs_lookup_revalidate_exit(dir, dentry, flags, error);
1106 if (error) 1108 if (error)
1107 goto out_bad; 1109 goto out_bad;
1108 if (nfs_compare_fh(NFS_FH(inode), fhandle)) 1110 if (nfs_compare_fh(NFS_FH(inode), fhandle))
@@ -1315,6 +1317,7 @@ struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned in
1315 1317
1316 parent = dentry->d_parent; 1318 parent = dentry->d_parent;
1317 /* Protect against concurrent sillydeletes */ 1319 /* Protect against concurrent sillydeletes */
1320 trace_nfs_lookup_enter(dir, dentry, flags);
1318 nfs_block_sillyrename(parent); 1321 nfs_block_sillyrename(parent);
1319 error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr, label); 1322 error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr, label);
1320 if (error == -ENOENT) 1323 if (error == -ENOENT)
@@ -1341,6 +1344,7 @@ no_entry:
1341 nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); 1344 nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
1342out_unblock_sillyrename: 1345out_unblock_sillyrename:
1343 nfs_unblock_sillyrename(parent); 1346 nfs_unblock_sillyrename(parent);
1347 trace_nfs_lookup_exit(dir, dentry, flags, error);
1344 nfs4_label_free(label); 1348 nfs4_label_free(label);
1345out: 1349out:
1346 nfs_free_fattr(fattr); 1350 nfs_free_fattr(fattr);
@@ -1451,12 +1455,14 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
1451 if (IS_ERR(ctx)) 1455 if (IS_ERR(ctx))
1452 goto out; 1456 goto out;
1453 1457
1458 trace_nfs_atomic_open_enter(dir, ctx, open_flags);
1454 nfs_block_sillyrename(dentry->d_parent); 1459 nfs_block_sillyrename(dentry->d_parent);
1455 inode = NFS_PROTO(dir)->open_context(dir, ctx, open_flags, &attr); 1460 inode = NFS_PROTO(dir)->open_context(dir, ctx, open_flags, &attr);
1456 nfs_unblock_sillyrename(dentry->d_parent); 1461 nfs_unblock_sillyrename(dentry->d_parent);
1457 if (IS_ERR(inode)) { 1462 if (IS_ERR(inode)) {
1458 put_nfs_open_context(ctx); 1463 put_nfs_open_context(ctx);
1459 err = PTR_ERR(inode); 1464 err = PTR_ERR(inode);
1465 trace_nfs_atomic_open_exit(dir, ctx, open_flags, err);
1460 switch (err) { 1466 switch (err) {
1461 case -ENOENT: 1467 case -ENOENT:
1462 d_drop(dentry); 1468 d_drop(dentry);
@@ -1477,6 +1483,7 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
1477 } 1483 }
1478 1484
1479 err = nfs_finish_open(ctx, ctx->dentry, file, open_flags, opened); 1485 err = nfs_finish_open(ctx, ctx->dentry, file, open_flags, opened);
1486 trace_nfs_atomic_open_exit(dir, ctx, open_flags, err);
1480out: 1487out:
1481 return err; 1488 return err;
1482 1489
diff --git a/fs/nfs/nfstrace.c b/fs/nfs/nfstrace.c
index cc9146134848..4eb0aead69b6 100644
--- a/fs/nfs/nfstrace.c
+++ b/fs/nfs/nfstrace.c
@@ -2,6 +2,7 @@
2 * Copyright (c) 2013 Trond Myklebust <Trond.Myklebust@netapp.com> 2 * Copyright (c) 2013 Trond Myklebust <Trond.Myklebust@netapp.com>
3 */ 3 */
4#include <linux/nfs_fs.h> 4#include <linux/nfs_fs.h>
5#include <linux/namei.h>
5#include "internal.h" 6#include "internal.h"
6 7
7#define CREATE_TRACE_POINTS 8#define CREATE_TRACE_POINTS
diff --git a/fs/nfs/nfstrace.h b/fs/nfs/nfstrace.h
index 73c8e1edeef4..fba194b70027 100644
--- a/fs/nfs/nfstrace.h
+++ b/fs/nfs/nfstrace.h
@@ -157,6 +157,201 @@ DEFINE_NFS_INODE_EVENT_DONE(nfs_fsync_exit);
157DEFINE_NFS_INODE_EVENT(nfs_access_enter); 157DEFINE_NFS_INODE_EVENT(nfs_access_enter);
158DEFINE_NFS_INODE_EVENT_DONE(nfs_access_exit); 158DEFINE_NFS_INODE_EVENT_DONE(nfs_access_exit);
159 159
160#define show_lookup_flags(flags) \
161 __print_flags((unsigned long)flags, "|", \
162 { LOOKUP_AUTOMOUNT, "AUTOMOUNT" }, \
163 { LOOKUP_DIRECTORY, "DIRECTORY" }, \
164 { LOOKUP_OPEN, "OPEN" }, \
165 { LOOKUP_CREATE, "CREATE" }, \
166 { LOOKUP_EXCL, "EXCL" })
167
168DECLARE_EVENT_CLASS(nfs_lookup_event,
169 TP_PROTO(
170 const struct inode *dir,
171 const struct dentry *dentry,
172 unsigned int flags
173 ),
174
175 TP_ARGS(dir, dentry, flags),
176
177 TP_STRUCT__entry(
178 __field(unsigned int, flags)
179 __field(dev_t, dev)
180 __field(u64, dir)
181 __string(name, dentry->d_name.name)
182 ),
183
184 TP_fast_assign(
185 __entry->dev = dir->i_sb->s_dev;
186 __entry->dir = NFS_FILEID(dir);
187 __entry->flags = flags;
188 __assign_str(name, dentry->d_name.name);
189 ),
190
191 TP_printk(
192 "flags=%u (%s) name=%02x:%02x:%llu/%s",
193 __entry->flags,
194 show_lookup_flags(__entry->flags),
195 MAJOR(__entry->dev), MINOR(__entry->dev),
196 (unsigned long long)__entry->dir,
197 __get_str(name)
198 )
199);
200
201#define DEFINE_NFS_LOOKUP_EVENT(name) \
202 DEFINE_EVENT(nfs_lookup_event, name, \
203 TP_PROTO( \
204 const struct inode *dir, \
205 const struct dentry *dentry, \
206 unsigned int flags \
207 ), \
208 TP_ARGS(dir, dentry, flags))
209
210DECLARE_EVENT_CLASS(nfs_lookup_event_done,
211 TP_PROTO(
212 const struct inode *dir,
213 const struct dentry *dentry,
214 unsigned int flags,
215 int error
216 ),
217
218 TP_ARGS(dir, dentry, flags, error),
219
220 TP_STRUCT__entry(
221 __field(int, error)
222 __field(unsigned int, flags)
223 __field(dev_t, dev)
224 __field(u64, dir)
225 __string(name, dentry->d_name.name)
226 ),
227
228 TP_fast_assign(
229 __entry->dev = dir->i_sb->s_dev;
230 __entry->dir = NFS_FILEID(dir);
231 __entry->error = error;
232 __entry->flags = flags;
233 __assign_str(name, dentry->d_name.name);
234 ),
235
236 TP_printk(
237 "error=%d flags=%u (%s) name=%02x:%02x:%llu/%s",
238 __entry->error,
239 __entry->flags,
240 show_lookup_flags(__entry->flags),
241 MAJOR(__entry->dev), MINOR(__entry->dev),
242 (unsigned long long)__entry->dir,
243 __get_str(name)
244 )
245);
246
247#define DEFINE_NFS_LOOKUP_EVENT_DONE(name) \
248 DEFINE_EVENT(nfs_lookup_event_done, name, \
249 TP_PROTO( \
250 const struct inode *dir, \
251 const struct dentry *dentry, \
252 unsigned int flags, \
253 int error \
254 ), \
255 TP_ARGS(dir, dentry, flags, error))
256
257DEFINE_NFS_LOOKUP_EVENT(nfs_lookup_enter);
258DEFINE_NFS_LOOKUP_EVENT_DONE(nfs_lookup_exit);
259DEFINE_NFS_LOOKUP_EVENT(nfs_lookup_revalidate_enter);
260DEFINE_NFS_LOOKUP_EVENT_DONE(nfs_lookup_revalidate_exit);
261
262#define show_open_flags(flags) \
263 __print_flags((unsigned long)flags, "|", \
264 { O_CREAT, "O_CREAT" }, \
265 { O_EXCL, "O_EXCL" }, \
266 { O_TRUNC, "O_TRUNC" }, \
267 { O_APPEND, "O_APPEND" }, \
268 { O_DSYNC, "O_DSYNC" }, \
269 { O_DIRECT, "O_DIRECT" }, \
270 { O_DIRECTORY, "O_DIRECTORY" })
271
272#define show_fmode_flags(mode) \
273 __print_flags(mode, "|", \
274 { ((__force unsigned long)FMODE_READ), "READ" }, \
275 { ((__force unsigned long)FMODE_WRITE), "WRITE" }, \
276 { ((__force unsigned long)FMODE_EXEC), "EXEC" })
277
278TRACE_EVENT(nfs_atomic_open_enter,
279 TP_PROTO(
280 const struct inode *dir,
281 const struct nfs_open_context *ctx,
282 unsigned int flags
283 ),
284
285 TP_ARGS(dir, ctx, flags),
286
287 TP_STRUCT__entry(
288 __field(unsigned int, flags)
289 __field(unsigned int, fmode)
290 __field(dev_t, dev)
291 __field(u64, dir)
292 __string(name, ctx->dentry->d_name.name)
293 ),
294
295 TP_fast_assign(
296 __entry->dev = dir->i_sb->s_dev;
297 __entry->dir = NFS_FILEID(dir);
298 __entry->flags = flags;
299 __entry->fmode = (__force unsigned int)ctx->mode;
300 __assign_str(name, ctx->dentry->d_name.name);
301 ),
302
303 TP_printk(
304 "flags=%u (%s) fmode=%s name=%02x:%02x:%llu/%s",
305 __entry->flags,
306 show_open_flags(__entry->flags),
307 show_fmode_flags(__entry->fmode),
308 MAJOR(__entry->dev), MINOR(__entry->dev),
309 (unsigned long long)__entry->dir,
310 __get_str(name)
311 )
312);
313
314TRACE_EVENT(nfs_atomic_open_exit,
315 TP_PROTO(
316 const struct inode *dir,
317 const struct nfs_open_context *ctx,
318 unsigned int flags,
319 int error
320 ),
321
322 TP_ARGS(dir, ctx, flags, error),
323
324 TP_STRUCT__entry(
325 __field(int, error)
326 __field(unsigned int, flags)
327 __field(unsigned int, fmode)
328 __field(dev_t, dev)
329 __field(u64, dir)
330 __string(name, ctx->dentry->d_name.name)
331 ),
332
333 TP_fast_assign(
334 __entry->error = error;
335 __entry->dev = dir->i_sb->s_dev;
336 __entry->dir = NFS_FILEID(dir);
337 __entry->flags = flags;
338 __entry->fmode = (__force unsigned int)ctx->mode;
339 __assign_str(name, ctx->dentry->d_name.name);
340 ),
341
342 TP_printk(
343 "error=%d flags=%u (%s) fmode=%s "
344 "name=%02x:%02x:%llu/%s",
345 __entry->error,
346 __entry->flags,
347 show_open_flags(__entry->flags),
348 show_fmode_flags(__entry->fmode),
349 MAJOR(__entry->dev), MINOR(__entry->dev),
350 (unsigned long long)__entry->dir,
351 __get_str(name)
352 )
353);
354
160#endif /* _TRACE_NFS_H */ 355#endif /* _TRACE_NFS_H */
161 356
162#undef TRACE_INCLUDE_PATH 357#undef TRACE_INCLUDE_PATH