[stgt] [RFC] example init.d script for tgtd

FUJITA Tomonori fujita.tomonori at lab.ntt.co.jp
Wed Oct 22 04:33:58 CEST 2008


On Wed, 22 Oct 2008 12:50:22 +1100
"ronnie sahlberg" <ronniesahlberg at gmail.com> wrote:

> On Wed, Oct 22, 2008 at 12:47 PM, FUJITA Tomonori
> <fujita.tomonori at lab.ntt.co.jp> wrote:
> > On Tue, 21 Oct 2008 15:56:17 +0200
> > Tomasz Chmielewski <mangoo at wpkg.org> wrote:
> >
> >> FUJITA Tomonori schrieb:
> >>
> >> (...)
> >>
> >> >> # tgtd ; tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2008-01.....
> >> >> tgtadm: can't connect to the tgt daemon, Connection refused
> >> >> tgtadm: can't send the request to the tgt daemon, Transport endpoint is not connected
> >> >
> >> > I guess that 'daemon' program works differently from what you did here
> >> > (that's what I wrote in the previous mail). But I might be wrong since
> >> > I don't know how 'daemon' program works (Debian doesn't have the program).
> >> >
> >> > For your case, this patch helps (you also need the tgtadm patch that
> >> > I've just sent)?
> >>
> >> It helps here.
> >>
> >> # tgtd ; tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn....
> >> # tgt-admin -s
> >> Target 1: iqn....
> >>     System information:
> >>         Driver: iscsi
> >> (...)
> >>
> >> Repeated several times, so it seems like it works.
> >
> > Yeah, it should work for your case.
> >
> >
> >> Restarting still needs "sleep 1s" ;)
> >>
> >> # tgtd ; tgtadm --op delete --mode system ; tgtd
> >> (null): iscsi_tcp_init(222) unable to bind server socket, Address already in use
> >> No available low level driver!
> >> #
> >
> > I guess that there is a way to work around this. But I can't recall
> > now. I need to check a network programing book.
> >
> 
> setsockopt()
> SO_REUSEADDR

Thanks!

I found that I already use SO_REUSEADDR for iSCSI sockets. :)


 # tgtd ; tgtadm --op delete --mode system ; tgtd


I guess, this problem happens in the following way.

1. execute `tgtadm --op delete --mode system`
2. tgtd sets system_active to zero and notifies tgtadm of the
completion of the request.
3. tgtadm returns and the scripts tries to run tgtd again however tgtd
still runs (it takes some time until tgtd dies after setting
system_active to zero).


In short, `tgtadm --op delete --mode system` should not return until
tgtd dies. If we really want to fix this, we need to add some hack to
do the above (tgtadm gets the process ID of tgtd and calls waitpid), I
think.
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list