aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/vhost
diff options
context:
space:
mode:
authorNicholas Bellinger <nab@linux-iscsi.org>2013-06-06 05:20:41 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2013-06-20 17:10:47 -0400
commit084ed45b3846ffb803a6cd6d631c1723e77689e0 (patch)
treefac8ae85cc4aff3a7fe01200e188757c00c8f404 /drivers/vhost
parent6c131d0c583cd5ceb2b497ae2dbeeae180d3573d (diff)
vhost/scsi: Convert to se_cmd->cmd_kref TARGET_SCF_ACK_KREF usage
This patch coverts vhost/scsi to se_cmd->cmd_kref TARGET_SCF_ACK_KREF usage, instead of assuming that vhost_scsi_free_cmd() is always called before TCM processing is completed in the response fast path. This includes adding vhost_scsi_check_stop_free() -> target_put_sess_cmd() to perform the second se_cmd->cmd_kref put, and moving vhost_scsi_free_cmd() resource release into tcm_vhost_release_cmd() that is invoked once the last se_cmd->cmd_kref put occurs. Cc: Christoph Hellwig <hch@lst.de> Cc: Roland Dreier <roland@kernel.org> Cc: Kent Overstreet <koverstreet@google.com> Cc: Asias He <asias@redhat.com> Cc: Michael S. Tsirkin <mst@redhat.com> Cc: Or Gerlitz <ogerlitz@mellanox.com> Cc: Moussa Ba <moussaba@micron.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/vhost')
-rw-r--r--drivers/vhost/scsi.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index aacf71ea001e..1e5e82042f84 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -446,7 +446,19 @@ static u32 tcm_vhost_tpg_get_inst_index(struct se_portal_group *se_tpg)
446 446
447static void tcm_vhost_release_cmd(struct se_cmd *se_cmd) 447static void tcm_vhost_release_cmd(struct se_cmd *se_cmd)
448{ 448{
449 return; 449 struct tcm_vhost_cmd *tv_cmd = container_of(se_cmd,
450 struct tcm_vhost_cmd, tvc_se_cmd);
451
452 if (tv_cmd->tvc_sgl_count) {
453 u32 i;
454 for (i = 0; i < tv_cmd->tvc_sgl_count; i++)
455 put_page(sg_page(&tv_cmd->tvc_sgl[i]));
456
457 kfree(tv_cmd->tvc_sgl);
458 }
459
460 tcm_vhost_put_inflight(tv_cmd->inflight);
461 kfree(tv_cmd);
450} 462}
451 463
452static int tcm_vhost_shutdown_session(struct se_session *se_sess) 464static int tcm_vhost_shutdown_session(struct se_session *se_sess)
@@ -559,17 +571,11 @@ static void vhost_scsi_free_cmd(struct tcm_vhost_cmd *tv_cmd)
559 /* TODO locking against target/backend threads? */ 571 /* TODO locking against target/backend threads? */
560 transport_generic_free_cmd(se_cmd, 0); 572 transport_generic_free_cmd(se_cmd, 0);
561 573
562 if (tv_cmd->tvc_sgl_count) { 574}
563 u32 i;
564 for (i = 0; i < tv_cmd->tvc_sgl_count; i++)
565 put_page(sg_page(&tv_cmd->tvc_sgl[i]));
566
567 kfree(tv_cmd->tvc_sgl);
568 }
569
570 tcm_vhost_put_inflight(tv_cmd->inflight);
571 575
572 kfree(tv_cmd); 576static int vhost_scsi_check_stop_free(struct se_cmd *se_cmd)
577{
578 return target_put_sess_cmd(se_cmd->se_sess, se_cmd);
573} 579}
574 580
575static void tcm_vhost_do_evt_work(struct vhost_scsi *vs, 581static void tcm_vhost_do_evt_work(struct vhost_scsi *vs,
@@ -847,7 +853,7 @@ static void tcm_vhost_submission_work(struct work_struct *work)
847 tv_cmd->tvc_cdb, &tv_cmd->tvc_sense_buf[0], 853 tv_cmd->tvc_cdb, &tv_cmd->tvc_sense_buf[0],
848 tv_cmd->tvc_lun, tv_cmd->tvc_exp_data_len, 854 tv_cmd->tvc_lun, tv_cmd->tvc_exp_data_len,
849 tv_cmd->tvc_task_attr, tv_cmd->tvc_data_direction, 855 tv_cmd->tvc_task_attr, tv_cmd->tvc_data_direction,
850 0, sg_ptr, tv_cmd->tvc_sgl_count, 856 TARGET_SCF_ACK_KREF, sg_ptr, tv_cmd->tvc_sgl_count,
851 sg_bidi_ptr, sg_no_bidi); 857 sg_bidi_ptr, sg_no_bidi);
852 if (rc < 0) { 858 if (rc < 0) {
853 transport_send_check_condition_and_sense(se_cmd, 859 transport_send_check_condition_and_sense(se_cmd,
@@ -2008,6 +2014,7 @@ static struct target_core_fabric_ops tcm_vhost_ops = {
2008 .tpg_release_fabric_acl = tcm_vhost_release_fabric_acl, 2014 .tpg_release_fabric_acl = tcm_vhost_release_fabric_acl,
2009 .tpg_get_inst_index = tcm_vhost_tpg_get_inst_index, 2015 .tpg_get_inst_index = tcm_vhost_tpg_get_inst_index,
2010 .release_cmd = tcm_vhost_release_cmd, 2016 .release_cmd = tcm_vhost_release_cmd,
2017 .check_stop_free = vhost_scsi_check_stop_free,
2011 .shutdown_session = tcm_vhost_shutdown_session, 2018 .shutdown_session = tcm_vhost_shutdown_session,
2012 .close_session = tcm_vhost_close_session, 2019 .close_session = tcm_vhost_close_session,
2013 .sess_get_index = tcm_vhost_sess_get_index, 2020 .sess_get_index = tcm_vhost_sess_get_index,