提交 bd85b796 编写于 作者: P Pankaj Gupta 提交者: Shile Zhang

dax: check synchronous mapping is supported

fix #27138800

commit 32de1484648a837db5dea0a7007fe7136804e392 upstream.

This patch introduces 'daxdev_mapping_supported' helper
which checks if 'MAP_SYNC' is supported with filesystem
mapping. It also checks if corresponding dax_device is
synchronous. Virtio pmem device is asynchronous and
does not not support VM_SYNC.
Suggested-by: NJan Kara <jack@suse.cz>
Signed-off-by: NPankaj Gupta <pagupta@redhat.com>
Reviewed-by: NJan Kara <jack@suse.cz>
Signed-off-by: NDan Williams <dan.j.williams@intel.com>
Reviewed-by: NYang Shi <yang.shi@linux.alibaba.com>
Signed-off-by: NXunlei Pang <xlpang@linux.alibaba.com>
上级 b6f6b2d6
...@@ -48,6 +48,18 @@ static inline void set_dax_synchronous(struct dax_device *dax_dev) ...@@ -48,6 +48,18 @@ static inline void set_dax_synchronous(struct dax_device *dax_dev)
{ {
__set_dax_synchronous(dax_dev); __set_dax_synchronous(dax_dev);
} }
/*
* Check if given mapping is supported by the file / underlying device.
*/
static inline bool daxdev_mapping_supported(struct vm_area_struct *vma,
struct dax_device *dax_dev)
{
if (!(vma->vm_flags & VM_SYNC))
return true;
if (!IS_DAX(file_inode(vma->vm_file)))
return false;
return dax_synchronous(dax_dev);
}
#else #else
static inline struct dax_device *dax_get_by_host(const char *host) static inline struct dax_device *dax_get_by_host(const char *host)
{ {
...@@ -82,6 +94,11 @@ static inline bool dax_synchronous(struct dax_device *dax_dev) ...@@ -82,6 +94,11 @@ static inline bool dax_synchronous(struct dax_device *dax_dev)
static inline void set_dax_synchronous(struct dax_device *dax_dev) static inline void set_dax_synchronous(struct dax_device *dax_dev)
{ {
} }
static inline bool daxdev_mapping_supported(struct vm_area_struct *vma,
struct dax_device *dax_dev)
{
return !(vma->vm_flags & VM_SYNC);
}
#endif #endif
struct writeback_control; struct writeback_control;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册