Re: [PATCH] fscache: fix race between enablement and dropping of object

From: David Howells
Date: Wed Nov 28 2018 - 10:12:34 EST

NeilBrown <neilb@xxxxxxxx> wrote:

> It was observed that a process blocked indefintely in
> __fscache_read_or_alloc_page(), waiting for FSCACHE_COOKIE_LOOKING_UP
> to be cleared via fscache_wait_for_deferred_lookup().

Was there a backtrace for that?

> This leaves a window where something else can set FSCACHE_COOKIE_LOOKING_UP

Attempting to enable the cookie again would have that effect.

> There is some uncertainty in this analysis, but it seems to be fit the
> observations. Adding the wake in this patch will be handled correctly
> by __fscache_read_or_alloc_page(), as it checks if ->backing_objects
> is empty again, after waiting.

That should work. The read op should just then fail with -ENOBUFS, causing
the netfs to issue the read over the network instead.

I think there's a more elegant solution to be had, but it'll take some thought
as to how to achieve it.