dm-service-time¶
dm-service-time 是一个用于设备映射器目标的路径选择模块,它为传入的 I/O 选择估计服务时间最短的路径。
每条路径的服务时间通过将路径上正在进行的 I/O 的总大小除以路径的性能值来估算。性能值是路径组中所有路径之间的相对吞吐量值,可以作为表格参数指定。
路径选择器名称为“service-time”。
每条路径的表格参数
- [<repeat_count> [<relative_throughput>]]
- <repeat_count>
在切换到下一条路径之前,使用选定路径分派的 I/O 数量。如果未给出,则使用内部默认值。要检查默认值,请参阅已激活的表格。
- <relative_throughput>
路径在路径组中所有路径中的相对吞吐量值。有效范围为 0-100。如果未给出,则使用最小值“1”。如果给出“0”,则当其他具有正值的路径可用时,不选择该路径。
每条路径的状态
- <status> <fail-count> <in-flight-size> <relative_throughput>
- <status>
如果路径处于活动状态,则为“A”;如果路径失败,则为“F”。
- <fail-count>
路径失败的次数。
- <in-flight-size>
路径上正在进行的 I/O 的大小。
- <relative_throughput>
路径在路径组中所有路径中的相对吞吐量值。
算法¶
dm-service-time 在 I/O 分派时将 I/O 大小添加到“in-flight-size”中,并在完成时减去。基本上,dm-service-time 选择服务时间最短的路径,服务时间通过以下方式计算:
('in-flight-size' + 'size-of-incoming-io') / 'relative_throughput'
然而,为尽可能减少计算量,使用了一些如下优化。
如果路径具有相同的“relative_throughput”,则跳过除法,仅比较“in-flight-size”。
如果路径具有相同的“in-flight-size”,则跳过除法,仅比较“relative_throughput”。
如果某些路径具有非零的“relative_throughput”而其他路径具有零的“relative_throughput”,则忽略那些“relative_throughput”为零的路径。
如果无法应用此类优化,则计算服务时间并比较服务时间。如果计算出的服务时间相等,则具有最大“relative_throughput”的路径可能更好。因此,在此情况下比较“relative_throughput”。
示例¶
在两根路径(sda 和 sdb)且 repeat_count == 128 的情况下,如果 sda 的平均吞吐量为 1GB/s,sdb 为 4GB/s,则 sda 的“relative_throughput”值可能为“1”,sdb 为“4”。
# echo "0 10 multipath 0 0 1 1 service-time 0 2 2 8:0 128 1 8:16 128 4" \
dmsetup create test
#
# dmsetup table
test: 0 10 multipath 0 0 1 1 service-time 0 2 2 8:0 128 1 8:16 128 4
#
# dmsetup status
test: 0 10 multipath 2 0 0 0 1 1 E 0 2 2 8:0 A 0 0 1 8:16 A 0 0 4
或者 sda 为“2”,sdb 为“8”也同样正确。
# echo "0 10 multipath 0 0 1 1 service-time 0 2 2 8:0 128 2 8:16 128 8" \
dmsetup create test
#
# dmsetup table
test: 0 10 multipath 0 0 1 1 service-time 0 2 2 8:0 128 2 8:16 128 8
#
# dmsetup status
test: 0 10 multipath 2 0 0 0 1 1 E 0 2 2 8:0 A 0 0 2 8:16 A 0 0 8