Skip to content

Commit

Permalink
Merge tag 'fscache-fixes-20220809' of git://git.kernel.org/pub/scm/li…
Browse files Browse the repository at this point in the history
…nux/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
  • Loading branch information
torvalds committed Aug 9, 2022
2 parents 4b22e20 + 1a1e3ac commit 15205c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions fs/fscache/cookie.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ void fscache_caching_failed(struct fscache_cookie *cookie)
{
clear_bit(FSCACHE_COOKIE_IS_CACHING, &cookie->flags);
fscache_set_cookie_state(cookie, FSCACHE_COOKIE_STATE_FAILED);
trace_fscache_cookie(cookie->debug_id, refcount_read(&cookie->ref),
fscache_cookie_failed);
}
EXPORT_SYMBOL(fscache_caching_failed);

Expand Down Expand Up @@ -739,6 +741,9 @@ static void fscache_cookie_state_machine(struct fscache_cookie *cookie)
fallthrough;

case FSCACHE_COOKIE_STATE_FAILED:
if (test_and_clear_bit(FSCACHE_COOKIE_DO_INVALIDATE, &cookie->flags))
fscache_end_cookie_access(cookie, fscache_access_invalidate_cookie_end);

if (atomic_read(&cookie->n_accesses) != 0)
break;
if (test_bit(FSCACHE_COOKIE_DO_RELINQUISH, &cookie->flags)) {
Expand Down Expand Up @@ -1063,8 +1068,8 @@ void __fscache_invalidate(struct fscache_cookie *cookie,
return;

case FSCACHE_COOKIE_STATE_LOOKING_UP:
__fscache_begin_cookie_access(cookie, fscache_access_invalidate_cookie);
set_bit(FSCACHE_COOKIE_DO_INVALIDATE, &cookie->flags);
if (!test_and_set_bit(FSCACHE_COOKIE_DO_INVALIDATE, &cookie->flags))
__fscache_begin_cookie_access(cookie, fscache_access_invalidate_cookie);
fallthrough;
case FSCACHE_COOKIE_STATE_CREATING:
spin_unlock(&cookie->lock);
Expand Down
2 changes: 2 additions & 0 deletions include/trace/events/fscache.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ enum fscache_volume_trace {
enum fscache_cookie_trace {
fscache_cookie_collision,
fscache_cookie_discard,
fscache_cookie_failed,
fscache_cookie_get_attach_object,
fscache_cookie_get_end_access,
fscache_cookie_get_hash_collision,
Expand Down Expand Up @@ -131,6 +132,7 @@ enum fscache_access_trace {
#define fscache_cookie_traces \
EM(fscache_cookie_collision, "*COLLIDE*") \
EM(fscache_cookie_discard, "DISCARD ") \
EM(fscache_cookie_failed, "FAILED ") \
EM(fscache_cookie_get_attach_object, "GET attch") \
EM(fscache_cookie_get_hash_collision, "GET hcoll") \
EM(fscache_cookie_get_end_access, "GQ endac") \
Expand Down

0 comments on commit 15205c2

Please sign in to comment.