Skip to content

Commit 22d1175

Browse files
Christoph HellwigNicholas Bellinger
authored andcommitted
target: make ->shutdown_session optional
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>
1 parent fba81f8 commit 22d1175

12 files changed

Lines changed: 4 additions & 66 deletions

File tree

‎Documentation/target/tcm_mod_builder.py‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
294294
buf += " .tpg_check_prod_mode_write_protect = " + fabric_mod_name + "_check_false,\n"
295295
buf += " .tpg_get_inst_index = " + fabric_mod_name + "_tpg_get_inst_index,\n"
296296
buf += " .release_cmd = " + fabric_mod_name + "_release_cmd,\n"
297-
buf += " .shutdown_session = " + fabric_mod_name + "_shutdown_session,\n"
298297
buf += " .close_session = " + fabric_mod_name + "_close_session,\n"
299298
buf += " .sess_get_index = " + fabric_mod_name + "_sess_get_index,\n"
300299
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):
467466
buf += "}\n\n"
468467
bufi += "void " + fabric_mod_name + "_release_cmd(struct se_cmd *);\n"
469468

470-
if re.search('shutdown_session\)\(', fo):
471-
buf += "int " + fabric_mod_name + "_shutdown_session(struct se_session *se_sess)\n"
472-
buf += "{\n"
473-
buf += " return 0;\n"
474-
buf += "}\n\n"
475-
bufi += "int " + fabric_mod_name + "_shutdown_session(struct se_session *);\n"
476-
477469
if re.search('close_session\)\(', fo):
478470
buf += "void " + fabric_mod_name + "_close_session(struct se_session *se_sess)\n"
479471
buf += "{\n"

‎drivers/infiniband/ulp/srpt/ib_srpt.c‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,14 +1960,6 @@ static void __srpt_close_all_ch(struct srpt_device *sdev)
19601960
}
19611961
}
19621962

