From be675d504911ae180fe21098b65330d6267a6a8a Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sun, 7 Jan 2018 16:39:48 -0500 Subject: [PATCH] add patch pass-detailed-error-code-from-dax_iomap_fault --- pass-detailed-error-code-from-dax_iomap_fault | 120 ++++++++++++++++++++++++++ series | 1 + timestamps | 6 +- 3 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 pass-detailed-error-code-from-dax_iomap_fault diff --git a/pass-detailed-error-code-from-dax_iomap_fault b/pass-detailed-error-code-from-dax_iomap_fault new file mode 100644 index 00000000..90cf09d3 --- /dev/null +++ b/pass-detailed-error-code-from-dax_iomap_fault @@ -0,0 +1,120 @@ +dax: pass detailed error code from dax_iomap_fault() + +From: Jan Kara + +Ext4 needs to pass through error from its iomap handler to the page +fault handler so that it can properly detect ENOSPC and force +transaction commit and retry the fault (and block allocation). Add +argument to dax_iomap_fault() for passing such error. + +Reviewed-by: Ross Zwisler +Signed-off-by: Jan Kara +Signed-off-by: Theodore Ts'o +--- + fs/dax.c | 9 ++++++--- + fs/ext2/file.c | 2 +- + fs/ext4/file.c | 2 +- + fs/xfs/xfs_file.c | 2 +- + include/linux/dax.h | 2 +- + 5 files changed, 10 insertions(+), 7 deletions(-) + +diff --git a/fs/dax.c b/fs/dax.c +index 95981591977a..f3afa1d6156c 100644 +--- a/fs/dax.c ++++ b/fs/dax.c +@@ -1096,7 +1096,7 @@ static bool dax_fault_is_synchronous(unsigned long flags, + } + + static int dax_iomap_pte_fault(struct vm_fault *vmf, pfn_t *pfnp, +- const struct iomap_ops *ops) ++ int *iomap_errp, const struct iomap_ops *ops) + { + struct vm_area_struct *vma = vmf->vma; + struct address_space *mapping = vma->vm_file->f_mapping; +@@ -1149,6 +1149,8 @@ static int dax_iomap_pte_fault(struct vm_fault *vmf, pfn_t *pfnp, + * that we never have to deal with more than a single extent here. + */ + error = ops->iomap_begin(inode, pos, PAGE_SIZE, flags, &iomap); ++ if (iomap_errp) ++ *iomap_errp = error; + if (error) { + vmf_ret = dax_fault_return(error); + goto unlock_entry; +@@ -1488,6 +1490,7 @@ static int dax_iomap_pmd_fault(struct vm_fault *vmf, pfn_t *pfnp, + * @vmf: The description of the fault + * @pe_size: Size of the page to fault in + * @pfnp: PFN to insert for synchronous faults if fsync is required ++ * @iomap_errp: Storage for detailed error code in case of error + * @ops: Iomap ops passed from the file system + * + * When a page fault occurs, filesystems may call this helper in +@@ -1496,11 +1499,11 @@ static int dax_iomap_pmd_fault(struct vm_fault *vmf, pfn_t *pfnp, + * successfully. + */ + int dax_iomap_fault(struct vm_fault *vmf, enum page_entry_size pe_size, +- pfn_t *pfnp, const struct iomap_ops *ops) ++ pfn_t *pfnp, int *iomap_errp, const struct iomap_ops *ops) + { + switch (pe_size) { + case PE_SIZE_PTE: +- return dax_iomap_pte_fault(vmf, pfnp, ops); ++ return dax_iomap_pte_fault(vmf, pfnp, iomap_errp, ops); + case PE_SIZE_PMD: + return dax_iomap_pmd_fault(vmf, pfnp, ops); + default: +diff --git a/fs/ext2/file.c b/fs/ext2/file.c +index 2da67699dc33..09640220fda8 100644 +--- a/fs/ext2/file.c ++++ b/fs/ext2/file.c +@@ -100,7 +100,7 @@ static int ext2_dax_fault(struct vm_fault *vmf) + } + down_read(&ei->dax_sem); + +- ret = dax_iomap_fault(vmf, PE_SIZE_PTE, NULL, &ext2_iomap_ops); ++ ret = dax_iomap_fault(vmf, PE_SIZE_PTE, NULL, NULL, &ext2_iomap_ops); + + up_read(&ei->dax_sem); + if (vmf->flags & FAULT_FLAG_WRITE) +diff --git a/fs/ext4/file.c b/fs/ext4/file.c +index a0ae27b1bc66..1c7cd882d998 100644 +--- a/fs/ext4/file.c ++++ b/fs/ext4/file.c +@@ -314,7 +314,7 @@ static int ext4_dax_huge_fault(struct vm_fault *vmf, + } else { + down_read(&EXT4_I(inode)->i_mmap_sem); + } +- result = dax_iomap_fault(vmf, pe_size, &pfn, &ext4_iomap_ops); ++ result = dax_iomap_fault(vmf, pe_size, &pfn, NULL, &ext4_iomap_ops); + if (write) { + ext4_journal_stop(handle); + /* Handling synchronous page fault? */ +diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c +index 8601275cc5e6..9ea08326f876 100644 +--- a/fs/xfs/xfs_file.c ++++ b/fs/xfs/xfs_file.c +@@ -1048,7 +1048,7 @@ __xfs_filemap_fault( + if (IS_DAX(inode)) { + pfn_t pfn; + +- ret = dax_iomap_fault(vmf, pe_size, &pfn, &xfs_iomap_ops); ++ ret = dax_iomap_fault(vmf, pe_size, &pfn, NULL, &xfs_iomap_ops); + if (ret & VM_FAULT_NEEDDSYNC) + ret = dax_finish_sync_fault(vmf, pe_size, pfn); + } else { +diff --git a/include/linux/dax.h b/include/linux/dax.h +index 5258346c558c..0185ecdae135 100644 +--- a/include/linux/dax.h ++++ b/include/linux/dax.h +@@ -96,7 +96,7 @@ bool dax_write_cache_enabled(struct dax_device *dax_dev); + ssize_t dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter, + const struct iomap_ops *ops); + int dax_iomap_fault(struct vm_fault *vmf, enum page_entry_size pe_size, +- pfn_t *pfnp, const struct iomap_ops *ops); ++ pfn_t *pfnp, int *errp, const struct iomap_ops *ops); + int dax_finish_sync_fault(struct vm_fault *vmf, enum page_entry_size pe_size, + pfn_t pfn); + int dax_delete_mapping_entry(struct address_space *mapping, pgoff_t index); +-- +2.12.3 + + diff --git a/series b/series index 28cdbcf9..bd59b5a4 100644 --- a/series +++ b/series @@ -3,6 +3,7 @@ spdx-cleanups mbcache-initialize-e_referenced-in-mb_cache_entry_create revert-mbcache-make-count_objects-more-robust +pass-detailed-error-code-from-dax_iomap_fault #################################################### # unstable patches diff --git a/timestamps b/timestamps index 204b8397..fc7681e1 100755 --- a/timestamps +++ b/timestamps @@ -34,7 +34,9 @@ touch -d @1512353611 disable-writeback touch -d @1512353785 add-ext4-journal-lazy-mount-option touch -d @1513566059 spdx-cleanups touch -d @1513566119 stable-boundary -touch -d @1515359234 series touch -d @1515360155 mbcache-initialize-e_referenced-in-mb_cache_entry_create -touch -d @1515360163 status touch -d @1515360173 timestamps +touch -d @1515360920 revert-mbcache-make-count_objects-more-robust +touch -d @1515361123 pass-detailed-error-code-from-dax_iomap_fault +touch -d @1515361138 series +touch -d @1515361143 status -- 2.11.4.GIT