diff options
author | David Howells <dhowells@redhat.com> | 2020-04-29 18:02:04 +0200 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2020-06-04 16:37:57 +0200 |
commit | cca37d45d547434144409ae648a19b7eb6db5eb4 (patch) | |
tree | a5f02c893b15d6bb17444b5f27c3df7727cde531 /fs/afs/volume.c | |
parent | afs: Detect cell aliases 3 - YFS Cells with a canonical cell name op (diff) | |
download | linux-cca37d45d547434144409ae648a19b7eb6db5eb4.tar.xz linux-cca37d45d547434144409ae648a19b7eb6db5eb4.zip |
afs: Add a tracepoint to track the lifetime of the afs_volume struct
Add a tracepoint to track the lifetime of the afs_volume struct.
Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'fs/afs/volume.c')
-rw-r--r-- | fs/afs/volume.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/fs/afs/volume.c b/fs/afs/volume.c index d4d9a8fbba3d..0393f4910a92 100644 --- a/fs/afs/volume.c +++ b/fs/afs/volume.c @@ -52,6 +52,7 @@ static struct afs_volume *afs_alloc_volume(struct afs_fs_context *params, refcount_set(&slist->usage, 1); rcu_assign_pointer(volume->servers, slist); + trace_afs_volume(volume->vid, 1, afs_volume_trace_alloc); return volume; error_1: @@ -158,20 +159,38 @@ static void afs_destroy_volume(struct afs_net *net, struct afs_volume *volume) afs_put_serverlist(net, rcu_access_pointer(volume->servers)); afs_put_cell(net, volume->cell); + trace_afs_volume(volume->vid, atomic_read(&volume->usage), + afs_volume_trace_free); kfree(volume); _leave(" [destroyed]"); } /* - * Drop a reference on a volume record. + * Get a reference on a volume record. */ -void afs_put_volume(struct afs_net *net, struct afs_volume *volume) +struct afs_volume *afs_get_volume(struct afs_volume *volume, + enum afs_volume_trace reason) { if (volume) { - _enter("%s", volume->name); + int u = atomic_inc_return(&volume->usage); + trace_afs_volume(volume->vid, u, reason); + } + return volume; +} + - if (atomic_dec_and_test(&volume->usage)) +/* + * Drop a reference on a volume record. + */ +void afs_put_volume(struct afs_net *net, struct afs_volume *volume, + enum afs_volume_trace reason) +{ + if (volume) { + afs_volid_t vid = volume->vid; + int u = atomic_dec_return(&volume->usage); + trace_afs_volume(vid, u, reason); + if (u == 0) afs_destroy_volume(net, volume); } } |