1963-
/**
1964-
* srpt_shutdown_session() - Whether or not a session may be shut down.
1965-
*/
1966-
static int srpt_shutdown_session(struct se_session *se_sess)
1967-
{
1968-
return 1;
1969-
}
1970-
19711963
static void srpt_free_ch(struct kref *kref)
19721964
{
19731965
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 = {
32873279
.tpg_get_inst_index = srpt_tpg_get_inst_index,
32883280
.release_cmd = srpt_release_cmd,
32893281
.check_stop_free = srpt_check_stop_free,
3290-
.shutdown_session = srpt_shutdown_session,
32913282
.close_session = srpt_close_session,
32923283
.sess_get_index = srpt_sess_get_index,
32933284
.sess_get_initiator_sid = NULL,

‎drivers/target/loopback/tcm_loop.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -601,11 +601,6 @@ static int tcm_loop_get_cmd_state(struct se_cmd *se_cmd)
601601
return tl_cmd->sc_cmd_state;
602602
}
603603

604-
static int tcm_loop_shutdown_session(struct se_session *se_sess)
605-
{
606-
return 0;
607-
}
608-
609604
static void tcm_loop_close_session(struct se_session *se_sess)
610605
{
611606
return;
@@ -1243,7 +1238,6 @@ static const struct target_core_fabric_ops loop_ops = {
12431238
.tpg_get_inst_index = tcm_loop_get_inst_index,
12441239
.check_stop_free = tcm_loop_check_stop_free,
12451240
.release_cmd = tcm_loop_release_cmd,
1246-
.shutdown_session = tcm_loop_shutdown_session,
12471241
.close_session = tcm_loop_close_session,
12481242
.sess_get_index = tcm_loop_sess_get_index,
12491243
.write_pending = tcm_loop_write_pending,

‎drivers/target/sbp/sbp_target.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,11 +1726,6 @@ static void sbp_release_cmd(struct se_cmd *se_cmd)
17261726
sbp_free_request(req);
17271727
}
17281728

1729-
static int sbp_shutdown_session(struct se_session *se_sess)
1730-
{
1731-
return 0;
1732-
}
1733-
17341729
static void sbp_close_session(struct se_session *se_sess)
17351730
{
17361731
return;
@@ -2349,7 +2344,6 @@ static const struct target_core_fabric_ops sbp_ops = {
23492344
.tpg_check_prod_mode_write_protect = sbp_check_false,
23502345
.tpg_get_inst_index = sbp_tpg_get_inst_index,
23512346
.release_cmd = sbp_release_cmd,
2352-
.shutdown_session = sbp_shutdown_session,
23532347
.close_session = sbp_close_session,
23542348
.sess_get_index = sbp_sess_get_index,
23552349
.write_pending = sbp_write_pending,

‎drivers/target/target_core_configfs.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,6 @@ static int target_fabric_tf_ops_check(const struct target_core_fabric_ops *tfo)
385385
pr_err("Missing tfo->release_cmd()\n");
386386
return -EINVAL;
387387
}
388-
if (!tfo->shutdown_session) {
389-
pr_err("Missing tfo->shutdown_session()\n");
390-
return -EINVAL;
391-
}
392388
if (!tfo->close_session) {
393389
pr_err("Missing tfo->close_session()\n");
394390
return -EINVAL;

‎drivers/target/target_core_tpg.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,10 @@ static void target_shutdown_sessions(struct se_node_acl *acl)
353353
list_del_init(&sess->sess_acl_list);
354354

355355
spin_unlock_irqrestore(&acl->nacl_sess_lock, flags);
356-
ret = acl->se_tpg->se_tpg_tfo->shutdown_session(sess);
356+
if (acl->se_tpg->se_tpg_tfo->shutdown_session)
357+
ret = acl->se_tpg->se_tpg_tfo->shutdown_session(sess);
358+
else
359+
ret = 1;
357360
target_put_session(sess);
358361
if (ret)
359362
target_put_session(sess);

‎drivers/target/tcm_fc/tcm_fc.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ extern unsigned int ft_debug_logging;
139139
* Session ops.
140140
*/
141141
void ft_sess_put(struct ft_sess *);
142-
int ft_sess_shutdown(struct se_session *);
143142
void ft_sess_close(struct se_session *);
144143
u32 ft_sess_get_index(struct se_session *);
145144
u32 ft_sess_get_port_name(struct se_session *, unsigned char *, u32);

‎drivers/target/tcm_fc/tfc_conf.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,6 @@ static const struct target_core_fabric_ops ft_fabric_ops = {
442442
.tpg_get_inst_index = ft_tpg_get_inst_index,
443443
.check_stop_free = ft_check_stop_free,
444444
.release_cmd = ft_release_cmd,
445-
.shutdown_session = ft_sess_shutdown,
446445
.close_session = ft_sess_close,
447446
.sess_get_index = ft_sess_get_index,
448447
.sess_get_initiator_sid = NULL,

‎drivers/target/tcm_fc/tfc_sess.c‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -302,18 +302,6 @@ static void ft_sess_delete_all(struct ft_tport *tport)
302302
* TCM ops for sessions.
303303
*/
304304

305-
/*
306-
* Determine whether session is allowed to be shutdown in the current context.
307-
* Returns non-zero if the session should be shutdown.
308-
*/
309-
int ft_sess_shutdown(struct se_session *se_sess)
310-
{
311-
struct ft_sess *sess = se_sess->fabric_sess_ptr;
312-
313-
pr_debug("port_id %x\n", sess->port_id);
314-
return 1;
315-
}
316-
317305
/*
318306
* Remove session and send PRLO.
319307
* This is called when the ACL is being deleted or queue depth is changing.

‎drivers/usb/gadget/function/f_tcm.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,11 +1290,6 @@ static void usbg_release_cmd(struct se_cmd *se_cmd)
12901290
percpu_ida_free(&se_sess->sess_tag_pool, se_cmd->map_tag);
12911291
}
12921292

1293-
static int usbg_shutdown_session(struct se_session *se_sess)
1294-
{
1295-
return 0;
1296-
}
1297-
12981293
static void usbg_close_session(struct se_session *se_sess)
12991294
{
13001295
}
@@ -1735,7 +1730,6 @@ static const struct target_core_fabric_ops usbg_ops = {
17351730
.tpg_check_prod_mode_write_protect = usbg_check_false,
17361731
.tpg_get_inst_index = usbg_tpg_get_inst_index,
17371732
.release_cmd = usbg_release_cmd,
1738-
.shutdown_session = usbg_shutdown_session,
17391733
.close_session = usbg_close_session,
17401734
.sess_get_index = usbg_sess_get_index,
17411735
.sess_get_initiator_sid = NULL,

0 commit comments

Comments
 (0)