aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKhazhismel Kumykov <khazhy@google.com>2018-01-19 18:07:37 -0500
committerMike Snitzer <snitzer@redhat.com>2018-01-29 13:44:58 -0500
commitf20426056f2eba3f0379779f0a75722e41bc28da (patch)
tree03684152f0cc079ad9d21804e2543e47059bb4ab
parentcc65661981ae2424e27c695ae8d15604448eb666 (diff)
dm mpath selector: more evenly distribute ties
Move the last used path to the end of the list (least preferred) so that ties are more evenly distributed. For example, in case with three paths with one that is slower than others, the remaining two would be unevenly used if they tie. This is due to the rotation not being a truely fair distribution. Illustrated: paths a, b, c, 'c' has 1 outstanding IO, a and b are 'tied' Three possible rotations: (a, b, c) -> best path 'a' (b, c, a) -> best path 'b' (c, a, b) -> best path 'a' (a, b, c) -> best path 'a' (b, c, a) -> best path 'b' (c, a, b) -> best path 'a' ... So 'a' is used 2x more than 'b', although they should be used evenly. With this change, the most recently used path is always the least preferred, removing this bias resulting in even distribution. (a, b, c) -> best path 'a' (b, c, a) -> best path 'b' (c, a, b) -> best path 'a' (c, b, a) -> best path 'b' ... Signed-off-by: Khazhismel Kumykov <khazhy@google.com> Reviewed-by: Martin Wilck <mwilck@suse.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
-rw-r--r--drivers/md/dm-queue-length.c6
-rw-r--r--drivers/md/dm-service-time.c6
2 files changed, 6 insertions, 6 deletions
diff --git a/drivers/md/dm-queue-length.c b/drivers/md/dm-queue-length.c
index 23f178641794..969c4f1a3633 100644
--- a/drivers/md/dm-queue-length.c
+++ b/drivers/md/dm-queue-length.c
@@ -195,9 +195,6 @@ static struct dm_path *ql_select_path(struct path_selector *ps, size_t nr_bytes)
195 if (list_empty(&s->valid_paths)) 195 if (list_empty(&s->valid_paths))
196 goto out; 196 goto out;
197 197
198 /* Change preferred (first in list) path to evenly balance. */
199 list_move_tail(s->valid_paths.next, &s->valid_paths);
200
201 list_for_each_entry(pi, &s->valid_paths, list) { 198 list_for_each_entry(pi, &s->valid_paths, list) {
202 if (!best || 199 if (!best ||
203 (atomic_read(&pi->qlen) < atomic_read(&best->qlen))) 200 (atomic_read(&pi->qlen) < atomic_read(&best->qlen)))
@@ -210,6 +207,9 @@ static struct dm_path *ql_select_path(struct path_selector *ps, size_t nr_bytes)
210 if (!best) 207 if (!best)
211 goto out; 208 goto out;
212 209
210 /* Move most recently used to least preferred to evenly balance. */
211 list_move_tail(&best->list, &s->valid_paths);
212
213 ret = best->path; 213 ret = best->path;
214out: 214out:
215 spin_unlock_irqrestore(&s->lock, flags); 215 spin_unlock_irqrestore(&s->lock, flags);
diff --git a/drivers/md/dm-service-time.c b/drivers/md/dm-service-time.c
index 7b8642045c55..f006a9005593 100644
--- a/drivers/md/dm-service-time.c
+++ b/drivers/md/dm-service-time.c
@@ -282,9 +282,6 @@ static struct dm_path *st_select_path(struct path_selector *ps, size_t nr_bytes)
282 if (list_empty(&s->valid_paths)) 282 if (list_empty(&s->valid_paths))
283 goto out; 283 goto out;
284 284
285 /* Change preferred (first in list) path to evenly balance. */
286 list_move_tail(s->valid_paths.next, &s->valid_paths);
287
288 list_for_each_entry(pi, &s->valid_paths, list) 285 list_for_each_entry(pi, &s->valid_paths, list)
289 if (!best || (st_compare_load(pi, best, nr_bytes) < 0)) 286 if (!best || (st_compare_load(pi, best, nr_bytes) < 0))
290 best = pi; 287 best = pi;
@@ -292,6 +289,9 @@ static struct dm_path *st_select_path(struct path_selector *ps, size_t nr_bytes)
292 if (!best) 289 if (!best)
293 goto out; 290 goto out;
294 291
292 /* Move most recently used to least preferred to evenly balance. */
293 list_move_tail(&best->list, &s->valid_paths);
294
295 ret = best->path; 295 ret = best->path;
296out: 296out:
297 spin_unlock_irqrestore(&s->lock, flags); 297 spin_unlock_irqrestore(&s->lock, flags);