aboutsummaryrefslogtreecommitdiff
path: root/fs/fscache/internal.h
diff options
context:
space:
mode:
authorGravatar David Howells <dhowells@redhat.com> 2021-03-29 13:53:50 +0100
committerGravatar David Howells <dhowells@redhat.com> 2021-08-27 13:34:03 +0100
commit20ec197bfa13c5b799fc9527790ea7b5374fc8f2 (patch)
tree77224ac38587572748156ae6bf02835a74585afb /fs/fscache/internal.h
parentfscache: Fix fscache_cookie_put() to not deref after dec (diff)
downloadlinux-20ec197bfa13c5b799fc9527790ea7b5374fc8f2.tar.gz
linux-20ec197bfa13c5b799fc9527790ea7b5374fc8f2.tar.bz2
linux-20ec197bfa13c5b799fc9527790ea7b5374fc8f2.zip
fscache: Use refcount_t for the cookie refcount instead of atomic_t
Use refcount_t for the fscache_cookie refcount instead of atomic_t and rename the 'usage' member to 'ref' in such cases. The tracepoints that reference it change from showing "u=%d" to "r=%d". Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: Jeff Layton <jlayton@redhat.com> cc: linux-cachefs@redhat.com Link: https://lore.kernel.org/r/162431204358.2908479.8006938388213098079.stgit@warthog.procyon.org.uk/
Diffstat (limited to 'fs/fscache/internal.h')
-rw-r--r--fs/fscache/internal.h17
1 files changed, 9 insertions, 8 deletions
diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
index 345105dbbfd1..c3e4804b8fcb 100644
--- a/fs/fscache/internal.h
+++ b/fs/fscache/internal.h
@@ -54,9 +54,18 @@ extern struct fscache_cookie *fscache_alloc_cookie(struct fscache_cookie *,
const void *, size_t,
void *, loff_t);
extern struct fscache_cookie *fscache_hash_cookie(struct fscache_cookie *);
+extern struct fscache_cookie *fscache_cookie_get(struct fscache_cookie *,
+ enum fscache_cookie_trace);
extern void fscache_cookie_put(struct fscache_cookie *,
enum fscache_cookie_trace);
+static inline void fscache_cookie_see(struct fscache_cookie *cookie,
+ enum fscache_cookie_trace where)
+{
+ trace_fscache_cookie(cookie->debug_id, refcount_read(&cookie->ref),
+ where);
+}
+
/*
* fsdef.c
*/
@@ -286,14 +295,6 @@ static inline void fscache_raise_event(struct fscache_object *object,
fscache_enqueue_object(object);
}
-static inline void fscache_cookie_get(struct fscache_cookie *cookie,
- enum fscache_cookie_trace where)
-{
- int usage = atomic_inc_return(&cookie->usage);
-
- trace_fscache_cookie(cookie->debug_id, usage, where);
-}
-
/*
* get an extra reference to a netfs retrieval context
*/