xref: /OK3568_Linux_fs/kernel/Documentation/admin-guide/device-mapper/dm-service-time.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun===============
2*4882a593Smuzhiyundm-service-time
3*4882a593Smuzhiyun===============
4*4882a593Smuzhiyun
5*4882a593Smuzhiyundm-service-time is a path selector module for device-mapper targets,
6*4882a593Smuzhiyunwhich selects a path with the shortest estimated service time for
7*4882a593Smuzhiyunthe incoming I/O.
8*4882a593Smuzhiyun
9*4882a593SmuzhiyunThe service time for each path is estimated by dividing the total size
10*4882a593Smuzhiyunof in-flight I/Os on a path with the performance value of the path.
11*4882a593SmuzhiyunThe performance value is a relative throughput value among all paths
12*4882a593Smuzhiyunin a path-group, and it can be specified as a table argument.
13*4882a593Smuzhiyun
14*4882a593SmuzhiyunThe path selector name is 'service-time'.
15*4882a593Smuzhiyun
16*4882a593SmuzhiyunTable parameters for each path:
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun    [<repeat_count> [<relative_throughput>]]
19*4882a593Smuzhiyun	<repeat_count>:
20*4882a593Smuzhiyun			The number of I/Os to dispatch using the selected
21*4882a593Smuzhiyun			path before switching to the next path.
22*4882a593Smuzhiyun			If not given, internal default is used.  To check
23*4882a593Smuzhiyun			the default value, see the activated table.
24*4882a593Smuzhiyun	<relative_throughput>:
25*4882a593Smuzhiyun			The relative throughput value of the path
26*4882a593Smuzhiyun			among all paths in the path-group.
27*4882a593Smuzhiyun			The valid range is 0-100.
28*4882a593Smuzhiyun			If not given, minimum value '1' is used.
29*4882a593Smuzhiyun			If '0' is given, the path isn't selected while
30*4882a593Smuzhiyun			other paths having a positive value are available.
31*4882a593Smuzhiyun
32*4882a593SmuzhiyunStatus for each path:
33*4882a593Smuzhiyun
34*4882a593Smuzhiyun    <status> <fail-count> <in-flight-size> <relative_throughput>
35*4882a593Smuzhiyun	<status>:
36*4882a593Smuzhiyun		'A' if the path is active, 'F' if the path is failed.
37*4882a593Smuzhiyun	<fail-count>:
38*4882a593Smuzhiyun		The number of path failures.
39*4882a593Smuzhiyun	<in-flight-size>:
40*4882a593Smuzhiyun		The size of in-flight I/Os on the path.
41*4882a593Smuzhiyun	<relative_throughput>:
42*4882a593Smuzhiyun		The relative throughput value of the path
43*4882a593Smuzhiyun		among all paths in the path-group.
44*4882a593Smuzhiyun
45*4882a593Smuzhiyun
46*4882a593SmuzhiyunAlgorithm
47*4882a593Smuzhiyun=========
48*4882a593Smuzhiyun
49*4882a593Smuzhiyundm-service-time adds the I/O size to 'in-flight-size' when the I/O is
50*4882a593Smuzhiyundispatched and subtracts when completed.
51*4882a593SmuzhiyunBasically, dm-service-time selects a path having minimum service time
52*4882a593Smuzhiyunwhich is calculated by::
53*4882a593Smuzhiyun
54*4882a593Smuzhiyun	('in-flight-size' + 'size-of-incoming-io') / 'relative_throughput'
55*4882a593Smuzhiyun
56*4882a593SmuzhiyunHowever, some optimizations below are used to reduce the calculation
57*4882a593Smuzhiyunas much as possible.
58*4882a593Smuzhiyun
59*4882a593Smuzhiyun	1. If the paths have the same 'relative_throughput', skip
60*4882a593Smuzhiyun	   the division and just compare the 'in-flight-size'.
61*4882a593Smuzhiyun
62*4882a593Smuzhiyun	2. If the paths have the same 'in-flight-size', skip the division
63*4882a593Smuzhiyun	   and just compare the 'relative_throughput'.
64*4882a593Smuzhiyun
65*4882a593Smuzhiyun	3. If some paths have non-zero 'relative_throughput' and others
66*4882a593Smuzhiyun	   have zero 'relative_throughput', ignore those paths with zero
67*4882a593Smuzhiyun	   'relative_throughput'.
68*4882a593Smuzhiyun
69*4882a593SmuzhiyunIf such optimizations can't be applied, calculate service time, and
70*4882a593Smuzhiyuncompare service time.
71*4882a593SmuzhiyunIf calculated service time is equal, the path having maximum
72*4882a593Smuzhiyun'relative_throughput' may be better.  So compare 'relative_throughput'
73*4882a593Smuzhiyunthen.
74*4882a593Smuzhiyun
75*4882a593Smuzhiyun
76*4882a593SmuzhiyunExamples
77*4882a593Smuzhiyun========
78*4882a593SmuzhiyunIn case that 2 paths (sda and sdb) are used with repeat_count == 128
79*4882a593Smuzhiyunand sda has an average throughput 1GB/s and sdb has 4GB/s,
80*4882a593Smuzhiyun'relative_throughput' value may be '1' for sda and '4' for sdb::
81*4882a593Smuzhiyun
82*4882a593Smuzhiyun  # echo "0 10 multipath 0 0 1 1 service-time 0 2 2 8:0 128 1 8:16 128 4" \
83*4882a593Smuzhiyun    dmsetup create test
84*4882a593Smuzhiyun  #
85*4882a593Smuzhiyun  # dmsetup table
86*4882a593Smuzhiyun  test: 0 10 multipath 0 0 1 1 service-time 0 2 2 8:0 128 1 8:16 128 4
87*4882a593Smuzhiyun  #
88*4882a593Smuzhiyun  # dmsetup status
89*4882a593Smuzhiyun  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
90*4882a593Smuzhiyun
91*4882a593Smuzhiyun
92*4882a593SmuzhiyunOr '2' for sda and '8' for sdb would be also true::
93*4882a593Smuzhiyun
94*4882a593Smuzhiyun  # echo "0 10 multipath 0 0 1 1 service-time 0 2 2 8:0 128 2 8:16 128 8" \
95*4882a593Smuzhiyun    dmsetup create test
96*4882a593Smuzhiyun  #
97*4882a593Smuzhiyun  # dmsetup table
98*4882a593Smuzhiyun  test: 0 10 multipath 0 0 1 1 service-time 0 2 2 8:0 128 2 8:16 128 8
99*4882a593Smuzhiyun  #
100*4882a593Smuzhiyun  # dmsetup status
101*4882a593Smuzhiyun  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
102