Skip to content

Commit 5c4588a

Browse files
taigerhudhowells
authored andcommitted
fscache: Introduce fscache_cookie_is_dropped()
FSCACHE_COOKIE_STATE_DROPPED will be read more than once, so let's add a helper to avoid code duplication. Signed-off-by: Yue Hu <huyue2@coolpad.com> Signed-off-by: David Howells <dhowells@redhat.com> Link: https://listman.redhat.com/archives/linux-cachefs/2022-May/006919.html
1 parent bf17455 commit 5c4588a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

fs/fscache/cookie.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,17 +372,22 @@ static struct fscache_cookie *fscache_alloc_cookie(
372372
return NULL;
373373
}
374374

375+
static inline bool fscache_cookie_is_dropped(struct fscache_cookie *cookie)
376+
{
377+
return READ_ONCE(cookie->state) == FSCACHE_COOKIE_STATE_DROPPED;
378+
}
379+
375380
static void fscache_wait_on_collision(struct fscache_cookie *candidate,
376381
struct fscache_cookie *wait_for)
377382
{
378383
enum fscache_cookie_state *statep = &wait_for->state;
379384

380-
wait_var_event_timeout(statep, READ_ONCE(*statep) == FSCACHE_COOKIE_STATE_DROPPED,
385+
wait_var_event_timeout(statep, fscache_cookie_is_dropped(wait_for),
381386
20 * HZ);
382-
if (READ_ONCE(*statep) != FSCACHE_COOKIE_STATE_DROPPED) {
387+
if (!fscache_cookie_is_dropped(wait_for)) {
383388
pr_notice("Potential collision c=%08x old: c=%08x",
384389
candidate->debug_id, wait_for->debug_id);
385-
wait_var_event(statep, READ_ONCE(*statep) == FSCACHE_COOKIE_STATE_DROPPED);
390+
wait_var_event(statep, fscache_cookie_is_dropped(wait_for));
386391
}
387392
}
388393

0 commit comments

Comments
 (0)