mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fscache: extended "dying" check before emitting EV_INVALIDATE
@ 2013-04-03 14:48 Max Kellermann
  2013-04-23 16:46 ` David Howells
  2013-04-23 16:57 ` David Howells
  0 siblings, 2 replies; 3+ messages in thread
From: Max Kellermann @ 2013-04-03 14:48 UTC (permalink / raw)
  To: dhowells, linux-cachefs; +Cc: linux-kernel

Before emitting an FSCACHE_OBJECT_EV_INVALIDATE event, the function
__fscache_invalidate() checks whether the fscache_object is currently
"dying".  This checks only the current state, not the queued events
that will very soon lead to the object's death.

The problem is that fscache_object_state_machine() will
BUG("Unsupported event") when there is object->events includes
EV_INVALIDATE during "terminal_transit".  Even if we would ignore that
check, we could run into "Unexpected event in dead state" later
because object->work may still be queued.

The solution is to check for EV_RETIRE and EV_RELEASE; if one of those
two terminal events is already queued, don't bother to queue
EV_INVALIDATE.

Signed-off-by: Max Kellermann <mk@cm4all.com>
---
 fs/fscache/cookie.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
index 8dcb114..ed80d7f 100644
--- a/fs/fscache/cookie.c
+++ b/fs/fscache/cookie.c
@@ -402,7 +402,8 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
 			object = hlist_entry(cookie->backing_objects.first,
 					     struct fscache_object,
 					     cookie_link);
-			if (object->state < FSCACHE_OBJECT_DYING)
+			if (object->state < FSCACHE_OBJECT_DYING &&
+			    (object->events & (FSCACHE_OBJECT_EV_RETIRE|FSCACHE_OBJECT_EV_RELEASE)) == 0)
 				fscache_raise_event(
 					object, FSCACHE_OBJECT_EV_INVALIDATE);
 		}


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fscache: extended "dying" check before emitting EV_INVALIDATE
  2013-04-03 14:48 [PATCH] fscache: extended "dying" check before emitting EV_INVALIDATE Max Kellermann
@ 2013-04-23 16:46 ` David Howells
  2013-04-23 16:57 ` David Howells
  1 sibling, 0 replies; 3+ messages in thread
From: David Howells @ 2013-04-23 16:46 UTC (permalink / raw)
  To: Max Kellermann; +Cc: dhowells, linux-cachefs, linux-kernel

Max Kellermann <mk@cm4all.com> wrote:

> +			    (object->events & (FSCACHE_OBJECT_EV_RETIRE|FSCACHE_OBJECT_EV_RELEASE)) == 0)

You can't do it like this.  EV_RETIRE and EV_RELEASE are bit numbers, so need
to be shifted into place.

David

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fscache: extended "dying" check before emitting EV_INVALIDATE
  2013-04-03 14:48 [PATCH] fscache: extended "dying" check before emitting EV_INVALIDATE Max Kellermann
  2013-04-23 16:46 ` David Howells
@ 2013-04-23 16:57 ` David Howells
  1 sibling, 0 replies; 3+ messages in thread
From: David Howells @ 2013-04-23 16:57 UTC (permalink / raw)
  To: Max Kellermann; +Cc: dhowells, linux-cachefs, linux-kernel

Max Kellermann <mk@cm4all.com> wrote:

> Before emitting an FSCACHE_OBJECT_EV_INVALIDATE event, the function
> __fscache_invalidate() checks whether the fscache_object is currently
> "dying".  This checks only the current state, not the queued events
> that will very soon lead to the object's death.

This should not be a problem, I think.  EV_RETIRE and EV_RELEASE should only be
set by fscache_relinquish_cookie().  If you (the netfs) call that to dispose of
a cookie to fscache, you shouldn't thereafter be calling fscache_invalidate()
on it.  The only case in which __fscache_invalidate() should see a dying object
is if the caching backend withdraws it (ie. EV_WITHDRAW is set).

Do you have a backtrace?

David

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-04-23 16:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-03 14:48 [PATCH] fscache: extended "dying" check before emitting EV_INVALIDATE Max Kellermann
2013-04-23 16:46 ` David Howells
2013-04-23 16:57 ` David Howells

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®