On Tue 19-05-20 22:57:49, ira.we...@intel.com wrote:
> From: Ira Weiny <ira.we...@intel.com>
> 
> S_DAX should only be enabled when the underlying block device supports
> dax.
> 
> Change ext4_should_use_dax() to check for device support prior to the
> over riding mount option.
> 
> While we are at it change the function to ext4_should_enable_dax() as
> this better reflects the ask as well as matches xfs.
> 
> Reviewed-by: Jan Kara <j...@suse.cz>
> Signed-off-by: Ira Weiny <ira.we...@intel.com>

...

> @@ -4412,7 +4410,13 @@ static bool ext4_should_use_dax(struct inode *inode)
>               return false;
>       if (ext4_test_inode_flag(inode, EXT4_INODE_VERITY))
>               return false;
> -     return true;
> +     if (!bdev_dax_supported(inode->i_sb->s_bdev,
> +                             inode->i_sb->s_blocksize))
> +             return false;
> +     if (test_opt(inode->i_sb, DAX_ALWAYS))
> +             return true;
> +
> +     return false;
>  }

Now that I think about it - shouldn't we rather cache the result of
bdev_dax_supported() in sb on mount and then just check the flag here?
Because bdev_dax_supported() isn't exactly cheap (it does a lot of checks
and mappings, tries to read from the pmem, ...).

                                                                Honza
-- 
Jan Kara <j...@suse.com>
SUSE Labs, CR

Reply via email to