summaryrefslogtreecommitdiffstats
path: root/fs/netfs/objects.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2022-02-17 15:01:24 +0000
committerDavid Howells <dhowells@redhat.com>2022-03-18 09:24:00 +0000
commit6cd3d6fd1fe2feae5ff9f6a821081569bb140bf4 (patch)
tree1a8fce9f17a0ef5e991ddd3691358f65738e7bd0 /fs/netfs/objects.c
parentde74023befa1876f64bc5871a2a4a51850517118 (diff)
downloadlinux-stable-6cd3d6fd1fe2feae5ff9f6a821081569bb140bf4.tar.gz
linux-stable-6cd3d6fd1fe2feae5ff9f6a821081569bb140bf4.tar.bz2
linux-stable-6cd3d6fd1fe2feae5ff9f6a821081569bb140bf4.zip
netfs: Trace refcounting on the netfs_io_subrequest struct
Add refcount tracing for the netfs_io_subrequest structure. Changes ======= ver #3) - Switch 'W=' to 'R=' in the traceline to match other request debug IDs. 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/164622998584.3564931.5052255990645723639.stgit@warthog.procyon.org.uk/ # v1 Link: https://lore.kernel.org/r/164678202603.1200972.14726007419792315578.stgit@warthog.procyon.org.uk/ # v2 Link: https://lore.kernel.org/r/164692901860.2099075.4845820886851239935.stgit@warthog.procyon.org.uk/ # v3
Diffstat (limited to 'fs/netfs/objects.c')
-rw-r--r--fs/netfs/objects.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/fs/netfs/objects.c b/fs/netfs/objects.c
index 4e29c3bb6e5a..39097893e847 100644
--- a/fs/netfs/objects.c
+++ b/fs/netfs/objects.c
@@ -53,7 +53,8 @@ void netfs_clear_subrequests(struct netfs_io_request *rreq, bool was_async)
subreq = list_first_entry(&rreq->subrequests,
struct netfs_io_subrequest, rreq_link);
list_del(&subreq->rreq_link);
- netfs_put_subrequest(subreq, was_async);
+ netfs_put_subrequest(subreq, was_async,
+ netfs_sreq_trace_put_clear);
}
}
@@ -101,7 +102,7 @@ struct netfs_io_subrequest *netfs_alloc_subrequest(struct netfs_io_request *rreq
subreq = kzalloc(sizeof(struct netfs_io_subrequest), GFP_KERNEL);
if (subreq) {
INIT_LIST_HEAD(&subreq->rreq_link);
- refcount_set(&subreq->usage, 2);
+ refcount_set(&subreq->ref, 2);
subreq->rreq = rreq;
netfs_get_request(rreq, netfs_rreq_trace_get_subreq);
netfs_stat(&netfs_n_rh_sreq);
@@ -110,13 +111,18 @@ struct netfs_io_subrequest *netfs_alloc_subrequest(struct netfs_io_request *rreq
return subreq;
}
-void netfs_get_subrequest(struct netfs_io_subrequest *subreq)
+void netfs_get_subrequest(struct netfs_io_subrequest *subreq,
+ enum netfs_sreq_ref_trace what)
{
- refcount_inc(&subreq->usage);
+ int r;
+
+ __refcount_inc(&subreq->ref, &r);
+ trace_netfs_sreq_ref(subreq->rreq->debug_id, subreq->debug_index, r + 1,
+ what);
}
-static void __netfs_put_subrequest(struct netfs_io_subrequest *subreq,
- bool was_async)
+static void netfs_free_subrequest(struct netfs_io_subrequest *subreq,
+ bool was_async)
{
struct netfs_io_request *rreq = subreq->rreq;
@@ -126,8 +132,16 @@ static void __netfs_put_subrequest(struct netfs_io_subrequest *subreq,
netfs_put_request(rreq, was_async, netfs_rreq_trace_put_subreq);
}
-void netfs_put_subrequest(struct netfs_io_subrequest *subreq, bool was_async)
+void netfs_put_subrequest(struct netfs_io_subrequest *subreq, bool was_async,
+ enum netfs_sreq_ref_trace what)
{
- if (refcount_dec_and_test(&subreq->usage))
- __netfs_put_subrequest(subreq, was_async);
+ unsigned int debug_index = subreq->debug_index;
+ unsigned int debug_id = subreq->rreq->debug_id;
+ bool dead;
+ int r;
+
+ dead = __refcount_dec_and_test(&subreq->ref, &r);
+ trace_netfs_sreq_ref(debug_id, debug_index, r - 1, what);
+ if (dead)
+ netfs_free_subrequest(subreq, was_async);
}