Re: [PATCH] the dm-loop target

Mikulas Patocka
2025-03-03T21:04:14Z

On Mon, 3 Mar 2025, Christoph Hellwig wrote:

> On Mon, Mar 03, 2025 at 05:16:48PM +0100, Mikulas Patocka wrote:
> > What should I use instead of bmap? Is fiemap exported for use in the
> > kernel?
>
> You can't do an ahead of time mapping. It's a broken concept.

Swapfile does ahead of time mapping. 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?

> > Would Jens Axboe agree to merge the dm-loop logic into the existing loop
> > driver?
>
> What logic?

The ahead-of-time mapping.

> > Dm-loop is significantly faster than the regular loop:
> >
> > # modprobe brd rd_size=1048576
> > # dd if=/dev/zero of=/dev/ram0 bs=1048576
> > # mkfs.ext4 /dev/ram0
> > # mount -t ext4 /dev/ram0 /mnt/test
> > # dd if=/dev/zero of=/mnt/test/test bs=1048576 count=512
>
> All of this needs to be in a commit log. Also note that the above:
>
> a) does not use direct I/O which any sane loop user should
> b) is not on a file but a block device, rendering the use of a loop
> device entirely pointless.

With "losetup --direct-io=on /dev/loop0 /mnt/test/test", it is even slower
than without:

READ: bw=217MiB/s (227MB/s), 217MiB/s-217MiB/s (227MB/s-227MB/s), io=2170MiB (2275MB), run=10003-10003msec
WRITE: bw=217MiB/s (227MB/s), 217MiB/s-217MiB/s (227MB/s-227MB/s), io=2169MiB (2274MB), run=10003-10003msec

with --direct-io=off

READ: bw=398MiB/s (417MB/s), 398MiB/s-398MiB/s (417MB/s-417MB/s), io=3978MiB (4171MB), run=10003-10003msec
WRITE: bw=398MiB/s (417MB/s), 398MiB/s-398MiB/s (417MB/s-417MB/s), io=3981MiB (4175MB), run=10003-10003msec

Mikulas