Re: [PATCH V4 07/13] fs: Add locking for a dynamic address space operations state

From: Dave Chinner
Date: Fri Feb 21 2020 - 17:44:33 EST


On Fri, Feb 21, 2020 at 06:44:49PM +0100, Christoph Hellwig wrote:
> On Thu, Feb 20, 2020 at 04:41:28PM -0800, ira.weiny@xxxxxxxxx wrote:
> > From: Ira Weiny <ira.weiny@xxxxxxxxx>
> >
> > DAX requires special address space operations (aops). Changing DAX
> > state therefore requires changing those aops.
> >
> > However, many functions require aops to remain consistent through a deep
> > call stack.
> >
> > Define a vfs level inode rwsem to protect aops throughout call stacks
> > which require them.
> >
> > Finally, define calls to be used in subsequent patches when aops usage
> > needs to be quiesced by the file system.
>
> I am very much against this. There is a reason why we don't support
> changes of ops vectors at runtime anywhere else, because it is
> horribly complicated and impossible to get right. IFF we ever want
> to change the DAX vs non-DAX mode (which I'm still not sold on) the
> right way is to just add a few simple conditionals and merge the
> aops, which is much easier to reason about, and less costly in overall
> overhead.

*cough*

That's exactly what the original code did. And it was broken
because page faults call multiple aops that are dependent on the
result of the previous aop calls setting up the state correctly for
the latter calls. And when S_DAX changes between those calls, shit
breaks.

It's exactly the same problem as switching aops between two
dependent aops method calls - we don't solve anything by merging
aops and checking IS_DAX in each method because the race condition
is still there.

/me throws his hands in the air and walks away

-Dave.
--
Dave Chinner
david@xxxxxxxxxxxxx