Skip to content

Commit

Permalink
FS-Cache: The object-available state can't rely on the cookie to be a…
Browse files Browse the repository at this point in the history
…vailable

The object-available state in the object processing state machine (as
processed by fscache_object_available()) can't rely on the cookie to be
available because the FSCACHE_COOKIE_CREATING bit may have been cleared by
fscache_obtained_object() prior to the object being put into the
FSCACHE_OBJECT_AVAILABLE state.

Clearing the FSCACHE_COOKIE_CREATING bit on a cookie permits
__fscache_relinquish_cookie() to proceed and detach the cookie from the
object.

To deal with this, we don't dereference object->cookie in
fscache_object_available() if the object has already been detached.

In addition, a couple of assertions are added into fscache_drop_object() to
make sure the object is unbound from the cookie before it gets there.

Signed-off-by: David Howells <dhowells@redhat.com>
  • Loading branch information
David Howells committed Nov 19, 2009
1 parent 5753c44 commit 6897e3d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions fs/fscache/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ static void fscache_object_state_machine(struct fscache_object *object)

spin_lock(&object->lock);
object->state = FSCACHE_OBJECT_DYING;
if (test_and_clear_bit(FSCACHE_COOKIE_CREATING,
if (object->cookie &&
test_and_clear_bit(FSCACHE_COOKIE_CREATING,
&object->cookie->flags))
wake_up_bit(&object->cookie->flags,
FSCACHE_COOKIE_CREATING);
Expand Down Expand Up @@ -594,7 +595,8 @@ static void fscache_object_available(struct fscache_object *object)

spin_lock(&object->lock);

if (test_and_clear_bit(FSCACHE_COOKIE_CREATING, &object->cookie->flags))
if (object->cookie &&
test_and_clear_bit(FSCACHE_COOKIE_CREATING, &object->cookie->flags))
wake_up_bit(&object->cookie->flags, FSCACHE_COOKIE_CREATING);

fscache_done_parent_op(object);
Expand Down Expand Up @@ -631,6 +633,9 @@ static void fscache_drop_object(struct fscache_object *object)

_enter("{OBJ%x,%d}", object->debug_id, object->n_children);

ASSERTCMP(object->cookie, ==, NULL);
ASSERT(hlist_unhashed(&object->cookie_link));

spin_lock(&cache->object_list_lock);
list_del_init(&object->cache_link);
spin_unlock(&cache->object_list_lock);
Expand Down

0 comments on commit 6897e3d

Please sign in to comment.