Lines Matching refs: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
80 DBG_BUGON(grp->lockref.count < 1); in erofs_insert_workgroup()
83 pre = __xa_cmpxchg(&sbi->managed_pslots, grp->index, in erofs_insert_workgroup()
84 NULL, grp, GFP_NOFS); in erofs_insert_workgroup()
94 grp = pre; in erofs_insert_workgroup()
97 return grp; in erofs_insert_workgroup()
100 static void __erofs_workgroup_free(struct erofs_workgroup *grp) in __erofs_workgroup_free() argument
103 erofs_workgroup_free_rcu(grp); in __erofs_workgroup_free()
106 void erofs_workgroup_put(struct erofs_workgroup *grp) in erofs_workgroup_put() argument
108 if (lockref_put_or_lock(&grp->lockref)) in erofs_workgroup_put()
111 DBG_BUGON(__lockref_is_dead(&grp->lockref)); in erofs_workgroup_put()
112 if (grp->lockref.count == 1) in erofs_workgroup_put()
114 --grp->lockref.count; in erofs_workgroup_put()
115 spin_unlock(&grp->lockref.lock); in erofs_workgroup_put()
119 struct erofs_workgroup *grp) in erofs_try_to_release_workgroup() argument
123 spin_lock(&grp->lockref.lock); in erofs_try_to_release_workgroup()
124 if (grp->lockref.count) in erofs_try_to_release_workgroup()
132 if (erofs_try_to_free_all_cached_pages(sbi, grp)) in erofs_try_to_release_workgroup()
140 DBG_BUGON(__xa_erase(&sbi->managed_pslots, grp->index) != grp); in erofs_try_to_release_workgroup()
142 lockref_mark_dead(&grp->lockref); in erofs_try_to_release_workgroup()
145 spin_unlock(&grp->lockref.lock); in erofs_try_to_release_workgroup()
147 __erofs_workgroup_free(grp); in erofs_try_to_release_workgroup()
154 struct erofs_workgroup *grp; in erofs_shrink_workstation() local
159 xa_for_each(&sbi->managed_pslots, index, grp) { in erofs_shrink_workstation()
161 if (!erofs_try_to_release_workgroup(sbi, grp)) in erofs_shrink_workstation()