diff options
author | Nicholas Bellinger <nab@daterainc.com> | 2013-08-21 19:34:43 -0700 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2013-09-10 16:46:01 -0700 |
commit | cf6d1f0964fa9db57fc660caf51939d7a03359a1 (patch) | |
tree | 444f6f52a73ad35cf2b287adf23b15a8a05c9ba2 /drivers/target | |
parent | a2890087499ae530362139aaf6c120f438e1e679 (diff) | |
download | kernel_goldelico_gta04-cf6d1f0964fa9db57fc660caf51939d7a03359a1.zip kernel_goldelico_gta04-cf6d1f0964fa9db57fc660caf51939d7a03359a1.tar.gz kernel_goldelico_gta04-cf6d1f0964fa9db57fc660caf51939d7a03359a1.tar.bz2 |
target: Release COMPARE_AND_WRITE mutex in generic failure path
This patch adds a extra check for SCF_COMPARE_AND_WRITE within
transport_generic_request_failure() to invoke the callback for
compare_and_write_callback() or compare_and_write_done(), in
order to release se_dev->caw_mutex from the generic failure
path.
It also adds to checks within compare_and_write_callback() to
avoid processing when transport_generic_request_failure() occurs
early enough that cmd->t_data_sg or cmd->t_bidi_data_sg have not
been setup yet, nor se_dev->caw_mutex obtained from within
sbc_compare_and_write().
v4 changes:
- Add explicit check for cmd->transport_complete_callback in
transport_generic_request_failure() to handle case where
sbc_compare_and_write()clears callback pointer (Dan Carpenter)
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Martin Petersen <martin.petersen@oracle.com>
Cc: Chris Mason <chris.mason@fusionio.com>
Cc: James Bottomley <JBottomley@Parallels.com>
Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r-- | drivers/target/target_core_sbc.c | 7 | ||||
-rw-r--r-- | drivers/target/target_core_transport.c | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index 5c822fd..2cd9acd 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c @@ -372,6 +372,13 @@ static sense_reason_t compare_and_write_callback(struct se_cmd *cmd) sense_reason_t ret = TCM_NO_SENSE; int rc, i; + /* + * Handle early failure in transport_generic_request_failure(), + * which will not have taken ->caw_mutex yet.. + */ + if (!cmd->t_data_sg || !cmd->t_bidi_data_sg) + return TCM_NO_SENSE; + buf = kzalloc(cmd->data_length, GFP_KERNEL); if (!buf) { pr_err("Unable to allocate compare_and_write buf\n"); diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index e53c59b..bcbc3d3 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -1559,6 +1559,13 @@ void transport_generic_request_failure(struct se_cmd *cmd, * For SAM Task Attribute emulation for failed struct se_cmd */ transport_complete_task_attr(cmd); + /* + * Handle special case for COMPARE_AND_WRITE failure, where the + * callback is expected to drop the per device ->caw_mutex. + */ + if ((cmd->se_cmd_flags & SCF_COMPARE_AND_WRITE) && + cmd->transport_complete_callback) + cmd->transport_complete_callback(cmd); switch (sense_reason) { case TCM_NON_EXISTENT_LUN: |