Thread (78 messages) 78 messages, 4 authors, 2021-12-17

Re: [PATCH v3 17/68] fscache: Implement simple cookie state machine

From: David Howells <dhowells@redhat.com>
Date: 2021-12-17 19:45:46
Also in: ceph-devel, linux-fsdevel, linux-nfs, lkml

Jeff Layton [off-list ref] wrote:
quoted
+	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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help