On Mon, 3 Mar 2025, Christoph Hellwig wrote:
> On Mon, Mar 03, 2025 at 11:24:27AM +0100, Mikulas Patocka wrote:
> > This is the dm-loop target - a replacement for the regular loop driver
> > with better performance. The dm-loop target builds a map of the file in
> > the constructor and it just remaps bios according to this map.
>
> Using ->bmap is broken and a no-go for new code.
What should I use instead of bmap? Is fiemap exported for use in the
kernel?
ext4_bmap flushes the journal if journaled data are used. Is there some
equivalent function that would provide the same guarantee w.r.t. journaled
data?
> If you have any real
> performance issues with the loop driver document and report them so that
> they can be fixed instead of working around them by duplicating the code
> (and in this case making the new code completely broken).
Would Jens Axboe agree to merge the dm-loop logic into the existing loop
driver?
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
dm-loop (on /mnt/test/test):
# dmsetup create loop --table '0 1048576 loop /mnt/test/test 0'
# fio --direct=1 --bs=4k --runtime=10 --time_based --numjobs=16
--ioengine=psync --iodepth=1 --group_reporting=1
--filename=/dev/mapper/loop --name=job --rw=rw
READ: bw=2428MiB/s (2546MB/s), 2428MiB/s-2428MiB/s (2546MB/s-2546MB/s),
io=23.7GiB (25.5GB), run=10001-10001msec
WRITE: bw=2429MiB/s (2547MB/s), 2429MiB/s-2429MiB/s (2547MB/s-2547MB/s),
io=23.7GiB (25.5GB), run=10001-10001msec
regular loop (on /mnt/test/test):
# losetup /dev/loop0 /mnt/test/test
# fio --direct=1 --bs=4k --runtime=10 --time_based --numjobs=16
--ioengine=psync --iodepth=1 --group_reporting=1 --filename=/dev/loop0
--name=job --rw=rw
READ: bw=326MiB/s (342MB/s), 326MiB/s-326MiB/s (342MB/s-342MB/s), io=3259MiB
(3417MB), run=10003-10003msec
WRITE: bw=326MiB/s (342MB/s), 326MiB/s-326MiB/s (342MB/s-342MB/s), io=3260MiB
(3418MB), run=10003-10003msec
dm-loop is even slightly faster than running fio directly on the regular
file:
# fio --direct=1 --bs=4k --runtime=10 --time_based --numjobs=16
--ioengine=psync --iodepth=1 --group_reporting=1 --filename=/mnt/test/test
--name=job --rw=rw
READ: bw=2005MiB/s (2103MB/s), 2005MiB/s-2005MiB/s (2103MB/s-2103MB/s),
io=19.6GiB (21.0GB), run=10002-10002msec
WRITE: bw=2007MiB/s (2104MB/s), 2007MiB/s-2007MiB/s (2104MB/s-2104MB/s),
io=19.6GiB (21.0GB), run=10002-10002msec
Mikulas