target: make ->shutdown_session optional
authorChristoph Hellwig <hch@lst.de>
Mon, 2 May 2016 13:45:21 +0000 (15:45 +0200)
committerNicholas Bellinger <nab@linux-iscsi.org>
Tue, 10 May 2016 08:19:18 +0000 (01:19 -0700)
Turns out the template and thus many drivers got the return value wrong:
0 means the fabrics driver needs to put a session reference, which no
driver except for the iSCSI target drivers did.  Fortunately none of these
drivers supports explicit Node ACLs, so the bug was harmless.

Even without that only qla2xxx and iscsi every did real work in
shutdown_session, so get rid of the boilerplate code in all other
drivers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
12 files changed:
Documentation/target/tcm_mod_builder.py
drivers/infiniband/ulp/srpt/ib_srpt.c
drivers/target/loopback/tcm_loop.c
drivers/target/sbp/sbp_target.c
drivers/target/target_core_configfs.c
drivers/target/target_core_tpg.c
drivers/target/tcm_fc/tcm_fc.h
drivers/target/tcm_fc/tfc_conf.c
drivers/target/tcm_fc/tfc_sess.c
drivers/usb/gadget/function/f_tcm.c
drivers/vhost/scsi.c
drivers/xen/xen-scsiback.c

index 7d370c9b1450c5fc5a2230d086026fa1c7d59ab7..6b8aa4086c5dc55a7b7de8c6eb2a0e28ef794a5b 100755 (executable)
@@ -294,7 +294,6 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
        buf += "        .tpg_check_prod_mode_write_protect = " + fabric_mod_name + "_check_false,\n"
        buf += "        .tpg_get_inst_index             = " + fabric_mod_name + "_tpg_get_inst_index,\n"
        buf += "        .release_cmd                    = " + fabric_mod_name + "_release_cmd,\n"
-       buf += "        .shutdown_session               = " + fabric_mod_name + "_shutdown_session,\n"
        buf += "        .close_session                  = " + fabric_mod_name + "_close_session,\n"
        buf += "        .sess_get_index                 = " + fabric_mod_name + "_sess_get_index,\n"
        buf += "        .sess_get_initiator_sid         = NULL,\n"
@@ -467,13 +466,6 @@ def tcm_mod_dump_fabric_ops(proto_ident, fabric_mod_dir_var, fabric_mod_name):
                        buf += "}\n\n"
                        bufi += "void " + fabric_mod_name + "_release_cmd(struct se_cmd *);\n"
 
-               if re.search('shutdown_session\)\(', fo):
-                       buf += "int " + fabric_mod_name + "_shutdown_session(struct se_session *se_sess)\n"
-                       buf += "{\n"
-                       buf += "        return 0;\n"
-                       buf += "}\n\n"
-                       bufi += "int " + fabric_mod_name + "_shutdown_session(struct se_session *);\n"
-
                if re.search('close_session\)\(', fo):
                        buf += "void " + fabric_mod_name + "_close_session(struct se_session *se_sess)\n"
                        buf += "{\n"
index 8b42401d4795646019f4498ed909b306630f19ec..3b425af04572615b5472bc1b6068327498752db7 100644 (file)
@@ -1960,14 +1960,6 @@ static void __srpt_close_all_ch(struct srpt_device *sdev)
        }
 }
 
