Commit graph

7 commits

Author SHA1 Message Date
Christian Kellner
43ae79cabf devices/loopback: set partscan to false
Pass "partscan=False" to `LoopControl.loop_for_fd` to ensure that the
kernel does indeed not try to scan the partition table for the device.
2021-08-11 20:59:51 +02:00
Christian Kellner
6293da5874 devices/loopback: use new loop_for_fd helper
Use the new `LoopControl.loop_for_fd` helper, which is basically
a modified version of the existing code in `make_loop`.
2021-08-11 20:59:51 +02:00
Christian Kellner
3d08e84ceb devices/loopback: close loop device controller
In the `close` method of the device also close the loop controller.
2021-08-11 20:59:51 +02:00
Christian Kellner
c8427c392e devices/loopback:
Getting unbound loop devices is racy, so we do it in a retry loop:
in case of a recoverable error, like when the loop device signals
it is busy, we close the it and try another one. Indeed the code,
closed the loop device but did in fact not open a new one and we
would therefore see file descriptor cannot be a negative integer
errors when trying in `lo.set_fd(fd)` since `lo` is in fact closed
now and thus indeed '-1'.
Open a new loop device at the beginning of the retry-loop to fix
this issue.
2021-07-30 11:12:05 +02:00
Christian Kellner
b4c571ad87 devices/loopback: add some info message
Show the file descriptor that was opened for the file passed to
the device. Recently, in CI, we have seen errors opening the
loop device with `fd` being `-1` and this ensures that at least
the file itself could be opened.
2021-07-22 15:23:39 +02:00
Christian Kellner
83fc64c565 devices/loopback: since file on close
On rare occasions, when trying to mount a file system via the
loopback device that was created in the stage before the mount
fails with `wrong fs type, bad option, bad superblock on ...`.
It is not yet fully clear why this appears since in theory the
kernel should handle the sequence of operations we do, but it
might be down to the caching or bugs in the underlying file-
system.
To mitigate with potential caching issue we therefore now sync
the file that is backing the loopback device after the device
has been closed. In order to not have to re-open the file we
keep the file descriptor around as long as the loopback device
is open.
2021-07-07 17:24:58 +01:00
Christian Kellner
3085114ed7 devices: add support for loopback devices
Device service that provides support for bind files within the tree
to loopback devices. Valid parameters are the `filename`, `offset`
and `size`. This controls what part of the file to bind to the loop
device. The unit for `size` and `offset` is sectors and the sector
size can be configured via the `sector-size` parameter. The reason
behind the sector unit is so that numbers can easily be compared
with those specified in the partition table.
2021-06-09 18:37:47 +01:00