Skip to content

Commit 6897e3d

Browse files
committed
FS-Cache: The object-available state can't rely on the cookie to be available
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>
1 parent 5753c44 commit 6897e3d

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎fs/fscache/object.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ static void fscache_object_state_machine(struct fscache_object *object)
158158

159159
spin_lock(&object->lock);
160160
object->state = FSCACHE_OBJECT_DYING;
161-
if (test_and_clear_bit(FSCACHE_COOKIE_CREATING,
161+
if (object->cookie &&
162+
test_and_clear_bit(FSCACHE_COOKIE_CREATING,
162163
&object->cookie->flags))
163164
wake_up_bit(&object->cookie->flags,
164165
FSCACHE_COOKIE_CREATING);
@@ -594,7 +595,8 @@ static void fscache_object_available(struct fscache_object *object)
594595

595596
spin_lock(&object->lock);
596597

597-
if (test_and_clear_bit(FSCACHE_COOKIE_CREATING, &object->cookie->flags))
598+
if (object->cookie &&
599+
test_and_clear_bit(FSCACHE_COOKIE_CREATING, &object->cookie->flags))
598600
wake_up_bit(&object->cookie->flags, FSCACHE_COOKIE_CREATING);
599601

600602
fscache_done_parent_op(object);
@@ -631,6 +633,9 @@ static void fscache_drop_object(struct fscache_object *object)
631633

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

636+
ASSERTCMP(object->cookie, ==, NULL);
637+
ASSERT(hlist_unhashed(&object->cookie_link));
638+
634639
spin_lock(&cache->object_list_lock);
635640
list_del_init(&object->cache_link);
636641
spin_unlock(&cache->object_list_lock);

0 commit comments

Comments
 (0)