diff options
| author | Joern Engel <joern@logfs.org> | 2014-09-16 16:23:12 -0400 |
|---|---|---|
| committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2014-10-01 17:39:06 -0400 |
| commit | 33940d09937276cd3c81f2874faf43e37c2db0e2 (patch) | |
| tree | 2c3043e6902ee4e8e23b947f2e30e50967e99c5b /drivers/target/loopback | |
| parent | 74ed7e62289dc6d388996d7c8f89c2e7e95b9657 (diff) | |
target: encapsulate smp_mb__after_atomic()
The target code has a rather generous helping of smp_mb__after_atomic()
throughout the code base. Most atomic operations were followed by one
and none were preceded by smp_mb__before_atomic(), nor accompanied by a
comment explaining the need for a barrier.
Instead of trying to prove for every case whether or not it is needed,
this patch introduces atomic_inc_mb() and atomic_dec_mb(), which
explicitly include the memory barriers before and after the atomic
operation. For now they are defined in a target header, although they
could be of general use.
Most of the existing atomic/mb combinations were replaced by the new
helpers. In a few cases the atomic was sandwiched in
spin_lock/spin_unlock and I simply removed the barrier.
I suspect that in most cases the correct conversion would have been to
drop the barrier. I also suspect that a few cases exist where a) the
barrier was necessary and b) a second barrier before the atomic would
have been necessary and got added by this patch.
Signed-off-by: Joern Engel <joern@logfs.org>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/loopback')
| -rw-r--r-- | drivers/target/loopback/tcm_loop.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index 340de9d92b15..a7f6dc646045 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c | |||
| @@ -960,8 +960,7 @@ static int tcm_loop_port_link( | |||
| 960 | struct tcm_loop_tpg, tl_se_tpg); | 960 | struct tcm_loop_tpg, tl_se_tpg); |
| 961 | struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; | 961 | struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; |
| 962 | 962 | ||
| 963 | atomic_inc(&tl_tpg->tl_tpg_port_count); | 963 | atomic_inc_mb(&tl_tpg->tl_tpg_port_count); |
| 964 | smp_mb__after_atomic(); | ||
| 965 | /* | 964 | /* |
| 966 | * Add Linux/SCSI struct scsi_device by HCTL | 965 | * Add Linux/SCSI struct scsi_device by HCTL |
| 967 | */ | 966 | */ |
| @@ -995,8 +994,7 @@ static void tcm_loop_port_unlink( | |||
| 995 | scsi_remove_device(sd); | 994 | scsi_remove_device(sd); |
| 996 | scsi_device_put(sd); | 995 | scsi_device_put(sd); |
| 997 | 996 | ||
| 998 | atomic_dec(&tl_tpg->tl_tpg_port_count); | 997 | atomic_dec_mb(&tl_tpg->tl_tpg_port_count); |
| 999 | smp_mb__after_atomic(); | ||
| 1000 | 998 | ||
| 1001 | pr_debug("TCM_Loop_ConfigFS: Port Unlink Successful\n"); | 999 | pr_debug("TCM_Loop_ConfigFS: Port Unlink Successful\n"); |
| 1002 | } | 1000 | } |
