Skip to content

Commit 302a5e3

Browse files
jankaradjbw
authored andcommitted
dax: Inline dax_pmd_insert_mapping() into the callsite
dax_pmd_insert_mapping() has only one callsite and we will need to further fine tune what it does for synchronous faults. Just inline it into the callsite so that we don't have to pass awkward bools around. Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com> Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 1b5a1cb commit 302a5e3

File tree

2 files changed

+19
-29
lines changed

2 files changed

+19
-29
lines changed

fs/dax.c

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,33 +1235,11 @@ static int dax_iomap_pte_fault(struct vm_fault *vmf,
12351235
}
12361236

12371237
#ifdef CONFIG_FS_DAX_PMD
1238-
static int dax_pmd_insert_mapping(struct vm_fault *vmf, struct iomap *iomap,
1239-
loff_t pos, void *entry)
1240-
{
1241-
struct address_space *mapping = vmf->vma->vm_file->f_mapping;
1242-
const sector_t sector = dax_iomap_sector(iomap, pos);
1243-
struct inode *inode = mapping->host;
1244-
void *ret = NULL;
1245-
pfn_t pfn = {};
1246-
int rc;
1247-
1248-
rc = dax_iomap_pfn(iomap, pos, PMD_SIZE, &pfn);
1249-
if (rc < 0)
1250-
goto fallback;
1251-
1252-
ret = dax_insert_mapping_entry(mapping, vmf, entry, sector,
1253-
RADIX_DAX_PMD);
1254-
if (IS_ERR(ret))
1255-
goto fallback;
1256-
1257-
trace_dax_pmd_insert_mapping(inode, vmf, PMD_SIZE, pfn, ret);
1258-
return vmf_insert_pfn_pmd(vmf->vma, vmf->address, vmf->pmd,
1259-
pfn, vmf->flags & FAULT_FLAG_WRITE);
1260-
1261-
fallback:
1262-
trace_dax_pmd_insert_mapping_fallback(inode, vmf, PMD_SIZE, pfn, ret);
1263-
return VM_FAULT_FALLBACK;
1264-
}
1238+
/*
1239+
* The 'colour' (ie low bits) within a PMD of a page offset. This comes up
1240+
* more often than one might expect in the below functions.
1241+
*/
1242+
#define PG_PMD_COLOUR ((PMD_SIZE >> PAGE_SHIFT) - 1)
12651243

12661244
static int dax_pmd_load_hole(struct vm_fault *vmf, struct iomap *iomap,
12671245
void *entry)
@@ -1317,6 +1295,7 @@ static int dax_iomap_pmd_fault(struct vm_fault *vmf,
13171295
void *entry;
13181296
loff_t pos;
13191297
int error;
1298+
pfn_t pfn;
13201299

13211300
/*
13221301
* Check whether offset isn't beyond end of file now. Caller is
@@ -1394,7 +1373,19 @@ static int dax_iomap_pmd_fault(struct vm_fault *vmf,
13941373

13951374
switch (iomap.type) {
13961375
case IOMAP_MAPPED:
1397-
result = dax_pmd_insert_mapping(vmf, &iomap, pos, entry);
1376+
error = dax_iomap_pfn(&iomap, pos, PMD_SIZE, &pfn);
1377+
if (error < 0)
1378+
goto finish_iomap;
1379+
1380+
entry = dax_insert_mapping_entry(mapping, vmf, entry,
1381+
dax_iomap_sector(&iomap, pos),
1382+
RADIX_DAX_PMD);
1383+
if (IS_ERR(entry))
1384+
goto finish_iomap;
1385+
1386+
trace_dax_pmd_insert_mapping(inode, vmf, PMD_SIZE, pfn, entry);
1387+
result = vmf_insert_pfn_pmd(vma, vmf->address, vmf->pmd, pfn,
1388+
write);
13981389
break;
13991390
case IOMAP_UNWRITTEN:
14001391
case IOMAP_HOLE:

include/trace/events/fs_dax.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ DEFINE_EVENT(dax_pmd_insert_mapping_class, name, \
148148
TP_ARGS(inode, vmf, length, pfn, radix_entry))
149149

150150
DEFINE_PMD_INSERT_MAPPING_EVENT(dax_pmd_insert_mapping);
151-
DEFINE_PMD_INSERT_MAPPING_EVENT(dax_pmd_insert_mapping_fallback);
152151

153152
DECLARE_EVENT_CLASS(dax_pte_fault_class,
154153
TP_PROTO(struct inode *inode, struct vm_fault *vmf, int result),

0 commit comments

Comments
 (0)