Lines Matching full:grp
35 static bool erofs_workgroup_get(struct erofs_workgroup *grp) in erofs_workgroup_get() argument
37 if (lockref_get_not_zero(&grp->lockref)) in erofs_workgroup_get()
40 spin_lock(&grp->lockref.lock); in erofs_workgroup_get()
41 if (__lockref_is_dead(&grp->lockref)) { in erofs_workgroup_get()
42 spin_unlock(&grp->lockref.lock); in erofs_workgroup_get()
46 if (!grp->lockref.count++) in erofs_workgroup_get()
48 spin_unlock(&grp->lockref.lock); in erofs_workgroup_get()
56 struct erofs_workgroup *grp; in erofs_find_workgroup() local
60 grp = xa_load(&sbi->managed_pslots, index); in erofs_find_workgroup()
61 if (grp) { in erofs_find_workgroup()
62 if (!erofs_workgroup_get(grp)) { in erofs_find_workgroup()
68 DBG_BUGON(index != grp->index); in erofs_find_workgroup()
71 return grp; in erofs_find_workgroup()
75 struct erofs_workgroup *grp) in erofs_insert_workgroup() argument
84 lockref_get(&grp->lockref); in erofs_insert_workgroup()
88 pre = __xa_cmpxchg(&sbi->managed_pslots, grp->index, in erofs_insert_workgroup()
89 NULL, grp, GFP_NOFS); in erofs_insert_workgroup()
99 lockref_put_return(&grp->lockref); in erofs_insert_workgroup()
100 grp = pre; in erofs_insert_workgroup()
103 return grp; in erofs_insert_workgroup()
106 static void __erofs_workgroup_free(struct erofs_workgroup *grp) in __erofs_workgroup_free() argument
109 erofs_workgroup_free_rcu(grp); in __erofs_workgroup_free()
112 void erofs_workgroup_put(struct erofs_workgroup *grp) in erofs_workgroup_put() argument
114 if (lockref_put_or_lock(&grp->lockref)) in erofs_workgroup_put()
117 DBG_BUGON(__lockref_is_dead(&grp->lockref)); in erofs_workgroup_put()
118 if (grp->lockref.count == 1) in erofs_workgroup_put()
120 --grp->lockref.count; in erofs_workgroup_put()
121 spin_unlock(&grp->lockref.lock); in erofs_workgroup_put()
125 struct erofs_workgroup *grp) in erofs_try_to_release_workgroup() argument
129 spin_lock(&grp->lockref.lock); in erofs_try_to_release_workgroup()
130 if (grp->lockref.count) in erofs_try_to_release_workgroup()
138 if (erofs_try_to_free_all_cached_pages(sbi, grp)) in erofs_try_to_release_workgroup()
146 DBG_BUGON(__xa_erase(&sbi->managed_pslots, grp->index) != grp); in erofs_try_to_release_workgroup()
148 lockref_mark_dead(&grp->lockref); in erofs_try_to_release_workgroup()
151 spin_unlock(&grp->lockref.lock); in erofs_try_to_release_workgroup()
153 __erofs_workgroup_free(grp); in erofs_try_to_release_workgroup()
160 struct erofs_workgroup *grp; in erofs_shrink_workstation() local
165 xa_for_each(&sbi->managed_pslots, index, grp) { in erofs_shrink_workstation()
167 if (!erofs_try_to_release_workgroup(sbi, grp)) in erofs_shrink_workstation()