|
|
|
@ -132,6 +132,35 @@ struct erofs_workgroup { |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
#if defined(CONFIG_SMP) |
|
|
|
|
static inline bool erofs_workgroup_try_to_freeze(struct erofs_workgroup *grp, |
|
|
|
|
int val) |
|
|
|
|
{ |
|
|
|
|
preempt_disable(); |
|
|
|
|
if (val != atomic_cmpxchg(&grp->refcount, val, EROFS_LOCKED_MAGIC)) { |
|
|
|
|
preempt_enable(); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static inline void erofs_workgroup_unfreeze(struct erofs_workgroup *grp, |
|
|
|
|
int orig_val) |
|
|
|
|
{ |
|
|
|
|
/*
|
|
|
|
|
* other observers should notice all modifications |
|
|
|
|
* in the freezing period. |
|
|
|
|
*/ |
|
|
|
|
smp_mb(); |
|
|
|
|
atomic_set(&grp->refcount, orig_val); |
|
|
|
|
preempt_enable(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static inline int erofs_wait_on_workgroup_freezed(struct erofs_workgroup *grp) |
|
|
|
|
{ |
|
|
|
|
return atomic_cond_read_relaxed(&grp->refcount, |
|
|
|
|
VAL != EROFS_LOCKED_MAGIC); |
|
|
|
|
} |
|
|
|
|
#else |
|
|
|
|
static inline bool erofs_workgroup_try_to_freeze(struct erofs_workgroup *grp, |
|
|
|
|
int val) |
|
|
|
|
{ |
|
|
|
|