From d1d17f253c8c837da10cc50239dca5e2ac9af095 Mon Sep 17 00:00:00 2001 From: Dmitry Guryanov Date: Mon, 28 Mar 2016 20:15:56 +0300 Subject: [PATCH] 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 --- agent | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/agent b/agent index a83318c..38e9902 100755 --- a/agent +++ b/agent @@ -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