Web lists-archives.com

Talking about loop devices (was: Re: Partition information as text file?)




On Thu, 31 Jan 2019 at 02:52, <tomas@xxxxxxxxxx> wrote:
>
> [...]
>
>    A plain regular file can be made available as a device
>    via the loopback driver

I have a small addition to this excellent message.

There is very widespread mixup of the terms "loopback"
and "loop" in the context of block devices.

I've written about this in the past here. I will do my best to be
correct, and give evidence, although
1) I wish I had more evidence
2) I can't remember when I first became aware of this
3) I have very little knowledge of kernel development ...

A *loop* device is a *filesystem* technique to make a file
accessible as a block device.

Whereas a *loopback* device is a virtual *network* interface.

The word "loopback" does not appear in 'man mount'.

https://en.wikipedia.org/wiki/Loop_device says:
"Sometimes, the loop device is erroneously referred to as loopback device,
but this term is reserved for a networking device in operating systems."

Unfortunately I cannot remember where this first came to my
attention, so I can't provide a better authoritative reference.
There must be one in existence out there somewhere, because
I'm certain I didn't invent this myself, so I must have read about
it somewhere.

And I vaguely recall reading that some attempts were made to correct
this in the kernel source. Today I tried to find some evidence of that ...

For example, back in 2005 (linux 2.6.12) says:
https://github.com/torvalds/linux/commit/1da177e4c3f41524e886b7f1b8a0c1fc7321cac2

----- begin quote -----
7 block Loopback devices
0 = /dev/loop0 First loopback device
1 = /dev/loop1 Second loopback device
...
The loopback devices are used to mount filesystems not
associated with block devices. The binding to the
loopback devices is handled by mount(8) or losetup(8).
----- end quote -----

"loopback" is everywhere there!

Compare with today's version:
https://github.com/torvalds/linux/blob/v4.19/Documentation/admin-guide/devices.txt#L191

----- begin quote -----
7 block Loopback devices
0 = /dev/loop0 First loop device
1 = /dev/loop1 Second loop device
...
The loop devices are used to mount filesystems not
associated with block devices. The binding to the
loop devices is handled by mount(8) or losetup(8).
----- end quote -----

So all but one instance has changed from "loopback" to
"loop" ... maybe someone did a case-sensitive search/replace? :)

Searching the kernel source for the word "loopback" here:
https://livegrep.com/search/linux?q=loopback&fold_case=auto&regex=false&context=false
shows that, when referring to block devices, the word
"loopback" only appears in documentation here and there,
never in code.

The actual driver code is here:
https://github.com/torvalds/linux/blob/v4.19/drivers/block/loop.c

$ grep -c -i loopback loop.c
2
$ grep -c -i loop loop.c
343

The concept of "loopback" doesn't seem relevant to
a loop device. It's just a filesystem in a file, isn't it?
I suppose that's a slightly recursive concept,
but it's not circular like a loop. To me, the word "loopback"
suggests that something is going around and coming
back again. I don't see how that is relevant to a loop
device.

Comments welcome. Maybe Ted Ts'o will read this and
enlighten us (me).