in cookbooks/fb_storage/libraries/storage_handlers.rb [173:266]
def format_partition(partition, config)
umount_by_partition(partition)
unless File.basename(partition).start_with?('md')
Chef::Log.debug(
'fb_storage: Removing from any relevant arrays',
)
remove_device_from_any_arrays(partition)
end
cmd = mkfs_cmd(config['type'])
timeout = self.mkfs_timeout
unless cmd
fail "fb_storage: unknown fstype #{config['type']} for " +
" #{partition}"
end
format_options = default_format_options(config['type'])
if @node['fb_storage']['format_options']
case @node['fb_storage']['format_options']
when String
format_options =
@node['fb_storage']['format_options'].dup
when Hash
format_options =
@node['fb_storage']['format_options'][config['type']]
else
fail "fb_storage: Not sure what to do with 'format_options': " +
@node['fb_storage']['format_options'].to_s
end
end
device = partition
if config['raid_level'] == 'hybrid_xfs'
device = config['journal']
extsize = config['extsize'] || 262144
format_options << ' -d rtinherit=1 -r rtdev=' +
"#{config['members'].first},extsize=#{extsize}"
format_options << ' -m crc=0 -m reflink=0'
end
label = config['label']
if config['type'] == 'xfs'
label = label[0..11]
end
if config['type'] == 'ext4'
timeout *= 2
end
cmd << " #{format_options} -L \"#{label}\" #{device}"
Chef::Log.info(
"fb_storage: Making filesystem on #{device}",
)
Chef::Log.debug("fb_storage: Running #{cmd}")
limit_file = '/proc/sys/dev/raid/speed_limit_max'
if @type == :md && config['raid_level'] != 'hybrid_xfs' &&
File.exist?(limit_file)
need_to_quiesce_md = true
else
need_to_quiesce_md = false
end
begin
if need_to_quiesce_md
Chef::Log.info(
'fb_storage: Stopping md resyncing while creating ' +
'filesystem',
)
limit = File.read(limit_file)
File.write(limit_file, "0\n")
end
mkfs = Mixlib::ShellOut.new(cmd, :timeout => timeout)
mkfs.run_command.error!
ensure
if need_to_quiesce_md
Chef::Log.info(
'fb_storage: Resuming md resyncing after creating ' +
'filesystem',
)
File.write(limit_file, limit)
end
end
end