infra: factor out _reconnect_dent()

This commit is contained in:
Thomas Schoebel-Theuer 2020-08-19 09:58:53 +02:00 committed by Thomas Schoebel-Theuer
parent c500183177
commit 9828207c62
1 changed files with 15 additions and 10 deletions

View File

@ -1525,6 +1525,19 @@ int mars_filler(void *__buf, const char *name, int namlen, loff_t offset,
return 0;
}
static
void _reconnect_dent(struct mars_cookie *cookie, struct mars_dent *dent)
{
if (dent->d_parent == cookie->parent)
return;
if (dent->d_parent)
dent->d_parent->d_child_count--;
dent->d_parent = cookie->parent;
if (dent->d_parent)
dent->d_parent->d_child_count++;
}
static
void _mars_order(struct mars_cookie *cookie, struct mars_dent *dent)
{
@ -1603,11 +1616,7 @@ void _mars_order(struct mars_cookie *cookie, struct mars_dent *dent)
list_add(&dent->dent_hash_link, start);
found:
if (dent->d_parent)
dent->d_parent->d_child_count--;
dent->d_parent = cookie->parent;
if (dent->d_parent)
dent->d_parent->d_child_count++;
_reconnect_dent(cookie, dent);
}
static inline
@ -1655,11 +1664,7 @@ void _mars_order_all(struct mars_cookie *cookie)
list_add(&dent->dent_link, &later_anchor);
else
list_add_tail(&dent->dent_link, &later_anchor);
if (dent->d_parent)
dent->d_parent->d_child_count--;
dent->d_parent = cookie->parent;
if (dent->d_parent)
dent->d_parent->d_child_count++;
_reconnect_dent(cookie, dent);
continue;
}
if (!cookie->some_ordered) {