loop: test partition cleanup when the backing file is changed - #259
daandemeyer wants to merge 1 commit into
Conversation
Partitions can be added to a loop device with BLKPG while LO_FLAGS_PARTSCAN is clear. loop_change_fd() only rescanned when LO_FLAGS_PARTSCAN was set, so once disk_force_media_change() stopped setting GD_NEED_PART_SCAN such partitions survived the backing file swap and kept describing the old file. Add a regression test that adds a partition with partx to a read-only loop device, swaps in a backing file of the same size without a partition table, and verifies that the partition is gone afterwards. Stop an active systemd-udevd during the test so userspace cannot hide missing kernel cleanup, and restore it through the test cleanup hook. Signed-off-by: Daan De Meyer <daan@amutable.com>
|
@daandemeyer Thanks for this PR. The code change look good to me. I will wait for the kernel patch gets upstreamed before I merge this PR. One quick question: I guess the reason to use partx is that sfdisk does not have the feature "partx --add" provides. Is this guess correct? |
I am unsure, I was notified of a regression in some project using partx. I did not take a closer look at the project itself. |
Thanks, I did some more investigation, but could not find the way to replace "partx --add" with sfdisk or other util-linux tools. Then the current commit looks the best. |
Partitions can be added to a loop device with BLKPG while
LO_FLAGS_PARTSCAN is clear. loop_change_fd() only rescanned when
LO_FLAGS_PARTSCAN was set, so once disk_force_media_change() stopped
setting GD_NEED_PART_SCAN such partitions survived the backing file swap
and kept describing the old file.
Add a regression test that adds a partition with partx to a read-only
loop device, swaps in a backing file of the same size without a partition
table, and verifies that the partition is gone afterwards. Stop an active
systemd-udevd during the test so userspace cannot hide missing kernel
cleanup, and restore it through the test cleanup hook.
Signed-off-by: Daan De Meyer daan@amutable.com