Re: [PATCH V2 2/7] dax/fsdev: fix multi-range offset, vmemmap_shift leak, and probe error cleanup
From: John Groves
Date: Fri May 29 2026 - 20:00:04 EST
On 26/05/26 04:22PM, Dave Jiang wrote:
>
>
> On 5/22/26 12:18 PM, John Groves wrote:
> > From: John Groves <John@xxxxxxxxxx>
> >
> > Three fixes for fsdev.c:
> >
> > 1. Fix memory_failure offset calculation for multi-range devices.
> > The old code subtracted ranges[0].range.start from the faulting PFN's
> > physical address, which produces an incorrect (inflated) logical offset
> > when the PFN falls in ranges[1] or beyond due to physical gaps between
> > ranges. Add fsdev_pfn_to_offset() to walk the range list and compute
> > the correct device-linear byte offset.
> >
> > 2. Clear pgmap->vmemmap_shift for static DAX devices. When rebinding a
> > static device from device_dax (which may set vmemmap_shift based on
> > alignment) to fsdev_dax, the stale vmemmap_shift persists on the
> > shared pgmap. Explicitly zero it before devm_memremap_pages() so the
> > vmemmap is built for order-0 folios as fsdev requires.
> >
> > 3. Clear dev_dax->pgmap on probe failure for dynamic devices. After the
> > dynamic path sets dev_dax->pgmap, if a later probe step fails, devres
> > frees the devm_kzalloc'd pgmap but leaves dev_dax->pgmap dangling.
> > Subsequent probe attempts would hit the "dynamic-dax with pre-populated
> > page map" check and fail permanently. Use a goto cleanup to NULL
> > dev_dax->pgmap on error.
>
> 3 fixes, 3 separate patches?
>
> DJ
Yes, thanks. Done.
John
<snip>