Skip to content

loop: test partition cleanup when the backing file is changed - #259

Open
daandemeyer wants to merge 1 commit into
linux-blktests:masterfrom
daandemeyer:push-sutznltmsrqv
Open

daandemeyer wants to merge 1 commit into
linux-blktests:masterfrom
daandemeyer:push-sutznltmsrqv

Conversation

@daandemeyer

Copy link
Copy Markdown
Contributor

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

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>
@kawasaki

Copy link
Copy Markdown
Collaborator

@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?

@daandemeyer

Copy link
Copy Markdown
Contributor Author

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.

@kawasaki

Copy link
Copy Markdown
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants