Re: [PATCH] the dm-loop target

Kent Overstreet
2025-03-12T13:27:01Z

On Tue, Mar 04, 2025 at 05:49:51AM -0800, Christoph Hellwig wrote:
> On Mon, Mar 03, 2025 at 10:03:42PM +0100, Mikulas Patocka wrote:
> > Swapfile does ahead of time mapping.
>
> It does. But it is:
>
> a) protected against modification by the S_SWAPFILE flag and checked
> for full allocation first
> b) something we want to get rid of because even with the above it is
> rather problematic
>
> > And I just looked at what swapfile
> > does and copied the logic into dm-loop. If swapfile is not broken, how
> > could dm-loop be broken?
>
> As said above, swapfile works around the brokenness in ways that you
> can't. And just blindly copying old code without understanding it is
> never a good idea.
>
> >
> > > > Would Jens Axboe agree to merge the dm-loop logic into the existing loop
> > > > driver?
> > >
> > > What logic?
> >
> > The ahead-of-time mapping.
>
> As said multiple times you can't do that. The block mapping is
> file system private information.

We might be able to provide an API to _request_ a stable mapping to a
file - with proper synchronization, of course.

I don't recall anyone ever trying that, it'd replace all the weird
IF_SWAPFILE() hacks and be a safe way to do these kinds of performance
optimizations.