Skip to content

Commit

Permalink
Merge pull request #316 from yast/drop_pbl_storage_data
Browse files Browse the repository at this point in the history
Drop pbl storage data
  • Loading branch information
jreidinger committed Apr 13, 2016
2 parents 2793b56 + c51099e commit e77dcc8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 164 deletions.
7 changes: 7 additions & 0 deletions package/yast2-bootloader.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Apr 13 13:14:30 UTC 2016 - jreidinger@suse.com

- Drop preparing storage data for perl-Bootloader as it is no
longer needed (related to FATE#317701)
- 3.1.168

-------------------------------------------------------------------
Wed Apr 13 11:14:11 UTC 2016 - jreidinger@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-bootloader.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-bootloader
Version: 3.1.167
Version: 3.1.168
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
133 changes: 0 additions & 133 deletions src/modules/BootStorage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,9 @@ def main
textdomain "bootloader"

Yast.import "Storage"
Yast.import "StorageDevices"
Yast.import "Arch"
Yast.import "Mode"

# Saved change time from target map - only for checkCallingDiskInfo()
@disk_change_time_checkCallingDiskInfo = nil

# Storage locked
@storage_initialized = false

# device mapping between real devices and multipath
@multipath_mapping = {}

# mountpoints for perl-Bootloader
@mountpoints = {}

# list of all partitions for perl-Bootloader
@partinfo = []

# information about MD arrays for perl-Bootloader
@md_info = {}

# string sepresenting device name of /boot partition
# same as RootPartitionDevice if no separate /boot partition
@BootPartitionDevice = ""
Expand All @@ -68,27 +49,6 @@ def main
@md_physical_disks = []
end

# bnc #447591, 438243, 448110 multipath wrong device map
# Function maps real devices to multipath e.g.
# "/dev/sda/" : "/dev/mapper/SATA_ST3120813AS_3LS0CD7M"
#
# @return [Hash{String => String}] mapping real disk to multipath

# FIXME: grub only

def mapRealDevicesToMultipath
ret = {}
tm = Storage.GetTargetMap
tm.each do |disk, disk_info|
next if disk_info["type"] != :CT_DMMULTIPATH

devices = disk_info["devices"] || []
devices.each { |d| ret[d] = disk }
end

ret
end

def gpt_boot_disk?
require "bootloader/bootloader_factory"
current_bl = ::Bootloader::BootloaderFactory.current
Expand All @@ -104,94 +64,6 @@ def gpt_boot_disk?
boot_discs.any? { |d| d["label"] == "gpt" }
end

# Check if function was called or storage change
# partitionig of disk. It is usefull fo using cached data
# about disk. Data is send to perl-Bootloader and it includes
# info about partitions, multi path and md-raid
#
# @return false if it is posible use cached data

def checkCallingDiskInfo
# fix for problem with unintialized storage library in AutoYaST mode
# bnc #464090
if Mode.config && !@storage_initialized
@storage_initialized = true
log.info "Init storage library in yast2-bootloader"
Storage.InitLibstorage(true)
end
if @disk_change_time_checkCallingDiskInfo != Storage.GetTargetChangeTime ||
@partinfo.empty?
# save last change time from storage
@disk_change_time_checkCallingDiskInfo = Storage.GetTargetChangeTime
log.info "disk was changed by storage or partinfo is empty"
log.info "generate partinfo, md_info, mountpoints and multipath_mapping"
return true
else
log.info "Skip genarating partinfo, md_info, mountpoints and multipath_mapping"
return false
end
end

# Function init data for perl-Bootloader about disk
# It means fullfil md_info, multipath_mapping, partinfo
# and mountpoints

def InitDiskInfo
return unless checkCallingDiskInfo

# delete variables for perl-Bootloader
@md_info = {}

tm = Storage.GetTargetMap

@multipath_mapping = mapRealDevicesToMultipath
@mountpoints = Builtins.mapmap(Storage.GetMountPoints) do |k, v|
# detect all raid1 md devices and mark them in md_info
device = v[0]
@md_info[device] = [] if v[3] == "raid1"
{ k => device }
end
# filter out temporary mount points from installation

tmpdir = SCR.Read(path(".target.tmpdir"))
@mountpoints = Builtins.filter(@mountpoints) do |k, v|
v.is_a?(::String) && !k.start_with?(tmpdir)
end

log.info "Detected mountpoints: #{@mountpoints}"

@partinfo = tm.reduce([]) do |res, i|
disk, info = i
next res if [:CT_LVM, :CT_EVMS].include?(info["type"])
partitions = info["partitions"]
# disk do not have to be partitioned, so skip it in such case
next res unless partitions

parts = partitions.map do |p|
raid = p["used_by_type"] == :UB_MD ? p["used_by_device"] : nil
device = p["device"] || ""
# We only pass along RAID1 devices as all other causes
# severe breakage in the bootloader stack
@md_info[raid] << device if raid && @md_info.include?(raid)

nr = (p["nr"] || 0).to_s
region = p.fetch("region", [])
[
device,
disk,
nr,
p["fsid"].to_i.to_s,
p["fstype"] || "unknown",
p["type"] || "nil",
(region[0] || 0).to_s,
(region[1] || 0).to_s,
::Bootloader::UdevMapping.to_mountby_device(device)
]
end
res.concat(parts)
end
end

# Returns list of partitions and disks. Requests current partitioning from
# yast2-storage and creates list of partition and disks usable for grub stage1
def possible_locations_for_stage1
Expand Down Expand Up @@ -570,14 +442,9 @@ def encrypted_boot?
end
end

publish :variable => :multipath_mapping, :type => "map <string, string>"
publish :variable => :mountpoints, :type => "map <string, any>"
publish :variable => :partinfo, :type => "list <list>"
publish :variable => :md_info, :type => "map <string, list <string>>"
publish :variable => :BootPartitionDevice, :type => "string"
publish :variable => :RootPartitionDevice, :type => "string"
publish :variable => :ExtendedPartitionDevice, :type => "string"
publish :function => :InitDiskInfo, :type => "void ()"
publish :function => :Md2Partitions, :type => "map <string, integer> (string)"
end

Expand Down
30 changes: 0 additions & 30 deletions test/boot_storage_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,36 +86,6 @@
end
end

describe ".multipath_mapping" do
before do
mock_disk_partition
# force reinit every time
allow(subject).to receive(:checkCallingDiskInfo).and_return(true)
# mock getting mount points as it need whole libstorage initialization
allow(Yast::Storage).to receive(:GetMountPoints).and_return("/" => "/dev/vda1")
# mock for same reason getting udev mapping
allow(::Bootloader::UdevMapping).to receive(:to_mountby_device) do |arg|
arg
end
end

it "returns empty map if there is no multipath" do
target_map_stub("storage_lvm.yaml")

# init variables
subject.InitDiskInfo
expect(subject.multipath_mapping).to eq({})
end

it "returns map of kernel names for disk devices to multipath devices associated with it" do
target_map_stub("many_disks.yaml")

# init variables
subject.InitDiskInfo
expect(subject.multipath_mapping["/dev/sda"]).to eq "/dev/mapper/3600508b1001c9a84c91492de27962d57"
end
end

describe ".detect_disks" do
before do
mock_disk_partition
Expand Down

0 comments on commit e77dcc8

Please sign in to comment.