@@ -2293,6 +2293,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)
@@ -4116,6 +4116,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)
@@ -2354,6 +2354,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)
@@ -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,
@@ -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)
@@ -146,6 +146,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)
@@ -641,6 +641,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)
@@ -3226,6 +3226,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 */
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> --- fs/btrfs/file.c | 1 + fs/cifs/file.c | 1 + fs/fuse/file.c | 1 + fs/nfs/file.c | 1 + fs/ubifs/file.c | 1 + fs/vboxsf/file.c | 1 + include/linux/mm.h | 7 +++++++ mm/filemap.c | 1 + 8 files changed, 14 insertions(+)