From 9828207c62a26b4edf14a8bb4e285a76a78fc27e Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Wed, 19 Aug 2020 09:58:53 +0200 Subject: [PATCH] infra: factor out _reconnect_dent() --- kernel/sy_old/sy_generic.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/kernel/sy_old/sy_generic.c b/kernel/sy_old/sy_generic.c index d2784cc2..f0577d50 100644 --- a/kernel/sy_old/sy_generic.c +++ b/kernel/sy_old/sy_generic.c @@ -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) {