Atomic memory barriers cleanup. Inspired by Ming Zhang.

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@74 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2007-01-09 14:52:16 +00:00
parent a0ef0b8fb2
commit 9bb1f8eefe
2 changed files with 3 additions and 10 deletions

View File

@@ -287,11 +287,8 @@ static void q2t_free_session_done(struct scst_session *scst_sess)
tgt->handle, list_empty(&tgt->sess_list),
atomic_read(&tgt->sess_count));
smp_mb__before_atomic_dec();
if (atomic_dec_and_test(&tgt->sess_count)) {
smp_mb__after_atomic_dec();
if (atomic_dec_and_test(&tgt->sess_count))
wake_up_all(&tgt->waitQ);
}
out:
TRACE_EXIT();
@@ -1415,7 +1412,6 @@ out:
out_free_sess:
kfree(sess);
smp_mb__before_atomic_dec();
if (atomic_dec_and_test(&tgt->sess_count))
wake_up_all(&tgt->waitQ);
/* go through */

View File

@@ -433,6 +433,7 @@ static inline void scst_dec_on_dev_cmd(struct scst_cmd *cmd)
static inline void scst_inc_cmd_count(void)
{
atomic_inc(&scst_cmd_count);
/* It's needed to be before test_bit(SCST_FLAG_SUSPENDED) */
smp_mb__after_atomic_inc();
TRACE_DBG("Incrementing scst_cmd_count(%d)",
atomic_read(&scst_cmd_count));
@@ -442,7 +443,6 @@ static inline void scst_dec_cmd_count(void)
{
int f;
f = atomic_dec_and_test(&scst_cmd_count);
smp_mb__after_atomic_dec();
if (f && unlikely(test_bit(SCST_FLAG_SUSPENDED, &scst_flags)))
wake_up_all(&scst_dev_cmd_waitQ);
TRACE_DBG("Decrementing scst_cmd_count(%d)",
@@ -458,11 +458,8 @@ static inline void scst_sess_get(struct scst_session *sess)
static inline void scst_sess_put(struct scst_session *sess)
{
smp_mb__before_atomic_dec();
if (atomic_dec_and_test(&sess->refcnt)) {
smp_mb__after_atomic_dec();
if (atomic_dec_and_test(&sess->refcnt))
scst_sched_session_free(sess);
}
}
void __scst_suspend_activity(void);