target: Fix VERIFY and WRITE VERIFY command parsing
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/6 target: Fix VERIFY and WRITE VERIFY command parsing
Use the value of the BYTCHK field to determine the size of the Data-Out buffer. For VERIFY, honor the VRPROTECT, DPO and FUA fields. This patch avoids that LIO complains about a mismatch between the expected transfer length and the SCSI CDB length if the value of the BYTCHK field is 0.
--- drivers/target/target_core_sbc.c | 71 +++++++++++++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 9 deletions(-)
drivers/target/target_core_sbc.c +62 -9
@@ -828,6 +828,59 @@ sbc_check_dpofua(struct se_device *dev, struct se_cmd *cmd, unsigned char *cdb)return 0 ; } +/** +* sbc_parse_verify - parse VERIFY, VERIFY_16 and WRITE VERIFY commands +* @cmd: (in) structure that describes the SCSI command to be parsed. +* @sectors: (out) Number of logical blocks on the storage medium that will be +* affected by the SCSI command. +* @bufflen: (out) Expected length of the SCSI Data-Out buffer. +*/ +static sense_reason_t sbc_parse_verify (struct se_cmd *cmd,int *sectors, +u32 *bufflen) +{ +struct se_device *dev = cmd->se_dev; +u8 *cdb = cmd->t_task_cdb; +u8 bytchk = (cdb[1 ] >>1 ) &3 ; +sense_reason_t ret; + +switch (cdb[0 ]) { +case VERIFY : +case WRITE_VERIFY : + *sectors =transport_get_sectors_10 (cdb); + cmd->t_task_lba =transport_lba_32 (cdb); +break ; +case VERIFY_16 : + *sectors =transport_get_sectors_16 (cdb); + cmd->t_task_lba =transport_lba_64 (cdb); +break ; +default : +WARN_ON_ONCE (true); +return TCM_UNSUPPORTED_SCSI_OPCODE ; + } + +if (sbc_check_dpofua (dev, cmd, cdb)) +return TCM_INVALID_CDB_FIELD ; + + ret =sbc_check_prot (dev, cmd, cdb, *sectors, true); +if (ret) +return ret; + +switch (bytchk) { +case 0 : + *bufflen =0 ; +break ; +case 1 : + *bufflen =sbc_get_size (cmd, *sectors); + cmd->se_cmd_flags |=SCF_SCSI_DATA_CDB ; +break ; +default : +pr_err ("Unsupported BYTCHK value %d for SCSI opcode %#x\n" , + bytchk, cdb[0 ]); +return TCM_INVALID_CDB_FIELD ; + } +return TCM_NO_SENSE ; +} +sense_reason_t sbc_parse_cdb (struct se_cmd *cmd,struct sbc_ops *ops) {
@@ -895,7 +948,6 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) cmd->execute_cmd = sbc_execute_rw;break ;case WRITE_10 : -case WRITE_VERIFY : sectors =transport_get_sectors_10 (cdb); cmd->t_task_lba =transport_lba_32 (cdb);
@@ -909,6 +961,12 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) cmd->se_cmd_flags |=SCF_SCSI_DATA_CDB ; cmd->execute_cmd = sbc_execute_rw;break ; +case WRITE_VERIFY : + ret =sbc_parse_verify (cmd, §ors, &size); +if (ret) +return ret; + cmd->execute_cmd = sbc_execute_rw; + goto check_lba;case WRITE_12 : sectors =transport_get_sectors_12 (cdb); cmd->t_task_lba =transport_lba_32 (cdb);
@@ -1106,14 +1164,9 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)break ;case VERIFY :case VERIFY_16 : - size =0 ; -if (cdb[0 ] ==VERIFY ) { - sectors =transport_get_sectors_10 (cdb); - cmd->t_task_lba =transport_lba_32 (cdb); - }else { - sectors =transport_get_sectors_16 (cdb); - cmd->t_task_lba =transport_lba_64 (cdb); - } + ret =sbc_parse_verify (cmd, §ors, &size); +if (ret) +return ret; cmd->execute_cmd = sbc_emulate_noop; goto check_lba;case REZERO_UNIT :
Signature · 1 line
2.12.0
Nicholas A. Bellinger
AppliedQuoted 6 lines · Bart Van Assche
Use the value of the BYTCHK field to determine the size of the Data-Out buffer. For VERIFY, honor the VRPROTECT, DPO and FUA fields. This patch avoids that LIO complains about a mismatch between the expected transfer length and the SCSI CDB length if the value of the BYTCHK field is 0.
Quoted 6 lines
Signed-off-by Bart Van Assche <[email protected]>Cc Max Lohrmann <[email protected]>Cc <[email protected]>--- drivers/target/target_core_sbc.c | 71 +++++++++++++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 9 deletions(-)
Applied, but dropping the unnecessary stable CC'.
Since the code as-is generates a warning and doesn't fail the command, it's not a candidate for stable.
PATCH 2/6 target/iscsi: Call .iscsit_release_cmd() once
In reply to a message not in the archiveWhile releasing a command __iscsit_free_cmd() can be called multiple times but .iscsit_release_cmd() must be called only once. Hence move the .iscsit_release_cmd() call into iscsit_release_cmd(). The latter function is only called once per command. The only driver that defines the .iscsit_release_cmd() callback is the cxgbit driver so this change only affects the cxgbit driver.
--- drivers/target/iscsi/iscsi_target_util.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/target/iscsi/iscsi_target_util.c +9 -6
@@ -691,11 +691,17 @@ void iscsit_release_cmd(struct iscsi_cmd *cmd) {struct iscsi_session *sess;struct se_cmd *se_cmd = &cmd->se_cmd; +struct iscsi_conn *conn = cmd->conn; +void (*release)(struct iscsi_conn *,struct iscsi_cmd *); -if (cmd->conn) - sess = cmd->conn->sess; -else +if (conn) { + sess = conn->sess; + release = conn->conn_transport->iscsit_release_cmd; +if (release) +release (conn, cmd); + }else { sess = cmd->sess; + }BUG_ON (!sess || !sess->se_sess);
@@ -728,9 +734,6 @@ void __iscsit_free_cmd(struct iscsi_cmd *cmd, bool scsi_cmd,iscsit_remove_cmd_from_immediate_queue (cmd, conn);iscsit_remove_cmd_from_response_queue (cmd, conn); } - -if (conn && conn->conn_transport->iscsit_release_cmd) - conn->conn_transport->iscsit_release_cmd (conn, cmd); }void iscsit_free_cmd (struct iscsi_cmd *cmd,bool shutdown)
Signature · 1 line
2.12.0
Nicholas A. Bellinger
AppliedRe: [PATCH 2/6] target/iscsi: Call .iscsit_release_cmd() once
Quoted 7 lines · Bart Van Assche
While releasing a command
__iscsit_free_cmd()can be called multiple times but .iscsit_release_cmd() must be called only once. Hence move the .iscsit_release_cmd() call intoiscsit_release_cmd(). The latter function is only called once per command. The only driver that defines the .iscsit_release_cmd() callback is the cxgbit driver so this change only affects the cxgbit driver.
Quoted 9 lines
Fixes 7ec811a8e9c3 ("iscsi-target: add void (*iscsit_release_cmd)()")Signed-off-by Bart Van Assche <[email protected]>Cc Varun Prakash <[email protected]>Cc Nicholas Bellinger <[email protected]>Cc <[email protected]>--- drivers/target/iscsi/iscsi_target_util.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
Applied to target-pending/for-next, but dropping the stable CC' because the single caller in cxgbit_release_cmd() is already checking to ensure resources are only released on the first invocation.
So it's not a bug-fix.
Quoted 14 lines
drivers/target/iscsi/iscsi_target_util.c +2
-3@@ -691,11 +691,17 @@ void iscsit_release_cmd(struct iscsi_cmd *cmd) {struct iscsi_session *sess;struct se_cmd *se_cmd = &cmd->se_cmd; +struct iscsi_conn *conn = cmd->conn; +void (*release)(struct iscsi_conn *,struct iscsi_cmd *); -if (cmd->conn) - sess = cmd->conn->sess; -else
drivers/target/iscsi/iscsi_target_util.c void iscsit_release_cmd(struct iscsi_cmd *cmd) · line 706
Quoted 10 lines
drivers/target/iscsi/iscsi_target_util.c +7
-0+if (conn) { + sess = conn->sess; + release = conn->conn_transport->iscsit_release_cmd; +if (release) +release (conn, cmd); + }else { sess = cmd->sess; + }BUG_ON (!sess || !sess->se_sess);
Also, no need for a local (*release) function pointer and extra assignment.
Dropping that part now, and squashing into the original patch.
Re: [PATCH 2/6] target/iscsi: Call .iscsit_release_cmd() once
Hi Nicholas and Bart,
Quoted 18 lines · Nicholas A. Bellinger
Quoted 7 lines · Bart Van Assche
While releasing a command
__iscsit_free_cmd()can be called multiple times but .iscsit_release_cmd() must be called only once. Hence move the .iscsit_release_cmd() call intoiscsit_release_cmd(). The latter function is only called once per command. The only driver that defines the .iscsit_release_cmd() callback is the cxgbit driver so this change only affects the cxgbit driver.Quoted 9 lines
Fixes 7ec811a8e9c3 ("iscsi-target: add void (*iscsit_release_cmd)()")Signed-off-by Bart Van Assche <[email protected]>Cc Varun Prakash <[email protected]>Cc Nicholas Bellinger <[email protected]>Cc <[email protected]>--- drivers/target/iscsi/iscsi_target_util.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
Quoted 5 lines
Applied to target-pending/for-next, but dropping the stable CC' because the single caller in
cxgbit_release_cmd()is already checking to ensure resources are only released on the first invocation.So it's not a bug-fix.
In case of DDP cxgbit driver assigns cmd->se_cmd.t_data_sg to ttinfo->sgl and calls dma_map_sg(), cxgbit_release_cmd() calls dma_unmap_sg(), it needs a valid sg(ttinfo->sgl), before calling iscsit_release_cmd() cmd->se_cmd.t_data_sg gets freed so ttinfo->sgl will not be valid if we move ->iscsit_release_cmd() to iscsit_release_cmd().
Thanks
Varun
Re: [PATCH 2/6] target/iscsi: Call .iscsit_release_cmd() once
Hi Nicholas,
Quoted 25 lines · Varun Prakash
Hi Nicholas and Bart,
Quoted 22 lines · Nicholas A. Bellinger
Quoted 7 lines · Bart Van Assche
While releasing a command
__iscsit_free_cmd()can be called multiple times but .iscsit_release_cmd() must be called only once. Hence move the .iscsit_release_cmd() call intoiscsit_release_cmd(). The latter function is only called once per command. The only driver that defines the .iscsit_release_cmd() callback is the cxgbit driver so this change only affects the cxgbit driver.Quoted 9 lines
Fixes 7ec811a8e9c3 ("iscsi-target: add void (*iscsit_release_cmd)()")Signed-off-by Bart Van Assche <[email protected]>Cc Varun Prakash <[email protected]>Cc Nicholas Bellinger <[email protected]>Cc <[email protected]>--- drivers/target/iscsi/iscsi_target_util.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)Applied to target-pending/for-next, but dropping the stable CC' because the single caller in
cxgbit_release_cmd()is already checking to ensure resources are only released on the first invocation.
Quoted 7 lines
Quoted 1 line
So it's not a bug-fix.
In case of DDP cxgbit driver assigns
cmd->se_cmd.t_data_sgtottinfo->sgland callsdma_map_sg(),cxgbit_release_cmd()callsdma_unmap_sg(), it needs a validsg(ttinfo->sgl), before callingiscsit_release_cmd()cmd->se_cmd.t_data_sggets freed sottinfo->sglwill not be valid if we move ->iscsit_release_cmd() toiscsit_release_cmd().
Please drop this patch, it will regress cxgbit driver, with this patch scatterlist is freed before calling ->iscsit_release_cmd(), cxgbit calls dma_unmap_sg() so scatterlist should not be freed before calling ->iscst_release_cmd().
Thanks
Varun
Re: [PATCH 2/6] target/iscsi: Call .iscsit_release_cmd() once
Quoted 36 lines · Varun Prakash
Hi Nicholas,
Quoted 25 lines · Varun Prakash
Hi Nicholas and Bart,
Quoted 22 lines · Nicholas A. Bellinger
Quoted 7 lines · Bart Van Assche
While releasing a command
__iscsit_free_cmd()can be called multiple times but .iscsit_release_cmd() must be called only once. Hence move the .iscsit_release_cmd() call intoiscsit_release_cmd(). The latter function is only called once per command. The only driver that defines the .iscsit_release_cmd() callback is the cxgbit driver so this change only affects the cxgbit driver.Quoted 9 lines
Fixes 7ec811a8e9c3 ("iscsi-target: add void (*iscsit_release_cmd)()")Signed-off-by Bart Van Assche <[email protected]>Cc Varun Prakash <[email protected]>Cc Nicholas Bellinger <[email protected]>Cc <[email protected]>--- drivers/target/iscsi/iscsi_target_util.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)Applied to target-pending/for-next, but dropping the stable CC' because the single caller in
cxgbit_release_cmd()is already checking to ensure resources are only released on the first invocation.Quoted 7 lines
Quoted 1 line
So it's not a bug-fix.
In case of DDP cxgbit driver assigns
cmd->se_cmd.t_data_sgtottinfo->sgland callsdma_map_sg(),cxgbit_release_cmd()callsdma_unmap_sg(), it needs a validsg(ttinfo->sgl), before callingiscsit_release_cmd()cmd->se_cmd.t_data_sggets freed sottinfo->sglwill not be valid if we move ->iscsit_release_cmd() toiscsit_release_cmd().
Quoted 5 lines
Please drop this patch, it will regress cxgbit driver, with this patch scatterlist is freed before calling ->iscsit_release_cmd(), cxgbit calls
dma_unmap_sg()so scatterlist should not be freed before calling ->iscst_release_cmd().
Thanks for the heads up. Dropping this patch for now.
To address this, AFAICT the cleanest approach is to simply do the unmapping of DDP SGLs currently done by cxgbit_release_cmd(), directly from a cxgbit specific iscsit_transport->iscsit_queue_rsp() callback.
That way, we can unmap the DDP SGLs immediately before invoking iscsit_queue_rsp() from a cxgbit specific handler, and drop the iscsi_transport->iscsit_release_cmd() callback alltogether.
WDYT..?
Re: [PATCH 2/6] target/iscsi: Call .iscsit_release_cmd() once
Quoted 45 lines · Nicholas A. Bellinger
Quoted 32 lines · Varun Prakash
Quoted 23 lines · Varun Prakash
Quoted 22 lines · Nicholas A. Bellinger
Quoted 7 lines · Bart Van Assche
While releasing a command
__iscsit_free_cmd()can be called multiple times but .iscsit_release_cmd() must be called only once. Hence move the .iscsit_release_cmd() call intoiscsit_release_cmd(). The latter function is only called once per command. The only driver that defines the .iscsit_release_cmd() callback is the cxgbit driver so this change only affects the cxgbit driver.Quoted 9 lines
Fixes 7ec811a8e9c3 ("iscsi-target: add void (*iscsit_release_cmd)()")Signed-off-by Bart Van Assche <[email protected]>Cc Varun Prakash <[email protected]>Cc Nicholas Bellinger <[email protected]>Cc <[email protected]>--- drivers/target/iscsi/iscsi_target_util.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)Applied to target-pending/for-next, but dropping the stable CC' because the single caller in
cxgbit_release_cmd()is already checking to ensure resources are only released on the first invocation.Quoted 7 lines
Quoted 1 line
So it's not a bug-fix.
In case of DDP cxgbit driver assigns
cmd->se_cmd.t_data_sgtottinfo->sgland callsdma_map_sg(),cxgbit_release_cmd()callsdma_unmap_sg(), it needs a validsg(ttinfo->sgl), before callingiscsit_release_cmd()cmd->se_cmd.t_data_sggets freed sottinfo->sglwill not be valid if we move ->iscsit_release_cmd() toiscsit_release_cmd().Quoted 5 lines
Please drop this patch, it will regress cxgbit driver, with this patch scatterlist is freed before calling ->iscsit_release_cmd(), cxgbit calls
dma_unmap_sg()so scatterlist should not be freed before calling ->iscst_release_cmd().Thanks for the heads up. Dropping this patch for now.
To address this, AFAICT the cleanest approach is to simply do the unmapping of DDP SGLs currently done by
cxgbit_release_cmd(), directly from a cxgbit specificiscsit_transport->iscsit_queue_rsp()callback.
Quoted 5 lines
That way, we can unmap the DDP SGLs immediately before invoking
iscsit_queue_rsp()from a cxgbit specific handler, and drop theiscsi_transport->iscsit_release_cmd()callback alltogether.WDYT..?
This approach will work in success case, but in failure cases(digest errors, ...) ->iscsit_queue_status() is not called so dma umap will not happen.
Re: [PATCH 2/6] target/iscsi: Call .iscsit_release_cmd() once
Hi Varun,
Quoted 1 line · Varun Prakash
On Mon, May 01, 2017 at 09:33:31PM -0700, Nicholas A. Bellinger wrote:
<SNIP>
Quoted 10 lines
Quoted 10 lines
Thanks for the heads up. Dropping this patch for now.
To address this, AFAICT the cleanest approach is to simply do the unmapping of DDP SGLs currently done by
cxgbit_release_cmd(), directly from a cxgbit specificiscsit_transport->iscsit_queue_rsp()callback.That way, we can unmap the DDP SGLs immediately before invoking
iscsit_queue_rsp()from a cxgbit specific handler, and drop theiscsi_transport->iscsit_release_cmd()callback alltogether.
Quoted 5 lines
Quoted 1 line
WDYT..?
This approach will work in success case, but in failure
cases(digest errors, ...)->iscsit_queue_status() is not called so dma umap will not happen.
Indeed.
Looking at other hw drivers like qla2xxx that have this same requirement, they do *_unmap_sg() once a completion interrupt has triggered, but before target_core_fabric_ops->release_cmd() is invoked and se_cmd->t_task_sg has already been freed.
So I'm open to adding a target_core_fabric_ops->unmap_sg() to do this ahead of target_core_transport.c:transport_free_pages().
That said, snother option is to perform *_unmap_sg() internally in cxgbit once DDP completion for WRITEs has completed, but before it's submitted into iscsi_target -> target_core.
AFAICT from a quick scan of cxgbit code, the two scenarios for this would be:
*) For ISCSI_OP_SCSI_CMD with immediate data, once cxgbit_get_immediate_data() is invoked. Either for all cases when this is invoked (eg: does the DDP SGLs both immediate, unsolicited and solicited data when mapped..?), or only when iscsi_cmd->immediate_data = 1 && iscsi_cmd_flags & ICF_GOT_LAST_DATAOUT is true.
*) For ISCSI_OP_SCSI_DATA_OUT with FINAL_BIT set, before iscsit_check_dataout_payload() is called to invoke target_execute_cmd()
WDYT..?
Re: [PATCH 2/6] target/iscsi: Call .iscsit_release_cmd() once
Quoted 30 lines · Nicholas A. Bellinger
Hi Varun,
Quoted 1 line · Varun Prakash
On Mon, May 01, 2017 at 09:33:31PM -0700, Nicholas A. Bellinger wrote:
<SNIP>
Indeed.
Looking at other hw drivers like qla2xxx that have this same requirement, they do
*_unmap_sg()once a completion interrupt has triggered, but beforetarget_core_fabric_ops->release_cmd()is invoked andse_cmd->t_task_sghas already been freed.So I'm open to adding a
target_core_fabric_ops->unmap_sg()to do this ahead of target_core_transport.c:transport_free_pages().That said, snother option is to perform
*_unmap_sg()internally in cxgbit once DDP completion for WRITEs has completed, but before it's submitted intoiscsi_target->target_core.AFAICT from a quick scan of cxgbit code, the two scenarios for this would be:
*) For
ISCSI_OP_SCSI_CMDwith immediate data, oncecxgbit_get_immediate_data()is invoked. Either for all cases when this is invoked (eg: does the DDP SGLs both immediate, unsolicited and solicited data when mapped..?), or only wheniscsi_cmd->immediate_data= 1 &&iscsi_cmd_flags&ICF_GOT_LAST_DATAOUTis true.
Quoted 5 lines
*) For
ISCSI_OP_SCSI_DATA_OUTwithFINAL_BITset, beforeiscsit_check_dataout_payload()is called to invoketarget_execute_cmd()WDYT..?
Current cxgbit code does following in cxgbit_release_cmd()
1. put_page() in case of PASSTHROUGH_SG_TO_MEM_NOALLOC.
2. dma_unmap_sg() DDP SGL.
3. free hw DDP resource.
If cxgbit does cleanup internally then lot of error handling code is required in cxgbit driver, eg: - PDU with F bit set never arrives, header digest errors etc.
Another approach to add target_core_fabrics_ops->unmap_sg() will not work for ERL 2 case because for calling ->iscsit_unmap_sg() valid cmd->conn pointer is required, in case of ERL 2 cmd->conn can be NULL, but we can use this approach because in current cxgbit code I enable DDP only for ERL 0 case, similiary I can add code
to enable PASSTHROUGH_SG_TO_MEM_NOALLOC only for ERL 0 case.
Re: [PATCH 2/6] target/iscsi: Call .iscsit_release_cmd() once
In reply to Varun PrakashT24gVHVlLCAyMDE3LTA0LTA0IGF0IDEwOjM2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ZiB3 ZSBtb3ZlDQo+IC0+aXNjc2l0X3JlbGVhc2VfY21kKCkgdG8gaXNjc2l0X3JlbGVhc2VfY21kKCku DQoNCihyZXBseWluZyB0byBhbiBlLW1haWwgb2Ygc2l4IG1vbnRocyBhZ28pDQoNCkhlbGxvIFZh cnVuLA0KDQpIYXZlIHlvdSBub3RpY2VkIHRoYXQgY29tbWl0IGZlYmU1NjJjMjBkZiAodGFyZ2V0 OiBGaXggTFVOX1JFU0VUIGFjdGl2ZSBJL08NCmhhbmRsaW5nIGZvciBBQ0tfS1JFRjsgSmFudWFy eSAyMDE2KSBtb3ZlZCB0aGUgdHJhbnNwb3J0X2ZyZWVfcGFnZXMoKSBjYWxsDQpmcm9tIHRyYW5z cG9ydF9wdXRfY21kKCkgdG8gdGFyZ2V0X3JlbGVhc2VfY21kX2tyZWYoKT8gSSB0aGluayB0aGF0 IG1lYW5zDQp0aGF0IGl0IGlzIG5vdyBzYWZlIHRvIGNhbGwgLmlzY3NpdF9yZWxlYXNlX2NtZCgp IGFmdGVyDQp0cmFuc3BvcnRfZ2VuZXJpY19mcmVlX2NtZCgpLg0KDQpUaGFua3MsDQoNCkJhcnQu
Re: [PATCH 2/6] target/iscsi: Call .iscsit_release_cmd() once
Quoted 24 lines · Bart Van Assche
Quoted 9 lines · Varun Prakash
Quoted 8 lines · Nicholas A. Bellinger
Quoted 7 lines · Bart Van Assche
While releasing a command
__iscsit_free_cmd()can be called multiple times but .iscsit_release_cmd() must be called only once. Hence move the .iscsit_release_cmd() call intoiscsit_release_cmd(). The latter function is only called once per command. The only driver that defines the .iscsit_release_cmd() callback is the cxgbit driver so this change only affects the cxgbit driver.Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Fixes 7ec811a8e9c3 ("iscsi-target: add void (*iscsit_release_cmd)()")Signed-off-by Bart Van Assche <[email protected]>Cc Varun Prakash <[email protected]>Cc Nicholas Bellinger <[email protected]>Cc <[email protected]>--- drivers/target/iscsi/iscsi_target_util.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)(replying to an e-mail of six months ago)
Quoted 8 lines
Hello Varun,
Have you noticed that commit
febe562c20df(target: FixLUN_RESETactive I/O handling forACK_KREF; January 2016) moved thetransport_free_pages()call fromtransport_put_cmd()totarget_release_cmd_kref()? I think that means that it is now safe to call .iscsit_release_cmd() aftertransport_generic_free_cmd().
Hello Bart,
The requirement here is to call .iscsit_release_cmd() before target free the pages so that cxgbit driver can call dma_unmap_sg() and free the pages in case of PASSTHROUGH_SG_TO_MEM_NOALLOC.
Currently .iscsit_release_cmd() is called from two functions -
iscsit_free_cmd() -> __iscsit_free_cmd() -> .iscsit_release_cmd() iscsit_aborted_task() -> __iscsit_free_cmd() -> .iscsit_release_cmd()
If we move .iscsit_release_cmd() after transport_generic_free_cmd(), will it handle all the error cases(abort etc)?
In case of abort currently it is called from iscsit_aborted_task(), if we move then in case of abort .iscsit_release_cmd() will not be called.
If we can confirm that moving .iscsit_release_cmd() will not cause any memory leak then we can move it.
Thanks
Varun