Mathieu Desnoyers wrote:
> Replace the following fs/Kconfig:FS_DAX dependency:
> 
>   depends on !(ARM || MIPS || SPARC)
> 
> By a runtime check within alloc_dax().
> 
> This is done in preparation for its use by each filesystem supporting
> the "dax" mount option to validate whether DAX is indeed supported.
> 
> This is done in preparation for using cpu_dcache_is_aliasing() in a
> following change which will properly support architectures which detect
> data cache aliasing at runtime.
> 
> Fixes: d92576f1167c ("dax: does not work correctly with virtual aliasing 
> caches")
> Signed-off-by: Mathieu Desnoyers <[email protected]>
> Cc: Andrew Morton <[email protected]>
> Cc: Linus Torvalds <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Cc: Dan Williams <[email protected]>
> Cc: Vishal Verma <[email protected]>
> Cc: Dave Jiang <[email protected]>
> Cc: Matthew Wilcox <[email protected]>
> Cc: Arnd Bergmann <[email protected]>
> Cc: Russell King <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> ---
>  drivers/dax/super.c | 6 ++++++
>  fs/Kconfig          | 1 -
>  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/dax/super.c b/drivers/dax/super.c
> index 0da9232ea175..e9f397b8a5a3 100644
> --- a/drivers/dax/super.c
> +++ b/drivers/dax/super.c
> @@ -445,6 +445,12 @@ struct dax_device *alloc_dax(void *private, const struct 
> dax_operations *ops)
>       dev_t devt;
>       int minor;
>  
> +     /* Unavailable on architectures with virtually aliased data caches. */
> +     if (IS_ENABLED(CONFIG_ARM) ||
> +         IS_ENABLED(CONFIG_MIPS) ||
> +         IS_ENABLED(CONFIG_SPARC))
> +             return NULL;

This function returns ERR_PTR(), not NULL on failure.

...and I notice this mistake is also made in include/linux/dax.h in the
CONFIG_DAX=n case. That function also mentions:

    static inline struct dax_device *alloc_dax(void *private,
                    const struct dax_operations *ops)
    {
            /*
             * Callers should check IS_ENABLED(CONFIG_DAX) to know if this
             * NULL is an error or expected.
             */     
            return NULL;
    }               

...and none of the callers validate the result, but now runtime
validation is necessary. I.e. it is not enough to check
IS_ENABLED(CONFIG_DAX) it also needs to check cpu_dcache_is_aliasing().

With that, there are a few more fixup places needed, pmem_attach_disk(),
dcssblk_add_store(), and virtio_fs_setup_dax().

Reply via email to