Skip to content

Commit

Permalink
FS-Cache: Clear netfs pointers in cookie after detaching object, not …
Browse files Browse the repository at this point in the history
…before

Clear the pointers from the fscache_cookie struct to netfs private data after
clearing the pointer to the cookie from the fscache_object struct and
releasing the object lock, rather than before.

This allows the netfs private data pointers to be relied on simply by holding
the object lock, rather than having to hold the cookie lock.  This is makes
things simpler as the cookie lock has to be taken before the object lock, but
sometimes the object pointer is all that the code has.

Signed-off-by: David Howells <dhowells@redhat.com>
  • Loading branch information
dhowells committed Nov 19, 2009
1 parent 52bd75f commit 7e311a2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fs/fscache/cookie.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,8 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)

event = retire ? FSCACHE_OBJECT_EV_RETIRE : FSCACHE_OBJECT_EV_RELEASE;

/* detach pointers back to the netfs */
spin_lock(&cookie->lock);

cookie->netfs_data = NULL;
cookie->def = NULL;

/* break links with all the active objects */
while (!hlist_empty(&cookie->backing_objects)) {
object = hlist_entry(cookie->backing_objects.first,
Expand All @@ -465,6 +461,10 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
BUG();
}

/* detach pointers back to the netfs */
cookie->netfs_data = NULL;
cookie->def = NULL;

spin_unlock(&cookie->lock);

if (cookie->parent) {
Expand Down

0 comments on commit 7e311a2

Please sign in to comment.