Nicholas Bellinger 96330e5ec1 target: Fix percpu_ref_put race in transport_lun_remove_cmd
commit 5259a06ef97068b710f45d092a587e8d740f750f upstream.

This patch fixes a percpu_ref_put race for se_lun->lun_ref in
transport_lun_remove_cmd() where ->lun_ref could end up being
put more than once per command via different target completion
and fabric release contexts.

It adds a cmpxchg() for se_cmd->lun_ref_active to ensure that
percpu_ref_put() is only ever called once per se_cmd.

This bug was manifesting itself as a LUN shutdown regression
bug in >= v3.13 code, where percpu_ref_kill() would end up
hanging indefinately due to the incorrect percpu_ref count.

(Change se_cmd->lun_ref_active from bool -> int to force at
 least a 4-byte cmpxchg with MIPS ll/sc ins. - Fengguang)

Reported-by: Tommy Apel <tommyapeldk@gmail.com>
Cc: Tommy Apel <tommyapeldk@gmail.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-02-13 13:55:41 -08:00
..
2013-11-19 15:53:02 -05:00
2013-11-07 19:24:20 +01:00
2014-02-06 11:33:50 -08:00
2014-02-13 13:55:40 -08:00
2014-02-13 13:55:26 -08:00
2014-02-06 11:34:01 -08:00
2014-02-06 11:34:00 -08:00
2013-12-10 08:48:15 +01:00