aboutsummaryrefslogtreecommitdiffstats
path: root/fs/dax.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/dax.c')
-rw-r--r--fs/dax.c46
1 files changed, 19 insertions, 27 deletions
diff --git a/fs/dax.c b/fs/dax.c
index 5ea71381dba0..5b20c6456926 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -858,32 +858,6 @@ out:
858 return rc; 858 return rc;
859} 859}
860 860
861static int dax_insert_mapping(struct vm_fault *vmf, struct iomap *iomap,
862 loff_t pos, void *entry)
863{
864 const sector_t sector = dax_iomap_sector(iomap, pos);
865 struct vm_area_struct *vma = vmf->vma;
866 struct address_space *mapping = vma->vm_file->f_mapping;
867 unsigned long vaddr = vmf->address;
868 void *ret;
869 int rc;
870 pfn_t pfn;
871
872 rc = dax_iomap_pfn(iomap, pos, PAGE_SIZE, &pfn);
873 if (rc < 0)
874 return rc;
875
876 ret = dax_insert_mapping_entry(mapping, vmf, entry, sector, 0);
877 if (IS_ERR(ret))
878 return PTR_ERR(ret);
879
880 trace_dax_insert_mapping(mapping->host, vmf, ret);
881 if (vmf->flags & FAULT_FLAG_WRITE)
882 return vm_insert_mixed_mkwrite(vma, vaddr, pfn);
883 else
884 return vm_insert_mixed(vma, vaddr, pfn);
885}
886
887/* 861/*
888 * The user has performed a load from a hole in the file. Allocating a new 862 * The user has performed a load from a hole in the file. Allocating a new
889 * page in the file would cause excessive storage usage for workloads with 863 * page in the file would cause excessive storage usage for workloads with
@@ -1119,6 +1093,7 @@ static int dax_iomap_pte_fault(struct vm_fault *vmf,
1119 bool write = vmf->flags & FAULT_FLAG_WRITE; 1093 bool write = vmf->flags & FAULT_FLAG_WRITE;
1120 int vmf_ret = 0; 1094 int vmf_ret = 0;
1121 void *entry; 1095 void *entry;
1096 pfn_t pfn;
1122 1097
1123 trace_dax_pte_fault(inode, vmf, vmf_ret); 1098 trace_dax_pte_fault(inode, vmf, vmf_ret);
1124 /* 1099 /*
@@ -1201,7 +1176,24 @@ static int dax_iomap_pte_fault(struct vm_fault *vmf,
1201 count_memcg_event_mm(vma->vm_mm, PGMAJFAULT); 1176 count_memcg_event_mm(vma->vm_mm, PGMAJFAULT);
1202 major = VM_FAULT_MAJOR; 1177 major = VM_FAULT_MAJOR;
1203 } 1178 }
1204 error = dax_insert_mapping(vmf, &iomap, pos, entry); 1179 error = dax_iomap_pfn(&iomap, pos, PAGE_SIZE, &pfn);
1180 if (error < 0)
1181 goto error_finish_iomap;
1182
1183 entry = dax_insert_mapping_entry(mapping, vmf, entry,
1184 dax_iomap_sector(&iomap, pos),
1185 0);
1186 if (IS_ERR(entry)) {
1187 error = PTR_ERR(entry);
1188 goto error_finish_iomap;
1189 }
1190
1191 trace_dax_insert_mapping(inode, vmf, entry);
1192 if (write)
1193 error = vm_insert_mixed_mkwrite(vma, vaddr, pfn);
1194 else
1195 error = vm_insert_mixed(vma, vaddr, pfn);
1196
1205 /* -EBUSY is fine, somebody else faulted on the same PTE */ 1197 /* -EBUSY is fine, somebody else faulted on the same PTE */
1206 if (error == -EBUSY) 1198 if (error == -EBUSY)
1207 error = 0; 1199 error = 0;