From 27ed60c19d38684a76a56305e25aa220ab624287 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Mon, 25 Oct 2010 13:09:47 +0000 Subject: [PATCH] Let's be safe and always do memory barrier after all *_get(). git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@2462 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/iscsi.c | 2 +- iscsi-scst/kernel/iscsi.h | 20 ++++++++------------ scst/src/dev_handlers/scst_user.c | 21 +++++++-------------- 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/iscsi-scst/kernel/iscsi.c b/iscsi-scst/kernel/iscsi.c index a789592f2..f7678c4e8 100644 --- a/iscsi-scst/kernel/iscsi.c +++ b/iscsi-scst/kernel/iscsi.c @@ -3166,7 +3166,7 @@ static void iscsi_preprocessing_done(struct scst_cmd *scst_cmd) * because there can be only one read thread processing * connection. */ - cmnd_get_ordered(req); + cmnd_get(req); req->scst_state = ISCSI_CMD_STATE_AFTER_PREPROC; iscsi_make_conn_rd_active(req->conn); if (unlikely(req->conn->closing)) { diff --git a/iscsi-scst/kernel/iscsi.h b/iscsi-scst/kernel/iscsi.h index b238d0b99..69a6f1f40 100644 --- a/iscsi-scst/kernel/iscsi.h +++ b/iscsi-scst/kernel/iscsi.h @@ -679,12 +679,10 @@ static inline void cmnd_get(struct iscsi_cmnd *cmnd) atomic_inc(&cmnd->ref_cnt); TRACE_DBG("cmnd %p, new cmnd->ref_cnt %d", cmnd, atomic_read(&cmnd->ref_cnt)); -} - -static inline void cmnd_get_ordered(struct iscsi_cmnd *cmnd) -{ - cmnd_get(cmnd); - /* See comments for each cmnd_get_ordered() use */ + /* + * For the same reason as in kref_get(). Let's be safe and + * always do it. + */ smp_mb__after_atomic_inc(); } @@ -767,12 +765,10 @@ static inline void conn_get(struct iscsi_conn *conn) atomic_inc(&conn->conn_ref_cnt); TRACE_DBG("conn %p, new conn_ref_cnt %d", conn, atomic_read(&conn->conn_ref_cnt)); -} - -static inline void conn_get_ordered(struct iscsi_conn *conn) -{ - conn_get(conn); - /* See comments for each conn_get_ordered() use */ + /* + * For the same reason as in kref_get(). Let's be safe and + * always do it. + */ smp_mb__after_atomic_inc(); } diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index 5f3e8955a..433d806cf 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -280,22 +280,15 @@ static inline bool ucmd_get_check(struct scst_user_cmd *ucmd) return res; } -static inline void __ucmd_get(struct scst_user_cmd *ucmd, bool barrier) +static inline void ucmd_get(struct scst_user_cmd *ucmd) { TRACE_DBG("ucmd %p, ucmd_ref %d", ucmd, atomic_read(&ucmd->ucmd_ref)); atomic_inc(&ucmd->ucmd_ref); - if (barrier) - smp_mb__after_atomic_inc(); -} - -static inline void ucmd_get_ordered(struct scst_user_cmd *ucmd) -{ - __ucmd_get(ucmd, true); -} - -static inline void ucmd_get(struct scst_user_cmd *ucmd) -{ - __ucmd_get(ucmd, false); + /* + * For the same reason as in kref_get(). Let's be safe and + * always do it. + */ + smp_mb__after_atomic_inc(); } /* Must not be called under cmd_list_lock!! */ @@ -1412,7 +1405,7 @@ static int dev_user_process_reply_exec(struct scst_user_cmd *ucmd, * Otherwise, due to reorder, in dev_user_process_reply() * it is possible that ucmd is destroyed before it "got" here. */ - ucmd_get_ordered(ucmd); + ucmd_get(ucmd); ucmd->background_exec = 1; TRACE_DBG("Background ucmd %p", ucmd); goto out_compl;