]> git.ipfire.org Git - thirdparty/util-linux.git/commit
losetup: directly set dio instead of afterwards
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>
Thu, 9 Sep 2021 13:55:03 +0000 (09:55 -0400)
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>
Thu, 9 Sep 2021 13:55:03 +0000 (09:55 -0400)
commitd53346ed082db8717df7a76d2df9fd657d3e23e9
tree9f3ba32a7dd17e6072448fd9290fdd3a44a6719f
parent78001b7af36f685265e21feaf384a4be12118c64
losetup: directly set dio instead of afterwards

This avoids an extra syscall, and allows the kernel to automatically set
block size [0], avoiding unnecessary failure with 4096-byte devices.

This changes the observable behavior of losetup --direct-io in the case
where DIO is not supported to fully fail, instead of creating a
non-direct-io device. If the user explicitly specifies --direct-io, then
they should get either a DIO loopdev or no loopdev, not a non-DIO
loopdev and a misleading error.

Additionally, loopcxt_setup_device now uses O_CLOEXEC in the read-only
fallback.

[0] https://github.com/torvalds/linux/commit/85560117d00f5d528e928918b8f61cadcefff98b
lib/loopdev.c
sys-utils/losetup.c