FROMLIST: fs: list file types that support speculative faults.

Add a speculative field to the vm_operations_struct, which indicates if
the associated file type supports speculative faults.

Initially this is set for files that implement fault() with filemap_fault().

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20210407014502.24091-30-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ic92efdf13283c45e7da7bf703f4f85f8b392ba69
This commit is contained in:
Michel Lespinasse
2021-04-29 10:28:25 -07:00
committed by Todd Kjos
parent 4979ff3738
commit a2138fee6c
8 changed files with 14 additions and 0 deletions

View File

@@ -2315,6 +2315,7 @@ static const struct vm_operations_struct btrfs_file_vm_ops = {
.fault = filemap_fault,
.map_pages = filemap_map_pages,
.page_mkwrite = btrfs_page_mkwrite,
.speculative = true,
};
static int btrfs_file_mmap(struct file *filp, struct vm_area_struct *vma)

View File

@@ -4211,6 +4211,7 @@ static const struct vm_operations_struct cifs_file_vm_ops = {
.fault = filemap_fault,
.map_pages = filemap_map_pages,
.page_mkwrite = cifs_page_mkwrite,
.speculative = true,
};
int cifs_file_strict_mmap(struct file *file, struct vm_area_struct *vma)

View File

@@ -2402,6 +2402,7 @@ static const struct vm_operations_struct fuse_file_vm_ops = {
.fault = filemap_fault,
.map_pages = filemap_map_pages,
.page_mkwrite = fuse_page_mkwrite,
.speculative = true,
};
static int fuse_file_mmap(struct file *file, struct vm_area_struct *vma)

View File

@@ -588,6 +588,7 @@ static const struct vm_operations_struct nfs_file_vm_ops = {
.fault = filemap_fault,
.map_pages = filemap_map_pages,
.page_mkwrite = nfs_vm_page_mkwrite,
.speculative = true,
};
static int nfs_need_check_write(struct file *filp, struct inode *inode,

View File

@@ -1598,6 +1598,7 @@ static const struct vm_operations_struct ubifs_file_vm_ops = {
.fault = filemap_fault,
.map_pages = filemap_map_pages,
.page_mkwrite = ubifs_vm_page_mkwrite,
.speculative = true,
};
static int ubifs_file_mmap(struct file *file, struct vm_area_struct *vma)

View File

@@ -163,6 +163,7 @@ static const struct vm_operations_struct vboxsf_file_vm_ops = {
.close = vboxsf_vma_close,
.fault = filemap_fault,
.map_pages = filemap_map_pages,
.speculative = true,
};
static int vboxsf_file_mmap(struct file *file, struct vm_area_struct *vma)

View File

@@ -663,6 +663,13 @@ struct vm_operations_struct {
*/
struct page *(*find_special_page)(struct vm_area_struct *vma,
unsigned long addr);
/*
* speculative indicates that the vm_operations support
* speculative page faults. This allows ->fault and ->map_pages
* to be called with FAULT_FLAG_SPECULATIVE set; such calls will
* run within an rcu read locked section and with mmap lock not held.
*/
bool speculative;
};
static inline void vma_init(struct vm_area_struct *vma, struct mm_struct *mm)

View File

@@ -3425,6 +3425,7 @@ const struct vm_operations_struct generic_file_vm_ops = {
.fault = filemap_fault,
.map_pages = filemap_map_pages,
.page_mkwrite = filemap_page_mkwrite,
.speculative = true,
};
/* This is used for a general mmap of a disk file */