Skip to content

Commit 4f67bcf

Browse files
committed
afs: Improve afs_volume tracing to display a debug ID
Improve the tracing of afs_volume objects to include displaying a debug ID so that different instances of volumes with the same "vid" can be distinguished. Also be consistent about displaying the volume's refcount (and not the cell's). Signed-off-by: David Howells <dhowells@redhat.com> cc: Marc Dionne <marc.dionne@auristor.com> cc: linux-afs@lists.infradead.org cc: linux-fsdevel@vger.kernel.org Link: https://lore.kernel.org/r/20250224234154.2014840-9-dhowells@redhat.com/ # v1 Link: https://lore.kernel.org/r/20250310094206.801057-5-dhowells@redhat.com/ # v4
1 parent 1d0b929 commit 4f67bcf

3 files changed

Lines changed: 21 additions & 13 deletions

File tree

fs/afs/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ struct afs_volume {
623623
afs_volid_t vid; /* The volume ID of this volume */
624624
afs_volid_t vids[AFS_MAXTYPES]; /* All associated volume IDs */
625625
refcount_t ref;
626+
unsigned int debug_id; /* Debugging ID for traces */
626627
time64_t update_at; /* Time at which to next update */
627628
struct afs_cell *cell; /* Cell to which belongs (pins ref) */
628629
struct rb_node cell_node; /* Link in cell->volumes */

fs/afs/volume.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "internal.h"
1111

1212
static unsigned __read_mostly afs_volume_record_life = 60 * 60;
13+
static atomic_t afs_volume_debug_id;
1314

1415
static void afs_destroy_volume(struct work_struct *work);
1516

@@ -59,7 +60,7 @@ static void afs_remove_volume_from_cell(struct afs_volume *volume)
5960
struct afs_cell *cell = volume->cell;
6061

6162
if (!hlist_unhashed(&volume->proc_link)) {
62-
trace_afs_volume(volume->vid, refcount_read(&cell->ref),
63+
trace_afs_volume(volume->debug_id, volume->vid, refcount_read(&volume->ref),
6364
afs_volume_trace_remove);
6465
write_seqlock(&cell->volume_lock);
6566
hlist_del_rcu(&volume->proc_link);
@@ -84,6 +85,7 @@ static struct afs_volume *afs_alloc_volume(struct afs_fs_context *params,
8485
if (!volume)
8586
goto error_0;
8687

88+
volume->debug_id = atomic_inc_return(&afs_volume_debug_id);
8789
volume->vid = vldb->vid[params->type];
8890
volume->update_at = ktime_get_real_seconds() + afs_volume_record_life;
8991
volume->cell = afs_get_cell(params->cell, afs_cell_trace_get_vol);
@@ -115,7 +117,7 @@ static struct afs_volume *afs_alloc_volume(struct afs_fs_context *params,
115117

116118
*_slist = slist;
117119
rcu_assign_pointer(volume->servers, slist);
118-
trace_afs_volume(volume->vid, 1, afs_volume_trace_alloc);
120+
trace_afs_volume(volume->debug_id, volume->vid, 1, afs_volume_trace_alloc);
119121
return volume;
120122

121123
error_1:
@@ -247,7 +249,7 @@ static void afs_destroy_volume(struct work_struct *work)
247249
afs_remove_volume_from_cell(volume);
248250
afs_put_serverlist(volume->cell->net, slist);
249251
afs_put_cell(volume->cell, afs_cell_trace_put_vol);
250-
trace_afs_volume(volume->vid, refcount_read(&volume->ref),
252+
trace_afs_volume(volume->debug_id, volume->vid, refcount_read(&volume->ref),
251253
afs_volume_trace_free);
252254
kfree_rcu(volume, rcu);
253255

@@ -262,7 +264,7 @@ bool afs_try_get_volume(struct afs_volume *volume, enum afs_volume_trace reason)
262264
int r;
263265

264266
if (__refcount_inc_not_zero(&volume->ref, &r)) {
265-
trace_afs_volume(volume->vid, r + 1, reason);
267+
trace_afs_volume(volume->debug_id, volume->vid, r + 1, reason);
266268
return true;
267269
}
268270
return false;
@@ -278,7 +280,7 @@ struct afs_volume *afs_get_volume(struct afs_volume *volume,
278280
int r;
279281

280282
__refcount_inc(&volume->ref, &r);
281-
trace_afs_volume(volume->vid, r + 1, reason);
283+
trace_afs_volume(volume->debug_id, volume->vid, r + 1, reason);
282284
}
283285
return volume;
284286
}
@@ -290,12 +292,13 @@ struct afs_volume *afs_get_volume(struct afs_volume *volume,
290292
void afs_put_volume(struct afs_volume *volume, enum afs_volume_trace reason)
291293
{
292294
if (volume) {
295+
unsigned int debug_id = volume->debug_id;
293296
afs_volid_t vid = volume->vid;
294297
bool zero;
295298
int r;
296299

297300
zero = __refcount_dec_and_test(&volume->ref, &r);
298-
trace_afs_volume(vid, r - 1, reason);
301+
trace_afs_volume(debug_id, vid, r - 1, reason);
299302
if (zero)
300303
schedule_work(&volume->destructor);
301304
}

include/trace/events/afs.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,25 +1539,29 @@ TRACE_EVENT(afs_server,
15391539
);
15401540

15411541
TRACE_EVENT(afs_volume,
1542-
TP_PROTO(afs_volid_t vid, int ref, enum afs_volume_trace reason),
1542+
TP_PROTO(unsigned int debug_id, afs_volid_t vid, int ref,
1543+
enum afs_volume_trace reason),
15431544

1544-
TP_ARGS(vid, ref, reason),
1545+
TP_ARGS(debug_id, vid, ref, reason),
15451546

15461547
TP_STRUCT__entry(
1548+
__field(unsigned int, debug_id)
15471549
__field(afs_volid_t, vid)
15481550
__field(int, ref)
15491551
__field(enum afs_volume_trace, reason)
15501552
),
15511553

15521554
TP_fast_assign(
1553-
__entry->vid = vid;
1554-
__entry->ref = ref;
1555-
__entry->reason = reason;
1555+
__entry->debug_id = debug_id;
1556+
__entry->vid = vid;
1557+
__entry->ref = ref;
1558+
__entry->reason = reason;
15561559
),
15571560

1558-
TP_printk("V=%llx %s ur=%d",
1559-
__entry->vid,
1561+
TP_printk("V=%08x %s vid=%llx r=%d",
1562+
__entry->debug_id,
15601563
__print_symbolic(__entry->reason, afs_volume_traces),
1564+
__entry->vid,
15611565
__entry->ref)
15621566
);
15631567

0 commit comments

Comments
 (0)