diff options
| -rw-r--r-- | drivers/target/target_core_transport.c | 5 | ||||
| -rw-r--r-- | include/target/target_core_base.h | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 51a9736be726..c50fd9f11aab 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c | |||
| @@ -594,10 +594,11 @@ static void transport_lun_remove_cmd(struct se_cmd *cmd) | |||
| 594 | { | 594 | { |
| 595 | struct se_lun *lun = cmd->se_lun; | 595 | struct se_lun *lun = cmd->se_lun; |
| 596 | 596 | ||
| 597 | if (!lun || !cmd->lun_ref_active) | 597 | if (!lun) |
| 598 | return; | 598 | return; |
| 599 | 599 | ||
| 600 | percpu_ref_put(&lun->lun_ref); | 600 | if (cmpxchg(&cmd->lun_ref_active, true, false)) |
| 601 | percpu_ref_put(&lun->lun_ref); | ||
| 601 | } | 602 | } |
| 602 | 603 | ||
| 603 | void transport_cmd_finish_abort(struct se_cmd *cmd, int remove) | 604 | void transport_cmd_finish_abort(struct se_cmd *cmd, int remove) |
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index d28418645b00..909dacbd230f 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h | |||
| @@ -552,7 +552,7 @@ struct se_cmd { | |||
| 552 | void *priv; | 552 | void *priv; |
| 553 | 553 | ||
| 554 | /* Used for lun->lun_ref counting */ | 554 | /* Used for lun->lun_ref counting */ |
| 555 | bool lun_ref_active; | 555 | int lun_ref_active; |
| 556 | 556 | ||
| 557 | /* DIF related members */ | 557 | /* DIF related members */ |
| 558 | enum target_prot_op prot_op; | 558 | enum target_prot_op prot_op; |