-/**
- * srpt_shutdown_session() - Whether or not a session may be shut down.
- */
-static int srpt_shutdown_session(struct se_session *se_sess)
-{
-       return 1;
-}
-
 static void srpt_free_ch(struct kref *kref)
 {
        struct srpt_rdma_ch *ch = container_of(kref, struct srpt_rdma_ch, kref);
@@ -3287,7 +3279,6 @@ static const struct target_core_fabric_ops srpt_template = {
        .tpg_get_inst_index             = srpt_tpg_get_inst_index,
        .release_cmd                    = srpt_release_cmd,
        .check_stop_free                = srpt_check_stop_free,
-       .shutdown_session               = srpt_shutdown_session,
        .close_session                  = srpt_close_session,
        .sess_get_index                 = srpt_sess_get_index,
        .sess_get_initiator_sid         = NULL,
index 0ad5ac541a7fb59b46cbdf0d422420a0e316e6a0..0941b2c13f5ab97e9e852e81674d3bb30241924f 100644 (file)
@@ -601,11 +601,6 @@ static int tcm_loop_get_cmd_state(struct se_cmd *se_cmd)
        return tl_cmd->sc_cmd_state;
 }
 
-static int tcm_loop_shutdown_session(struct se_session *se_sess)
-{
-       return 0;
-}
-
 static void tcm_loop_close_session(struct se_session *se_sess)
 {
        return;
@@ -1243,7 +1238,6 @@ static const struct target_core_fabric_ops loop_ops = {
        .tpg_get_inst_index             = tcm_loop_get_inst_index,
        .check_stop_free                = tcm_loop_check_stop_free,
        .release_cmd                    = tcm_loop_release_cmd,
-       .shutdown_session               = tcm_loop_shutdown_session,
        .close_session                  = tcm_loop_close_session,
        .sess_get_index                 = tcm_loop_sess_get_index,
        .write_pending                  = tcm_loop_write_pending,
index c57e7884973d780bac36786b9ae1a4ea19091043..6c8b8f84a0478546d8cb43ef8d923126aa11fae2 100644 (file)
@@ -1726,11 +1726,6 @@ static void sbp_release_cmd(struct se_cmd *se_cmd)
        sbp_free_request(req);
 }
 
-static int sbp_shutdown_session(struct se_session *se_sess)
-{
-       return 0;
-}
-
 static void sbp_close_session(struct se_session *se_sess)
 {
        return;
@@ -2349,7 +2344,6 @@ static const struct target_core_fabric_ops sbp_ops = {
        .tpg_check_prod_mode_write_protect = sbp_check_false,
        .tpg_get_inst_index             = sbp_tpg_get_inst_index,
        .release_cmd                    = sbp_release_cmd,
-       .shutdown_session               = sbp_shutdown_session,
        .close_session                  = sbp_close_session,
        .sess_get_index                 = sbp_sess_get_index,
        .write_pending                  = sbp_write_pending,
index 73c23c75528ae9cf928cc561742e9d331acb4273..75c5000ca95e646efd4996c6c198c095f8015d1a 100644 (file)
@@ -385,10 +385,6 @@ static int target_fabric_tf_ops_check(const struct target_core_fabric_ops *tfo)
                pr_err("Missing tfo->release_cmd()\n");
                return -EINVAL;
        }
-       if (!tfo->shutdown_session) {
-               pr_err("Missing tfo->shutdown_session()\n");
-               return -EINVAL;
-       }
        if (!tfo->close_session) {
                pr_err("Missing tfo->close_session()\n");
                return -EINVAL;
index b1ac600f5b4579719f035ce5804f8a7fb1ae4940..a81a37045403a884fe34b1b3957fbc9ba8de46d6 100644 (file)
@@ -353,7 +353,10 @@ restart:
                list_del_init(&sess->sess_acl_list);
 
                spin_unlock_irqrestore(&acl->nacl_sess_lock, flags);
-               ret = acl->se_tpg->se_tpg_tfo->shutdown_session(sess);
+               if (acl->se_tpg->se_tpg_tfo->shutdown_session)
+                       ret = acl->se_tpg->se_tpg_tfo->shutdown_session(sess);
+               else
+                       ret = 1;
                target_put_session(sess);
                if (ret)
                        target_put_session(sess);
index c30003bd4ff07979fd6c65b6de830e79a5743a92..e28209b99b59804de51663afe0a677c91745a827 100644 (file)
@@ -139,7 +139,6 @@ extern unsigned int ft_debug_logging;
  * Session ops.
  */
 void ft_sess_put(struct ft_sess *);
-int ft_sess_shutdown(struct se_session *);
 void ft_sess_close(struct se_session *);
 u32 ft_sess_get_index(struct se_session *);
 u32 ft_sess_get_port_name(struct se_session *, unsigned char *, u32);
index 4d375e95841bc56bc1d10f9c154241aedab30df1..42ee91123dcaed297ffc8f9a3766adfb7dda39c7 100644 (file)
@@ -442,7 +442,6 @@ static const struct target_core_fabric_ops ft_fabric_ops = {
        .tpg_get_inst_index =           ft_tpg_get_inst_index,
        .check_stop_free =              ft_check_stop_free,
        .release_cmd =                  ft_release_cmd,
-       .shutdown_session =             ft_sess_shutdown,
        .close_session =                ft_sess_close,
        .sess_get_index =               ft_sess_get_index,
        .sess_get_initiator_sid =       NULL,
index d0c3e1894c61429783e50d406d528dff281b65f4..f5186a74439950631c48f9735e3d9fbed1699c30 100644 (file)
@@ -302,18 +302,6 @@ static void ft_sess_delete_all(struct ft_tport *tport)
  * TCM ops for sessions.
  */
 
-/*
- * Determine whether session is allowed to be shutdown in the current context.
- * Returns non-zero if the session should be shutdown.
- */
-int ft_sess_shutdown(struct se_session *se_sess)
-{
-       struct ft_sess *sess = se_sess->fabric_sess_ptr;
-
-       pr_debug("port_id %x\n", sess->port_id);
-       return 1;
-}
-
 /*
  * Remove session and send PRLO.
  * This is called when the ACL is being deleted or queue depth is changing.
index 2ace0295408e536e2834165a004ae11d3256f6ec..f4ed427e04ced9e36367ffb337a896d4393fea03 100644 (file)
@@ -1290,11 +1290,6 @@ static void usbg_release_cmd(struct se_cmd *se_cmd)
        percpu_ida_free(&se_sess->sess_tag_pool, se_cmd->map_tag);
 }
 
-static int usbg_shutdown_session(struct se_session *se_sess)
-{
-       return 0;
-}
-
 static void usbg_close_session(struct se_session *se_sess)
 {
 }
@@ -1735,7 +1730,6 @@ static const struct target_core_fabric_ops usbg_ops = {
        .tpg_check_prod_mode_write_protect = usbg_check_false,
        .tpg_get_inst_index             = usbg_tpg_get_inst_index,
        .release_cmd                    = usbg_release_cmd,
-       .shutdown_session               = usbg_shutdown_session,
        .close_session                  = usbg_close_session,
        .sess_get_index                 = usbg_sess_get_index,
        .sess_get_initiator_sid         = NULL,
index 0e6fd556c9827e0b50cdb19d6d2592673ff654bf..d2c60e5c48b312a9789766e5108028830615bd1a 100644 (file)
@@ -333,11 +333,6 @@ static void vhost_scsi_release_cmd(struct se_cmd *se_cmd)
        percpu_ida_free(&se_sess->sess_tag_pool, se_cmd->map_tag);
 }
 
-static int vhost_scsi_shutdown_session(struct se_session *se_sess)
-{
-       return 0;
-}
-
 static void vhost_scsi_close_session(struct se_session *se_sess)
 {
        return;
@@ -2114,7 +2109,6 @@ static struct target_core_fabric_ops vhost_scsi_ops = {
        .tpg_get_inst_index             = vhost_scsi_tpg_get_inst_index,
        .release_cmd                    = vhost_scsi_release_cmd,
        .check_stop_free                = vhost_scsi_check_stop_free,
-       .shutdown_session               = vhost_scsi_shutdown_session,
        .close_session                  = vhost_scsi_close_session,
        .sess_get_index                 = vhost_scsi_sess_get_index,
        .sess_get_initiator_sid         = NULL,
index ff932624eaad885c9cc02c311c6bb2f90f99a54e..783947a272ab3503ed7ae2e7ab9a9bd8bc6ddb0a 100644 (file)
@@ -1399,11 +1399,6 @@ static void scsiback_release_cmd(struct se_cmd *se_cmd)
        percpu_ida_free(&se_sess->sess_tag_pool, se_cmd->map_tag);
 }
 
-static int scsiback_shutdown_session(struct se_session *se_sess)
-{
-       return 0;
-}
-
 static void scsiback_close_session(struct se_session *se_sess)
 {
 }
@@ -1841,7 +1836,6 @@ static const struct target_core_fabric_ops scsiback_ops = {
        .tpg_get_inst_index             = scsiback_tpg_get_inst_index,
        .check_stop_free                = scsiback_check_stop_free,
        .release_cmd                    = scsiback_release_cmd,
-       .shutdown_session               = scsiback_shutdown_session,
        .close_session                  = scsiback_close_session,
        .sess_get_index                 = scsiback_sess_get_index,
        .sess_get_initiator_sid         = NULL,