Lines Matching +full:sub +full:- +full:systems

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2006-2008 Nokia Corporation.
19 * If the root of a TNC sub-tree is clean and old enough, then the children are
21 * dumps entire sub-trees.
23 * The age of znodes is just the time-stamp when they were last looked at.
27 * un-mounts, which is done by the 'ubifs_infos_lock' and 'c->umount_mutex'.
32 /* List of all UBIFS file-system instances */
49 * shrink_tnc - shrink TNC tree.
50 * @c: UBIFS file-system description object
64 ubifs_assert(c, mutex_is_locked(&c->umount_mutex)); in shrink_tnc()
65 ubifs_assert(c, mutex_is_locked(&c->tnc_mutex)); in shrink_tnc()
67 if (!c->zroot.znode || atomic_long_read(&c->clean_zn_cnt) == 0) in shrink_tnc()
72 * to destroy large sub-trees. Indeed, if a znode is old, then all its in shrink_tnc()
75 * Note, we are holding 'c->tnc_mutex', so we do not have to lock the in shrink_tnc()
76 * 'c->space_lock' when _reading_ 'c->clean_zn_cnt', because it is in shrink_tnc()
77 * changed only when the 'c->tnc_mutex' is held. in shrink_tnc()
80 znode = ubifs_tnc_levelorder_next(c, c->zroot.znode, NULL); in shrink_tnc()
82 atomic_long_read(&c->clean_zn_cnt) > 0) { in shrink_tnc()
86 * If the znode is clean, but it is in the 'c->cnext' list, this in shrink_tnc()
96 * the znodes which are in the 'c->cnext' list as freeable. in shrink_tnc()
98 * Also note, if the root of a sub-tree is not in 'c->cnext', in shrink_tnc()
99 * then the whole sub-tree is not in 'c->cnext' as well, so it in shrink_tnc()
100 * is safe to dump whole sub-tree. in shrink_tnc()
103 if (znode->cnext) { in shrink_tnc()
110 abs(time - znode->time) >= age) { in shrink_tnc()
111 if (znode->parent) in shrink_tnc()
112 znode->parent->zbranch[znode->iip].znode = NULL; in shrink_tnc()
114 c->zroot.znode = NULL; in shrink_tnc()
118 atomic_long_sub(freed, &c->clean_zn_cnt); in shrink_tnc()
123 if (unlikely(!c->zroot.znode)) in shrink_tnc()
127 znode = ubifs_tnc_levelorder_next(c, c->zroot.znode, znode); in shrink_tnc()
135 * shrink_tnc_trees - shrink UBIFS TNC trees.
140 * This function walks the list of mounted UBIFS file-systems and frees clean
155 /* Iterate over all mounted UBIFS file-systems and try to shrink them */ in shrink_tnc_trees()
163 if (c->shrinker_run_no == run_no) in shrink_tnc_trees()
165 if (!mutex_trylock(&c->umount_mutex)) { in shrink_tnc_trees()
166 /* Some un-mount is in progress, try next FS */ in shrink_tnc_trees()
168 p = p->next; in shrink_tnc_trees()
172 * We're holding 'c->umount_mutex', so the file-system won't go in shrink_tnc_trees()
175 if (!mutex_trylock(&c->tnc_mutex)) { in shrink_tnc_trees()
176 mutex_unlock(&c->umount_mutex); in shrink_tnc_trees()
178 p = p->next; in shrink_tnc_trees()
183 * OK, now we have TNC locked, the file-system cannot go away - in shrink_tnc_trees()
186 c->shrinker_run_no = run_no; in shrink_tnc_trees()
188 mutex_unlock(&c->tnc_mutex); in shrink_tnc_trees()
191 p = p->next; in shrink_tnc_trees()
196 list_move_tail(&c->infos_list, &ubifs_infos); in shrink_tnc_trees()
197 mutex_unlock(&c->umount_mutex); in shrink_tnc_trees()
206 * kick_a_thread - kick a background thread to start commit.
209 * %-1 if a thread was kicked or there is another reason to assume the memory
219 * Iterate over all mounted UBIFS file-systems and find out if there is in kick_a_thread()
228 if (!mutex_trylock(&c->umount_mutex)) { in kick_a_thread()
230 * Some un-mount is in progress, it will in kick_a_thread()
234 return -1; in kick_a_thread()
237 dirty_zn_cnt = atomic_long_read(&c->dirty_zn_cnt); in kick_a_thread()
239 if (!dirty_zn_cnt || c->cmt_state == COMMIT_BROKEN || in kick_a_thread()
240 c->ro_mount || c->ro_error) { in kick_a_thread()
241 mutex_unlock(&c->umount_mutex); in kick_a_thread()
245 if (c->cmt_state != COMMIT_RESTING) { in kick_a_thread()
247 mutex_unlock(&c->umount_mutex); in kick_a_thread()
248 return -1; in kick_a_thread()
252 list_move_tail(&c->infos_list, &ubifs_infos); in kick_a_thread()
256 mutex_unlock(&c->umount_mutex); in kick_a_thread()
257 return -1; in kick_a_thread()
259 mutex_unlock(&c->umount_mutex); in kick_a_thread()
282 unsigned long nr = sc->nr_to_scan; in ubifs_shrink_scan()
292 * And we return -1 which means will make VM call us again in ubifs_shrink_scan()
304 freed += shrink_tnc_trees(nr - freed, YOUNG_ZNODE_AGE, &contention); in ubifs_shrink_scan()
309 freed += shrink_tnc_trees(nr - freed, 0, &contention); in ubifs_shrink_scan()