Skip to content

Commit 8c39b8b

Browse files
committed
cachefiles: Make some tracepoint adjustments
Make some adjustments to tracepoints to make the tracing a bit more followable: (1) Standardise on displaying the backing inode number as "B=<hex>" with no leading zeros. (2) Make the cachefiles_lookup tracepoint log the directory inode number as well as the looked-up inode number. (3) Add a cachefiles_lookup tracepoint into cachefiles_get_directory() to log directory lookup. (4) Add a new cachefiles_mkdir tracepoint and use that to log a successful mkdir from cachefiles_get_directory(). (5) Make the cachefiles_unlink and cachefiles_rename tracepoints log the inode number of the affected file/dir rather than dentry struct pointers. Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> cc: linux-cachefs@redhat.com Link: https://lore.kernel.org/r/164251403694.3435901.9797725381831316715.stgit@warthog.procyon.org.uk/ # v1
1 parent c7ca731 commit 8c39b8b

File tree

2 files changed

+56
-34
lines changed

2 files changed

+56
-34
lines changed

fs/cachefiles/namei.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ struct dentry *cachefiles_get_directory(struct cachefiles_cache *cache,
101101
subdir = lookup_one_len(dirname, dir, strlen(dirname));
102102
else
103103
subdir = ERR_PTR(ret);
104+
trace_cachefiles_lookup(NULL, dir, subdir);
104105
if (IS_ERR(subdir)) {
105106
trace_cachefiles_vfs_error(NULL, d_backing_inode(dir),
106107
PTR_ERR(subdir),
@@ -135,6 +136,7 @@ struct dentry *cachefiles_get_directory(struct cachefiles_cache *cache,
135136
cachefiles_trace_mkdir_error);
136137
goto mkdir_error;
137138
}
139+
trace_cachefiles_mkdir(dir, subdir);
138140

139141
if (unlikely(d_unhashed(subdir))) {
140142
cachefiles_put_directory(subdir);
@@ -233,7 +235,7 @@ static int cachefiles_unlink(struct cachefiles_cache *cache,
233235
};
234236
int ret;
235237

236-
trace_cachefiles_unlink(object, dentry, why);
238+
trace_cachefiles_unlink(object, d_inode(dentry)->i_ino, why);
237239
ret = security_path_unlink(&path, dentry);
238240
if (ret < 0) {
239241
cachefiles_io_error(cache, "Unlink security error");
@@ -386,7 +388,7 @@ int cachefiles_bury_object(struct cachefiles_cache *cache,
386388
.new_dir = d_inode(cache->graveyard),
387389
.new_dentry = grave,
388390
};
389-
trace_cachefiles_rename(object, rep, grave, why);
391+
trace_cachefiles_rename(object, d_inode(rep)->i_ino, why);
390392
ret = cachefiles_inject_read_error();
391393
if (ret == 0)
392394
ret = vfs_rename(&rd);
@@ -617,7 +619,7 @@ bool cachefiles_look_up_object(struct cachefiles_object *object)
617619
object->d_name_len);
618620
else
619621
dentry = ERR_PTR(ret);
620-
trace_cachefiles_lookup(object, dentry);
622+
trace_cachefiles_lookup(object, fan, dentry);
621623
if (IS_ERR(dentry)) {
622624
if (dentry == ERR_PTR(-ENOENT))
623625
goto new_file;

include/trace/events/cachefiles.h

Lines changed: 51 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -233,25 +233,48 @@ TRACE_EVENT(cachefiles_ref,
233233

234234
TRACE_EVENT(cachefiles_lookup,
235235
TP_PROTO(struct cachefiles_object *obj,
236+
struct dentry *dir,
236237
struct dentry *de),
237238

238-
TP_ARGS(obj, de),
239+
TP_ARGS(obj, dir, de),
239240

240241
TP_STRUCT__entry(
241242
__field(unsigned int, obj )
242243
__field(short, error )
244+
__field(unsigned long, dino )
243245
__field(unsigned long, ino )
244246
),
245247

246248
TP_fast_assign(
247-
__entry->obj = obj->debug_id;
249+
__entry->obj = obj ? obj->debug_id : 0;
250+
__entry->dino = d_backing_inode(dir)->i_ino;
248251
__entry->ino = (!IS_ERR(de) && d_backing_inode(de) ?
249252
d_backing_inode(de)->i_ino : 0);
250253
__entry->error = IS_ERR(de) ? PTR_ERR(de) : 0;
251254
),
252255

253-
TP_printk("o=%08x i=%lx e=%d",
254-
__entry->obj, __entry->ino, __entry->error)
256+
TP_printk("o=%08x dB=%lx B=%lx e=%d",
257+
__entry->obj, __entry->dino, __entry->ino, __entry->error)
258+
);
259+
260+
TRACE_EVENT(cachefiles_mkdir,
261+
TP_PROTO(struct dentry *dir, struct dentry *subdir),
262+
263+
TP_ARGS(dir, subdir),
264+
265+
TP_STRUCT__entry(
266+
__field(unsigned int, dir )
267+
__field(unsigned int, subdir )
268+
),
269+
270+
TP_fast_assign(
271+
__entry->dir = d_backing_inode(dir)->i_ino;
272+
__entry->subdir = d_backing_inode(subdir)->i_ino;
273+
),
274+
275+
TP_printk("dB=%x sB=%x",
276+
__entry->dir,
277+
__entry->subdir)
255278
);
256279

257280
TRACE_EVENT(cachefiles_tmpfile,
@@ -269,7 +292,7 @@ TRACE_EVENT(cachefiles_tmpfile,
269292
__entry->backer = backer->i_ino;
270293
),
271294

272-
TP_printk("o=%08x b=%08x",
295+
TP_printk("o=%08x B=%x",
273296
__entry->obj,
274297
__entry->backer)
275298
);
@@ -289,61 +312,58 @@ TRACE_EVENT(cachefiles_link,
289312
__entry->backer = backer->i_ino;
290313
),
291314

292-
TP_printk("o=%08x b=%08x",
315+
TP_printk("o=%08x B=%x",
293316
__entry->obj,
294317
__entry->backer)
295318
);
296319

297320
TRACE_EVENT(cachefiles_unlink,
298321
TP_PROTO(struct cachefiles_object *obj,
299-
struct dentry *de,
322+
ino_t ino,
300323
enum fscache_why_object_killed why),
301324

302-
TP_ARGS(obj, de, why),
325+
TP_ARGS(obj, ino, why),
303326

304327
/* Note that obj may be NULL */
305328
TP_STRUCT__entry(
306329
__field(unsigned int, obj )
307-
__field(struct dentry *, de )
330+
__field(unsigned int, ino )
308331
__field(enum fscache_why_object_killed, why )
309332
),
310333

311334
TP_fast_assign(
312335
__entry->obj = obj ? obj->debug_id : UINT_MAX;
313-
__entry->de = de;
336+
__entry->ino = ino;
314337
__entry->why = why;
315338
),
316339

317-
TP_printk("o=%08x d=%p w=%s",
318-
__entry->obj, __entry->de,
340+
TP_printk("o=%08x B=%x w=%s",
341+
__entry->obj, __entry->ino,
319342
__print_symbolic(__entry->why, cachefiles_obj_kill_traces))
320343
);
321344

322345
TRACE_EVENT(cachefiles_rename,
323346
TP_PROTO(struct cachefiles_object *obj,
324-
struct dentry *de,
325-
struct dentry *to,
347+
ino_t ino,
326348
enum fscache_why_object_killed why),
327349

328-
TP_ARGS(obj, de, to, why),
350+
TP_ARGS(obj, ino, why),
329351

330352
/* Note that obj may be NULL */
331353
TP_STRUCT__entry(
332354
__field(unsigned int, obj )
333-
__field(struct dentry *, de )
334-
__field(struct dentry *, to )
355+
__field(unsigned int, ino )
335356
__field(enum fscache_why_object_killed, why )
336357
),
337358

338359
TP_fast_assign(
339360
__entry->obj = obj ? obj->debug_id : UINT_MAX;
340-
__entry->de = de;
341-
__entry->to = to;
361+
__entry->ino = ino;
342362
__entry->why = why;
343363
),
344364

345-
TP_printk("o=%08x d=%p t=%p w=%s",
346-
__entry->obj, __entry->de, __entry->to,
365+
TP_printk("o=%08x B=%x w=%s",
366+
__entry->obj, __entry->ino,
347367
__print_symbolic(__entry->why, cachefiles_obj_kill_traces))
348368
);
349369

@@ -370,7 +390,7 @@ TRACE_EVENT(cachefiles_coherency,
370390
__entry->ino = ino;
371391
),
372392

373-
TP_printk("o=%08x %s i=%llx c=%u",
393+
TP_printk("o=%08x %s B=%llx c=%u",
374394
__entry->obj,
375395
__print_symbolic(__entry->why, cachefiles_coherency_traces),
376396
__entry->ino,
@@ -397,7 +417,7 @@ TRACE_EVENT(cachefiles_vol_coherency,
397417
__entry->ino = ino;
398418
),
399419

400-
TP_printk("V=%08x %s i=%llx",
420+
TP_printk("V=%08x %s B=%llx",
401421
__entry->vol,
402422
__print_symbolic(__entry->why, cachefiles_coherency_traces),
403423
__entry->ino)
@@ -435,7 +455,7 @@ TRACE_EVENT(cachefiles_prep_read,
435455
__entry->cache_inode = cache_inode;
436456
),
437457

438-
TP_printk("R=%08x[%u] %s %s f=%02x s=%llx %zx ni=%x b=%x",
458+
TP_printk("R=%08x[%u] %s %s f=%02x s=%llx %zx ni=%x B=%x",
439459
__entry->rreq, __entry->index,
440460
__print_symbolic(__entry->source, netfs_sreq_sources),
441461
__print_symbolic(__entry->why, cachefiles_prepare_read_traces),
@@ -466,7 +486,7 @@ TRACE_EVENT(cachefiles_read,
466486
__entry->len = len;
467487
),
468488

469-
TP_printk("o=%08x b=%08x s=%llx l=%zx",
489+
TP_printk("o=%08x B=%x s=%llx l=%zx",
470490
__entry->obj,
471491
__entry->backer,
472492
__entry->start,
@@ -495,7 +515,7 @@ TRACE_EVENT(cachefiles_write,
495515
__entry->len = len;
496516
),
497517

498-
TP_printk("o=%08x b=%08x s=%llx l=%zx",
518+
TP_printk("o=%08x B=%x s=%llx l=%zx",
499519
__entry->obj,
500520
__entry->backer,
501521
__entry->start,
@@ -524,7 +544,7 @@ TRACE_EVENT(cachefiles_trunc,
524544
__entry->why = why;
525545
),
526546

527-
TP_printk("o=%08x b=%08x %s l=%llx->%llx",
547+
TP_printk("o=%08x B=%x %s l=%llx->%llx",
528548
__entry->obj,
529549
__entry->backer,
530550
__print_symbolic(__entry->why, cachefiles_trunc_traces),
@@ -549,7 +569,7 @@ TRACE_EVENT(cachefiles_mark_active,
549569
__entry->inode = inode->i_ino;
550570
),
551571

552-
TP_printk("o=%08x i=%lx",
572+
TP_printk("o=%08x B=%lx",
553573
__entry->obj, __entry->inode)
554574
);
555575

@@ -570,7 +590,7 @@ TRACE_EVENT(cachefiles_mark_inactive,
570590
__entry->inode = inode->i_ino;
571591
),
572592

573-
TP_printk("o=%08x i=%lx",
593+
TP_printk("o=%08x B=%lx",
574594
__entry->obj, __entry->inode)
575595
);
576596

@@ -594,7 +614,7 @@ TRACE_EVENT(cachefiles_vfs_error,
594614
__entry->where = where;
595615
),
596616

597-
TP_printk("o=%08x b=%08x %s e=%d",
617+
TP_printk("o=%08x B=%x %s e=%d",
598618
__entry->obj,
599619
__entry->backer,
600620
__print_symbolic(__entry->where, cachefiles_error_traces),
@@ -621,7 +641,7 @@ TRACE_EVENT(cachefiles_io_error,
621641
__entry->where = where;
622642
),
623643

624-
TP_printk("o=%08x b=%08x %s e=%d",
644+
TP_printk("o=%08x B=%x %s e=%d",
625645
__entry->obj,
626646
__entry->backer,
627647
__print_symbolic(__entry->where, cachefiles_error_traces),

0 commit comments

Comments
 (0)