How to force iscsid to reconnect target?

2.3k Views Asked by At

I have installed open-iscsi, and have login to several targets. The device is mounted, and doing some IO.
But I want to disconnect the tcp connection of initiator and target, force iscsid to run recovery and reconnect.
How to do this?

I have used tcpkill to kill some tcp connection, and iscsid will run recovery and reconnect to target. But i don't know which tcp connection belongs to which target. So if i want to reconnect target1, I may kill the tcp connection of target2.
How to identify the tcp connections to targets?

1

There are 1 best solutions below

1
On BEST ANSWER

If your targets have different IP addresses, you can use netstat, and grep for port 3260 (iscsi).

$ netstat -nap | grep 3260
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 172.16.10.16:48471          172.16.10.201:3260          ESTABLISHED -    

Then use tcpkill on the local port and destination IP:

$ sudo tcpkill -9 -i eth1 "port 48471 and host 172.16.10.201"

If your targets don't have different IP addresses, it looks like the best way is to increase the logging level of iscsid to 2 so that you can see this message that's logged when it makes a connection.

 log_debug(1, "connected local port %s to %s:%s",
           lserv, conn->host, serv);

There doesn't appear to be another way to get the initiator-side port out of iscsid.