]> git.ipfire.org Git - thirdparty/util-linux.git/commit
lib/loopdev.c: Retry LOOP_SET_STATUS64 on EAGAIN
authorRomain Izard <romain.izard.pro@gmail.com>
Fri, 3 May 2019 13:42:22 +0000 (15:42 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 7 May 2019 10:36:00 +0000 (12:36 +0200)
commiteab90ef8d4f66394285e0cff1dfc0a27242c05aa
tree0c9e4d872f20811c9a091d1ab4162efa8337faae
parent47b6eccc972a5433ac8b293eb2bf07d074f5bbf7
lib/loopdev.c: Retry LOOP_SET_STATUS64 on EAGAIN

A recent bugfix in the Linux kernel made it possible for the
LOOP_SET_STATUS64 ioctl to fail when called with a non-zero offset,
with an EAGAIN errno:

5db470e229e2 loop: drop caches if offset or block_size are changed

This fix changes a silent failure (where mount could sometimes access
the backing loop image through the cache without the specified offset)
to an explicit failure, and it has also been backported on stable
branches.

On a 5.0 kernel, other changes to the loop driver make it hard to get
generate the EAGAIN error, but this bugfix has also been backported to
stables branches, without these changes. At least with the 4.14 stable
branch, the EAGAIN error can be quickly generated with the following loop:

while mount -o loop,offset=239 disk point && umount point; do :; done

Retry the ioctl when it fails with EAGAIN, which means that mount or
losetup will eventually succeed when encountering this case.

[kzak@redhat.com: - use our local portable xusleep()]

Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/loopdev.c