Skip to content

Commit

Permalink
Fix a bug when formatting a full disk as Btrfs with snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
ancorgs committed Jun 14, 2024
1 parent 034d1fb commit ace78c6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/lib/y2storage/proposal/devices_planner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ def adjust_btrfs(planned_device, volume)
# @param volume [VolumeSpecification]
def adjust_btrfs_sizes(planned_device, volume)
return if volume.ignore_snapshots_sizes?
return unless planned_device.respond_to?(:min_size)

if volume.snapshots_size > DiskSize.zero
planned_device.min_size += volume.snapshots_size
Expand Down
21 changes: 20 additions & 1 deletion test/y2storage/proposal_agama_reuse_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@
# Let's define some volumes to shuffle them around among the disks
let(:volumes) { [root_vol, srv_vol, swap_vol] }
let(:root_vol) do
{ "mount_point" => "/", "fs_type" => "xfs", "min_size" => "5 GiB", "max_size" => "30 GiB" }
{
"mount_point" => "/", "fs_type" => "btrfs", "min_size" => "5 GiB", "max_size" => "30 GiB",
"snapshots" => true, "snapshots_percentage" => 160
}
end
let(:srv_vol) do
{ "mount_point" => "/srv", "fs_type" => "xfs", "min_size" => "5 GiB", "max_size" => "10 GiB" }
Expand Down Expand Up @@ -269,6 +272,22 @@
expect(filesystem.type.is?(:xfs)).to eq true
end
end

context "if the relocated volume is the root Btrfs with snapshots" do
before do
srv = settings.volumes.find { |v| v.mount_point == "/" }
srv.reuse_name = "/dev/sdc"
end

# The proposal used to throw an exception when adjusting the Btrfs-related sizes
# if the target device was a disk (so no sizes could actually be adjusted)
it "makes the proposal and assigns the mount point" do
proposal.propose
filesystem = proposal.devices.filesystems.find { |i| i.mount_path == "/" }
expect(filesystem.blk_devices.first.name).to eq "/dev/sdc"
expect(filesystem.type.is?(:btrfs)).to eq true
end
end
end

context "when using the existing filesystem from a disk" do
Expand Down

0 comments on commit ace78c6

Please sign in to comment.