# Config for {{ name }}
# Generated by ansible

{% for server in servers %}
volume vol-{{ servers.index(server) }}
	type protocol/client
	option transport-type tcp
	option remote-host {{ server }}
	option transport.socket.nodelay on
	option remote-port 6996
	option remote-subvolume iothreads
	option username {{ username }}
	option password {{ password }}
end-volume

{% endfor %}

volume mirror-0
	type cluster/replicate
	subvolumes {% for server in servers %}vol-{{loop.index - 1}} {% endfor %}
	{% if servers.index(inventory_hostname) %}
	option read-subvolume vol-{{ servers.index(inventory_hostname)}}{% endif %}

end-volume

volume writebehind
	type performance/write-behind
	option cache-size 4MB
	# option flush-behind on	# olecam: increasing the performance of handling lots of small files
	subvolumes mirror-0
end-volume

volume iothreads
	type performance/io-threads
	option thread-count 16 # default is 16
	subvolumes writebehind
end-volume

volume iocache
	type performance/io-cache
	option cache-size `grep 'MemTotal' /proc/meminfo  | awk '{print $2 * 0.2 / 1024}' | cut -f1 -d.`MB
	option cache-timeout 30
	subvolumes iothreads
end-volume

volume statprefetch
	type performance/stat-prefetch
	subvolumes iocache
end-volume

#volume nfs-server
#	type nfs/server
#	option nfs.dynamic-volumes on
#	subvolumes mirror-0
#end-volume
