Commit 84d6c730 authored by Pavel Tikhomirov's avatar Pavel Tikhomirov Committed by Andrei Vagin

mount: fix mnt_resort_siblings to work as described

We should add new entry _before_ first entry with less depth to sort in
descending order.

e.g: entries in list have depths [7,5,3], adding new entry m with depth
4 we would break list_for_each_entry loop on p with depth 3, before
patch we would get [7,5,3,4] after list_add, which is wrong.

Also we can relax "<=" check to "<" to avoid unnecessary reordering.
Signed-off-by: 's avatarPavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent dd104ddb
...@@ -446,10 +446,10 @@ static void mnt_resort_siblings(struct mount_info *tree) ...@@ -446,10 +446,10 @@ static void mnt_resort_siblings(struct mount_info *tree)
depth = mnt_depth(m); depth = mnt_depth(m);
list_for_each_entry(p, &list, siblings) list_for_each_entry(p, &list, siblings)
if (mnt_depth(p) <= depth) if (mnt_depth(p) < depth)
break; break;
list_add(&m->siblings, &p->siblings); list_add_tail(&m->siblings, &p->siblings);
mnt_resort_siblings(m); mnt_resort_siblings(m);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment