lkml.org 
[lkml]   [2021]   [Dec]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v3 17/68] fscache: Implement simple cookie state machine
Date
Jeff Layton <jlayton@kernel.org> wrote:

> > + case FSCACHE_COOKIE_STATE_RELINQUISHING:
> > + case FSCACHE_COOKIE_STATE_WITHDRAWING:
> > + if (cookie->cache_priv) {
> > + spin_unlock(&cookie->lock);
> > + cookie->volume->cache->ops->withdraw_cookie(cookie);
> > + spin_lock(&cookie->lock);
> > + }
> > +
> > + switch (state) {
> > + case FSCACHE_COOKIE_STATE_RELINQUISHING:
> > + fscache_see_cookie(cookie, fscache_cookie_see_relinquish);
> > + fscache_unhash_cookie(cookie);
> > + __fscache_set_cookie_state(cookie,
> > + FSCACHE_COOKIE_STATE_DROPPED);
> > + wake = true;
> > + goto out;
> > + case FSCACHE_COOKIE_STATE_WITHDRAWING:
> > + fscache_see_cookie(cookie, fscache_cookie_see_withdraw);
> > + break;
> > + default:
> > + BUG();
> > + }
> > +
>
> Ugh, the nested switch here is a bit hard to follow. It makes it seem
> like the state could change due to the withdraw_cookie and you're
> checking it again, but it doesn't do that.
>
> This would be clearer if you just duplicated the withdraw_cookie stanza
> for both states and moved the stuff below here to a helper or to a new
> goto block.

There are actually three states, but one's added in a later patch. It
probably does make sense to split the RELINQ state from the other two.

David

\
 
 \ /
  Last update: 2021-12-17 20:46    [W:0.521 / U:0.936 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site