Skip to content

Commit 15205c2

Browse files
committed
Merge tag 'fscache-fixes-20220809' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs
Pull fscache updates from David Howells: - Fix a cookie access ref leak if a cookie is invalidated a second time before the first invalidation is actually processed. - Add a tracepoint to log cookie lookup failure * tag 'fscache-fixes-20220809' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs: fscache: add tracepoint when failing cookie fscache: don't leak cookie access refs if invalidation is in progress or failed
2 parents 4b22e20 + 1a1e3ac commit 15205c2

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

fs/fscache/cookie.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ void fscache_caching_failed(struct fscache_cookie *cookie)
263263
{
264264
clear_bit(FSCACHE_COOKIE_IS_CACHING, &cookie->flags);
265265
fscache_set_cookie_state(cookie, FSCACHE_COOKIE_STATE_FAILED);
266+
trace_fscache_cookie(cookie->debug_id, refcount_read(&cookie->ref),
267+
fscache_cookie_failed);
266268
}
267269
EXPORT_SYMBOL(fscache_caching_failed);
268270

@@ -739,6 +741,9 @@ static void fscache_cookie_state_machine(struct fscache_cookie *cookie)
739741
fallthrough;
740742

741743
case FSCACHE_COOKIE_STATE_FAILED:
744+
if (test_and_clear_bit(FSCACHE_COOKIE_DO_INVALIDATE, &cookie->flags))
745+
fscache_end_cookie_access(cookie, fscache_access_invalidate_cookie_end);
746+
742747
if (atomic_read(&cookie->n_accesses) != 0)
743748
break;
744749
if (test_bit(FSCACHE_COOKIE_DO_RELINQUISH, &cookie->flags)) {
@@ -1063,8 +1068,8 @@ void __fscache_invalidate(struct fscache_cookie *cookie,
10631068
return;
10641069

10651070
case FSCACHE_COOKIE_STATE_LOOKING_UP:
1066-
__fscache_begin_cookie_access(cookie, fscache_access_invalidate_cookie);
1067-
set_bit(FSCACHE_COOKIE_DO_INVALIDATE, &cookie->flags);
1071+
if (!test_and_set_bit(FSCACHE_COOKIE_DO_INVALIDATE, &cookie->flags))
1072+
__fscache_begin_cookie_access(cookie, fscache_access_invalidate_cookie);
10681073
fallthrough;
10691074
case FSCACHE_COOKIE_STATE_CREATING:
10701075
spin_unlock(&cookie->lock);

include/trace/events/fscache.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ enum fscache_volume_trace {
4949
enum fscache_cookie_trace {
5050
fscache_cookie_collision,
5151
fscache_cookie_discard,
52+
fscache_cookie_failed,
5253
fscache_cookie_get_attach_object,
5354
fscache_cookie_get_end_access,
5455
fscache_cookie_get_hash_collision,
@@ -131,6 +132,7 @@ enum fscache_access_trace {
131132
#define fscache_cookie_traces \
132133
EM(fscache_cookie_collision, "*COLLIDE*") \
133134
EM(fscache_cookie_discard, "DISCARD ") \
135+
EM(fscache_cookie_failed, "FAILED ") \
134136
EM(fscache_cookie_get_attach_object, "GET attch") \
135137
EM(fscache_cookie_get_hash_collision, "GET hcoll") \
136138
EM(fscache_cookie_get_end_access, "GQ endac") \

0 commit comments

Comments
 (0)