Now that the dax-mapping-entry code has moved to a common location take the opportunity to fixup some long standing sparse warnings. In this case conveying vm_fault_t codes through Xarray internal values was missing some forced casts. Add some helpers, is_dax_err(), dax_err_to_vmfault(), and vmfault_to_dax_err() to handle the conversions. Fixes: drivers/dax/mapping.c:637:39: sparse: warning: incorrect type in argument 1 (different base types) drivers/dax/mapping.c:637:39: sparse: expected unsigned long v drivers/dax/mapping.c:637:39: sparse: got restricted vm_fault_t drivers/dax/mapping.c:639:39: sparse: warning: incorrect type in argument 1 (different base types) drivers/dax/mapping.c:639:39: sparse: expected unsigned long v drivers/dax/mapping.c:639:39: sparse: got restricted vm_fault_t drivers/dax/mapping.c:643:31: sparse: warning: incorrect type in argument 1 (different base types) drivers/dax/mapping.c:643:31: sparse: expected unsigned long v drivers/dax/mapping.c:643:31: sparse: got restricted vm_fault_t Reported-by: Reported-by: kernel test robot <lkp@xxxxxxxxx> Link: http://lore.kernel.org/r/202210091141.cHaQEuCs-lkp@xxxxxxxxx Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx> --- drivers/dax/mapping.c | 6 +++--- fs/dax.c | 8 ++++---- include/linux/dax.h | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/drivers/dax/mapping.c b/drivers/dax/mapping.c index 803ae64c13d4..b452bfa98f5e 100644 --- a/drivers/dax/mapping.c +++ b/drivers/dax/mapping.c @@ -634,13 +634,13 @@ void *dax_grab_mapping_entry(struct xa_state *xas, if (xas_nomem(xas, mapping_gfp_mask(mapping) & ~__GFP_HIGHMEM)) goto retry; if (xas->xa_node == XA_ERROR(-ENOMEM)) - return xa_mk_internal(VM_FAULT_OOM); + return vmfault_to_dax_err(VM_FAULT_OOM); if (xas_error(xas)) - return xa_mk_internal(VM_FAULT_SIGBUS); + return vmfault_to_dax_err(VM_FAULT_SIGBUS); return entry; fallback: xas_unlock_irq(xas); - return xa_mk_internal(VM_FAULT_FALLBACK); + return vmfault_to_dax_err(VM_FAULT_FALLBACK); } static void *dax_zap_entry(struct xa_state *xas, void *entry) diff --git a/fs/dax.c b/fs/dax.c index de79dd132e22..dc1dcbaeba05 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -707,8 +707,8 @@ static vm_fault_t dax_iomap_pte_fault(struct vm_fault *vmf, pfn_t *pfnp, iter.flags |= IOMAP_WRITE; entry = dax_grab_mapping_entry(&xas, mapping, 0); - if (xa_is_internal(entry)) { - ret = xa_to_internal(entry); + if (is_dax_err(entry)) { + ret = dax_err_to_vmfault(entry); goto out; } @@ -829,8 +829,8 @@ static vm_fault_t dax_iomap_pmd_fault(struct vm_fault *vmf, pfn_t *pfnp, * VM_FAULT_FALLBACK. */ entry = dax_grab_mapping_entry(&xas, mapping, PMD_ORDER); - if (xa_is_internal(entry)) { - ret = xa_to_internal(entry); + if (is_dax_err(entry)) { + ret = dax_err_to_vmfault(entry); goto fallback; } diff --git a/include/linux/dax.h b/include/linux/dax.h index 1fc3d79b6aec..553bc819a6a4 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -264,6 +264,22 @@ vm_fault_t dax_iomap_fault(struct vm_fault *vmf, enum page_entry_size pe_size, pfn_t *pfnp, int *errp, const struct iomap_ops *ops); vm_fault_t dax_finish_sync_fault(struct vm_fault *vmf, enum page_entry_size pe_size, pfn_t pfn); + +static inline bool is_dax_err(void *entry) +{ + return xa_is_internal(entry); +} + +static inline vm_fault_t dax_err_to_vmfault(void *entry) +{ + return (vm_fault_t __force)(xa_to_internal(entry)); +} + +static inline void *vmfault_to_dax_err(vm_fault_t error) +{ + return xa_mk_internal((unsigned long __force)error); +} + void *dax_grab_mapping_entry(struct xa_state *xas, struct address_space *mapping, unsigned int order); void dax_unlock_entry(struct xa_state *xas, void *entry);