report optimal io size for block devices

LVM aligns devices data area to io hints, reported for
block devices. Optimal io size can be big for some devices
(16M, as reported in bug). So nailgun's volume manager
should take it into account while doing partitioning.
So nailgun-agent should send this information to nailgun.

Change-Id: Idd9b778f7f21d4fe9d3fd029038664de41f93447
Partial-Bug: #1546049
This commit is contained in:
Dmitry Guryanov 2016-03-28 20:15:56 +03:00
parent 4b83a7943e
commit d1d17f253c
1 changed files with 22 additions and 1 deletions

23
agent
View File

@ -481,7 +481,8 @@ class NodeAgent
:disk => block[:disk],
:extra => block[:extra],
:removable => block[:removable],
:paths => nil
:paths => nil,
:opt_io => get_opt_io.fetch(dname, block_size)
}
elsif @mpath_devices.has_key?(dname)
@ -733,6 +734,26 @@ class NodeAgent
@blocks
end
def get_opt_io
return @opt_io_res if defined?(@opt_io_res)
@opt_io_res = {}
# example output:
# sda 4096 0
# sdb 512 2048
output = `lsblk --nodeps --bytes --noheadings --output NAME,MIN-IO,OPT-IO`
output.split("\n").each do |line|
name, min_io, opt_io = line.split()
@opt_io_res[name] = opt_io.to_i != 0 ? opt_io.to_i : min_io.to_i
end
@opt_io_res
rescue => e
@logger.error("Error '#{e.message}' in obtaining optimal io size: #{e.backtrace}")
@opt_io_res ||= {}
end
def _is_virtualbox
@os[:dmi][:system][:product_name] == "VirtualBox" rescue false
end