]> git.baikalelectronics.ru Git - kernel.git/commit
target: Fix percpu_ref_put race in transport_lun_remove_cmd
authorNicholas Bellinger <nab@linux-iscsi.org>
Wed, 29 Jan 2014 01:56:30 +0000 (17:56 -0800)
committerNicholas Bellinger <nab@linux-iscsi.org>
Thu, 30 Jan 2014 11:58:34 +0000 (03:58 -0800)
commit856a503c8f7a025c624ae215fae8b2f4f6fc5a4d
treeda2b4c9718b41cec6e5057a3da593cc93c44759c
parenta101716d4c36f5641291a1e7d002a9c8d2cd8545
target: Fix percpu_ref_put race in transport_lun_remove_cmd

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>
Cc: <stable@vger.kernel.org> #3.13+
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_transport.c
include/target/target_core_base.h