Lines Matching refs:grp
217 static bool erofs_workgroup_get(struct erofs_workgroup *grp) in erofs_workgroup_get() argument
219 if (lockref_get_not_zero(&grp->lockref)) in erofs_workgroup_get()
222 spin_lock(&grp->lockref.lock); in erofs_workgroup_get()
223 if (__lockref_is_dead(&grp->lockref)) { in erofs_workgroup_get()
224 spin_unlock(&grp->lockref.lock); in erofs_workgroup_get()
228 if (!grp->lockref.count++) in erofs_workgroup_get()
230 spin_unlock(&grp->lockref.lock); in erofs_workgroup_get()
238 struct erofs_workgroup *grp; in erofs_find_workgroup() local
242 grp = xa_load(&sbi->managed_pslots, index); in erofs_find_workgroup()
243 if (grp) { in erofs_find_workgroup()
244 if (!erofs_workgroup_get(grp)) { in erofs_find_workgroup()
250 DBG_BUGON(index != grp->index); in erofs_find_workgroup()
253 return grp; in erofs_find_workgroup()
257 struct erofs_workgroup *grp) in erofs_insert_workgroup() argument
262 DBG_BUGON(grp->lockref.count < 1); in erofs_insert_workgroup()
265 pre = __xa_cmpxchg(&sbi->managed_pslots, grp->index, in erofs_insert_workgroup()
266 NULL, grp, GFP_KERNEL); in erofs_insert_workgroup()
276 grp = pre; in erofs_insert_workgroup()
279 return grp; in erofs_insert_workgroup()
282 static void __erofs_workgroup_free(struct erofs_workgroup *grp) in __erofs_workgroup_free() argument
285 erofs_workgroup_free_rcu(grp); in __erofs_workgroup_free()
288 void erofs_workgroup_put(struct erofs_workgroup *grp) in erofs_workgroup_put() argument
290 if (lockref_put_or_lock(&grp->lockref)) in erofs_workgroup_put()
293 DBG_BUGON(__lockref_is_dead(&grp->lockref)); in erofs_workgroup_put()
294 if (grp->lockref.count == 1) in erofs_workgroup_put()
296 --grp->lockref.count; in erofs_workgroup_put()
297 spin_unlock(&grp->lockref.lock); in erofs_workgroup_put()
301 struct erofs_workgroup *grp) in erofs_try_to_release_workgroup() argument
305 spin_lock(&grp->lockref.lock); in erofs_try_to_release_workgroup()
306 if (grp->lockref.count) in erofs_try_to_release_workgroup()
314 if (erofs_try_to_free_all_cached_folios(sbi, grp)) in erofs_try_to_release_workgroup()
322 DBG_BUGON(__xa_erase(&sbi->managed_pslots, grp->index) != grp); in erofs_try_to_release_workgroup()
324 lockref_mark_dead(&grp->lockref); in erofs_try_to_release_workgroup()
327 spin_unlock(&grp->lockref.lock); in erofs_try_to_release_workgroup()
329 __erofs_workgroup_free(grp); in erofs_try_to_release_workgroup()
336 struct erofs_workgroup *grp; in erofs_shrink_workstation() local
341 xa_for_each(&sbi->managed_pslots, index, grp) { in erofs_shrink_workstation()
343 if (!erofs_try_to_release_workgroup(sbi, grp)) in erofs_shrink_workstation()