mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	scsi: iscsi: Fail session and connection on transport registration failure
If the transport cannot be registered, the session/connection creation needs to be failed early to let the initiator know. Otherwise, the system will have an outstanding connection that cannot be used nor removed by open-iscsi. The result is similar to the error below, triggered by injecting a failure in the transport's registration path. openiscsi reports success: root@debian-vm:~# iscsiadm -m node -T iqn:lun1 -p 127.0.0.1 -l Logging in to [iface: default, target: iqn:lun1, portal: 127.0.0.1,3260] Login to [iface: default, target: iqn:lun1, portal:127.0.0.1,3260] successful. But cannot remove the session afterwards, since the kernel is in an inconsistent state. root@debian-vm:~# iscsiadm -m node -T iqn:lun1 -p 127.0.0.1 -u iscsiadm: No matching sessions found Link: https://lore.kernel.org/r/20200106185817.640331-4-krisman@collabora.com Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
		
							parent
							
								
									cd7ea70bb0
								
							
						
					
					
						commit
						f3c893e3db
					
				
					 1 changed files with 16 additions and 2 deletions
				
			
		| 
						 | 
					@ -2093,7 +2093,12 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
 | 
				
			||||||
					 "could not register session's dev\n");
 | 
										 "could not register session's dev\n");
 | 
				
			||||||
		goto release_ida;
 | 
							goto release_ida;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	transport_register_device(&session->dev);
 | 
						err = transport_register_device(&session->dev);
 | 
				
			||||||
 | 
						if (err) {
 | 
				
			||||||
 | 
							iscsi_cls_session_printk(KERN_ERR, session,
 | 
				
			||||||
 | 
										 "could not register transport's dev\n");
 | 
				
			||||||
 | 
							goto release_dev;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spin_lock_irqsave(&sesslock, flags);
 | 
						spin_lock_irqsave(&sesslock, flags);
 | 
				
			||||||
	list_add(&session->sess_list, &sesslist);
 | 
						list_add(&session->sess_list, &sesslist);
 | 
				
			||||||
| 
						 | 
					@ -2103,6 +2108,8 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
 | 
				
			||||||
	ISCSI_DBG_TRANS_SESSION(session, "Completed session adding\n");
 | 
						ISCSI_DBG_TRANS_SESSION(session, "Completed session adding\n");
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					release_dev:
 | 
				
			||||||
 | 
						device_del(&session->dev);
 | 
				
			||||||
release_ida:
 | 
					release_ida:
 | 
				
			||||||
	if (session->ida_used)
 | 
						if (session->ida_used)
 | 
				
			||||||
		ida_simple_remove(&iscsi_sess_ida, session->target_id);
 | 
							ida_simple_remove(&iscsi_sess_ida, session->target_id);
 | 
				
			||||||
| 
						 | 
					@ -2263,7 +2270,12 @@ iscsi_create_conn(struct iscsi_cls_session *session, int dd_size, uint32_t cid)
 | 
				
			||||||
					 "register connection's dev\n");
 | 
										 "register connection's dev\n");
 | 
				
			||||||
		goto release_parent_ref;
 | 
							goto release_parent_ref;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	transport_register_device(&conn->dev);
 | 
						err = transport_register_device(&conn->dev);
 | 
				
			||||||
 | 
						if (err) {
 | 
				
			||||||
 | 
							iscsi_cls_session_printk(KERN_ERR, session, "could not "
 | 
				
			||||||
 | 
										 "register transport's dev\n");
 | 
				
			||||||
 | 
							goto release_conn_ref;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spin_lock_irqsave(&connlock, flags);
 | 
						spin_lock_irqsave(&connlock, flags);
 | 
				
			||||||
	list_add(&conn->conn_list, &connlist);
 | 
						list_add(&conn->conn_list, &connlist);
 | 
				
			||||||
| 
						 | 
					@ -2272,6 +2284,8 @@ iscsi_create_conn(struct iscsi_cls_session *session, int dd_size, uint32_t cid)
 | 
				
			||||||
	ISCSI_DBG_TRANS_CONN(conn, "Completed conn creation\n");
 | 
						ISCSI_DBG_TRANS_CONN(conn, "Completed conn creation\n");
 | 
				
			||||||
	return conn;
 | 
						return conn;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					release_conn_ref:
 | 
				
			||||||
 | 
						put_device(&conn->dev);
 | 
				
			||||||
release_parent_ref:
 | 
					release_parent_ref:
 | 
				
			||||||
	put_device(&session->dev);
 | 
						put_device(&session->dev);
 | 
				
			||||||
free_conn:
 | 
					free_conn:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue