Re: [RFC] example init.d script for tgtd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 21 Oct 2008 13:49:34 +0200
Tomasz Chmielewski <mangoo@xxxxxxxx> wrote:

> FUJITA Tomonori schrieb:
> > On Tue, 21 Oct 2008 13:27:04 +0200
> > Tomasz Chmielewski <mangoo@xxxxxxxx> wrote:
> > 
> >> ronnie sahlberg schrieb:
> >>
> >> (...)
> >>
> >>>> the RHEL script will probably fail to start here (may depend on machine,
> >>>> load etc.):
> >>>>
> >>>>        daemon tgtd $TGTD_OPTIONS
> >>>>
> >>>>        # read the config        tgt-admin -e -c "${TGTD_CONFIG}"
> >>>>
> >>>>
> >>>> tgtd starts in the background immediately, but does not yet accept commands
> >>>> from tgtadm. So adding "sleep 1" between starting tgtd and tgt-admin should
> >>>> help.
> >>>>
> >>> Having to explicitely add a sleep in scripts is a bit dodgy.
> >>>
> >>> Maybe better to enhance tgtadm to try-and-retry for x seconds before
> >>> giving up and thus hiding this
> >>> ugly race from the average user?
> >> Or tgtd shouldn't background when it's not ready to accept commands yet.
> > 
> > I guess that 'daemon' program forks tgtd. Then tgtd can't do anything.
> 
> Umm, it seems to me that it's tgtd itself:
> 
> # 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)?

=
From: FUJITA Tomonori <fujita.tomonori@xxxxxxxxxxxxx>
Subject: [PATCH] create ipc socket before calling daemon

Signed-off-by: FUJITA Tomonori <fujita.tomonori@xxxxxxxxxxxxx>
---
 usr/tgtd.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/usr/tgtd.c b/usr/tgtd.c
index 62aaa04..7024b12 100644
--- a/usr/tgtd.c
+++ b/usr/tgtd.c
@@ -325,6 +325,10 @@ int main(int argc, char **argv)
 		exit(1);
 	}
 
+	err = ipc_init();
+	if (err)
+		exit(1);
+
 	if (is_daemon && daemon(0,0))
 		exit(1);
 
@@ -344,10 +348,6 @@ int main(int argc, char **argv)
 		}
 	}
 
-	err = ipc_init();
-	if (err)
-		exit(1);
-
 	event_loop();
 
 	lld_exit();
-- 
1.5.6.5

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux