Skip to content

Commit 3bb0f28

Browse files
committed
Merge tag 'fsdax-for-5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm
Pull filesystem-dax updates from Dan Williams: - Fix handling of PMD-sized entries in the Xarray that lead to a crash scenario - Miscellaneous cleanups and small fixes * tag 'fsdax-for-5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm: dax: Flush partial PMDs correctly fs/dax: NIT fix comment regarding start/end vs range fs/dax: Convert to use vmf_error()
2 parents a840b56 + e4b3448 commit 3bb0f28

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

fs/dax.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ static void dax_entry_mkclean(struct address_space *mapping, pgoff_t index,
788788
address = pgoff_address(index, vma);
789789

790790
/*
791-
* Note because we provide start/end to follow_pte_pmd it will
791+
* Note because we provide range to follow_pte_pmd it will
792792
* call mmu_notifier_invalidate_range_start() on our behalf
793793
* before taking any lock.
794794
*/
@@ -843,9 +843,8 @@ static void dax_entry_mkclean(struct address_space *mapping, pgoff_t index,
843843
static int dax_writeback_one(struct xa_state *xas, struct dax_device *dax_dev,
844844
struct address_space *mapping, void *entry)
845845
{
846-
unsigned long pfn;
846+
unsigned long pfn, index, count;
847847
long ret = 0;
848-
size_t size;
849848

850849
/*
851850
* A page got tagged dirty in DAX mapping? Something is seriously
@@ -894,17 +893,18 @@ static int dax_writeback_one(struct xa_state *xas, struct dax_device *dax_dev,
894893
xas_unlock_irq(xas);
895894

896895
/*
897-
* Even if dax_writeback_mapping_range() was given a wbc->range_start
898-
* in the middle of a PMD, the 'index' we are given will be aligned to
899-
* the start index of the PMD, as will the pfn we pull from 'entry'.
896+
* If dax_writeback_mapping_range() was given a wbc->range_start
897+
* in the middle of a PMD, the 'index' we use needs to be
898+
* aligned to the start of the PMD.
900899
* This allows us to flush for PMD_SIZE and not have to worry about
901900
* partial PMD writebacks.
902901
*/
903902
pfn = dax_to_pfn(entry);
904-
size = PAGE_SIZE << dax_entry_order(entry);
903+
count = 1UL << dax_entry_order(entry);
904+
index = xas->xa_index & ~(count - 1);
905905

906-
dax_entry_mkclean(mapping, xas->xa_index, pfn);
907-
dax_flush(dax_dev, page_address(pfn_to_page(pfn)), size);
906+
dax_entry_mkclean(mapping, index, pfn);
907+
dax_flush(dax_dev, page_address(pfn_to_page(pfn)), count * PAGE_SIZE);
908908
/*
909909
* After we have flushed the cache, we can clear the dirty tag. There
910910
* cannot be new dirty data in the pfn after the flush has completed as
@@ -917,8 +917,7 @@ static int dax_writeback_one(struct xa_state *xas, struct dax_device *dax_dev,
917917
xas_clear_mark(xas, PAGECACHE_TAG_DIRTY);
918918
dax_wake_entry(xas, entry, false);
919919

920-
trace_dax_writeback_one(mapping->host, xas->xa_index,
921-
size >> PAGE_SHIFT);
920+
trace_dax_writeback_one(mapping->host, index, count);
922921
return ret;
923922

924923
put_unlocked:
@@ -1220,9 +1219,7 @@ static vm_fault_t dax_fault_return(int error)
12201219
{
12211220
if (error == 0)
12221221
return VM_FAULT_NOPAGE;
1223-
if (error == -ENOMEM)
1224-
return VM_FAULT_OOM;
1225-
return VM_FAULT_SIGBUS;
1222+
return vmf_error(error);
12261223
}
12271224

12281225
/*

0 commit comments

Comments
 (0)