Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Christoph Hellwig and committed by
Nicholas Bellinger
22d11759 fba81f88

+4 -66
-8
Documentation/target/tcm_mod_builder.py
··· 294 294 buf += " .tpg_check_prod_mode_write_protect = " + fabric_mod_name + "_check_false,\n" 295 295 buf += " .tpg_get_inst_index = " + fabric_mod_name + "_tpg_get_inst_index,\n" 296 296 buf += " .release_cmd = " + fabric_mod_name + "_release_cmd,\n" 297 - buf += " .shutdown_session = " + fabric_mod_name + "_shutdown_session,\n" 298 297 buf += " .close_session = " + fabric_mod_name + "_close_session,\n" 299 298 buf += " .sess_get_index = " + fabric_mod_name + "_sess_get_index,\n" 300 299 buf += " .sess_get_initiator_sid = NULL,\n" ··· 465 466 buf += " return;\n" 466 467 buf += "}\n\n" 467 468 bufi += "void " + fabric_mod_name + "_release_cmd(struct se_cmd *);\n" 468 - 469 - if re.search('shutdown_session\)\(', fo): 470 - buf += "int " + fabric_mod_name + "_shutdown_session(struct se_session *se_sess)\n" 471 - buf += "{\n" 472 - buf += " return 0;\n" 473 - buf += "}\n\n" 474 - bufi += "int " + fabric_mod_name + "_shutdown_session(struct se_session *);\n" 475 469 476 470 if re.search('close_session\)\(', fo): 477 471 buf += "void " + fabric_mod_name + "_close_session(struct se_session *se_sess)\n"
-9
drivers/infiniband/ulp/srpt/ib_srpt.c
··· 1960 1960 } 1961 1961 } 1962 1962 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 - 1971 1963 static void srpt_free_ch(struct kref *kref) 1972 1964 { 1973 1965 struct srpt_rdma_ch *ch = container_of(kref, struct srpt_rdma_ch, kref); ··· 3279 3287 .tpg_get_inst_index = srpt_tpg_get_inst_index, 3280 3288 .release_cmd = srpt_release_cmd, 3281 3289 .check_stop_free = srpt_check_stop_free, 3282 - .shutdown_session = srpt_shutdown_session, 3283 3290 .close_session = srpt_close_session, 3284 3291 .sess_get_index = srpt_sess_get_index, 3285 3292 .sess_get_initiator_sid = NULL,
-6
drivers/target/loopback/tcm_loop.c
··· 601 601 return tl_cmd->sc_cmd_state; 602 602 } 603 603 604 - static int tcm_loop_shutdown_session(struct se_session *se_sess) 605 - { 606 - return 0; 607 - } 608 - 609 604 static void tcm_loop_close_session(struct se_session *se_sess) 610 605 { 611 606 return; ··· 1238 1243 .tpg_get_inst_index = tcm_loop_get_inst_index, 1239 1244 .check_stop_free = tcm_loop_check_stop_free, 1240 1245 .release_cmd = tcm_loop_release_cmd, 1241 - .shutdown_session = tcm_loop_shutdown_session, 1242 1246 .close_session = tcm_loop_close_session, 1243 1247 .sess_get_index = tcm_loop_sess_get_index, 1244 1248 .write_pending = tcm_loop_write_pending,
-6
drivers/target/sbp/sbp_target.c
··· 1726 1726 sbp_free_request(req); 1727 1727 } 1728 1728 1729 - static int sbp_shutdown_session(struct se_session *se_sess) 1730 - { 1731 - return 0; 1732 - } 1733 - 1734 1729 static void sbp_close_session(struct se_session *se_sess) 1735 1730 { 1736 1731 return; ··· 2344 2349 .tpg_check_prod_mode_write_protect = sbp_check_false, 2345 2350 .tpg_get_inst_index = sbp_tpg_get_inst_index, 2346 2351 .release_cmd = sbp_release_cmd, 2347 - .shutdown_session = sbp_shutdown_session, 2348 2352 .close_session = sbp_close_session, 2349 2353 .sess_get_index = sbp_sess_get_index, 2350 2354 .write_pending = sbp_write_pending,
-4
drivers/target/target_core_configfs.c
··· 385 385 pr_err("Missing tfo->release_cmd()\n"); 386 386 return -EINVAL; 387 387 } 388 - if (!tfo->shutdown_session) { 389 - pr_err("Missing tfo->shutdown_session()\n"); 390 - return -EINVAL; 391 - } 392 388 if (!tfo->close_session) { 393 389 pr_err("Missing tfo->close_session()\n"); 394 390 return -EINVAL;
+4 -1
drivers/target/target_core_tpg.c
··· 353 353 list_del_init(&sess->sess_acl_list); 354 354 355 355 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; 357 360 target_put_session(sess); 358 361 if (ret) 359 362 target_put_session(sess);
-1
drivers/target/tcm_fc/tcm_fc.h
··· 139 139 * Session ops. 140 140 */ 141 141 void ft_sess_put(struct ft_sess *); 142 - int ft_sess_shutdown(struct se_session *); 143 142 void ft_sess_close(struct se_session *); 144 143 u32 ft_sess_get_index(struct se_session *); 145 144 u32 ft_sess_get_port_name(struct se_session *, unsigned char *, u32);
-1
drivers/target/tcm_fc/tfc_conf.c
··· 442 442 .tpg_get_inst_index = ft_tpg_get_inst_index, 443 443 .check_stop_free = ft_check_stop_free, 444 444 .release_cmd = ft_release_cmd, 445 - .shutdown_session = ft_sess_shutdown, 446 445 .close_session = ft_sess_close, 447 446 .sess_get_index = ft_sess_get_index, 448 447 .sess_get_initiator_sid = NULL,
-12
drivers/target/tcm_fc/tfc_sess.c
··· 303 303 */ 304 304 305 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 - 317 - /* 318 306 * Remove session and send PRLO. 319 307 * This is called when the ACL is being deleted or queue depth is changing. 320 308 */
-6
drivers/usb/gadget/function/f_tcm.c
··· 1290 1290 percpu_ida_free(&se_sess->sess_tag_pool, se_cmd->map_tag); 1291 1291 } 1292 1292 1293 - static int usbg_shutdown_session(struct se_session *se_sess) 1294 - { 1295 - return 0; 1296 - } 1297 - 1298 1293 static void usbg_close_session(struct se_session *se_sess) 1299 1294 { 1300 1295 } ··· 1730 1735 .tpg_check_prod_mode_write_protect = usbg_check_false, 1731 1736 .tpg_get_inst_index = usbg_tpg_get_inst_index, 1732 1737 .release_cmd = usbg_release_cmd, 1733 - .shutdown_session = usbg_shutdown_session, 1734 1738 .close_session = usbg_close_session, 1735 1739 .sess_get_index = usbg_sess_get_index, 1736 1740 .sess_get_initiator_sid = NULL,
-6
drivers/vhost/scsi.c
··· 333 333 percpu_ida_free(&se_sess->sess_tag_pool, se_cmd->map_tag); 334 334 } 335 335 336 - static int vhost_scsi_shutdown_session(struct se_session *se_sess) 337 - { 338 - return 0; 339 - } 340 - 341 336 static void vhost_scsi_close_session(struct se_session *se_sess) 342 337 { 343 338 return; ··· 2109 2114 .tpg_get_inst_index = vhost_scsi_tpg_get_inst_index, 2110 2115 .release_cmd = vhost_scsi_release_cmd, 2111 2116 .check_stop_free = vhost_scsi_check_stop_free, 2112 - .shutdown_session = vhost_scsi_shutdown_session, 2113 2117 .close_session = vhost_scsi_close_session, 2114 2118 .sess_get_index = vhost_scsi_sess_get_index, 2115 2119 .sess_get_initiator_sid = NULL,
-6
drivers/xen/xen-scsiback.c
··· 1399 1399 percpu_ida_free(&se_sess->sess_tag_pool, se_cmd->map_tag); 1400 1400 } 1401 1401 1402 - static int scsiback_shutdown_session(struct se_session *se_sess) 1403 - { 1404 - return 0; 1405 - } 1406 - 1407 1402 static void scsiback_close_session(struct se_session *se_sess) 1408 1403 { 1409 1404 } ··· 1836 1841 .tpg_get_inst_index = scsiback_tpg_get_inst_index, 1837 1842 .check_stop_free = scsiback_check_stop_free, 1838 1843 .release_cmd = scsiback_release_cmd, 1839 - .shutdown_session = scsiback_shutdown_session, 1840 1844 .close_session = scsiback_close_session, 1841 1845 .sess_get_index = scsiback_sess_get_index, 1842 1846 .sess_get_initiator_sid = NULL,