"Narendra Kumar S.S" writes:
> On 7/26/07, Liane Praza <lianep at eng.sun.com> wrote:
> >
> > "Narendra Kumar S.S" writes:
> > > Now, I have written a code, which calls smf_enable_instance to enable
> > > filesystem/local service.
> > > Immediately after returning from this call, the next instruction, tries
> > to
> > > access a file on one of the local filesystems.
> > > So, are there chances that, the filesystem/local is not yet completely
> > > enabled and because of that, the local filesystem is not yet mounted and
> > > hence this instruction might fail!?
> >
> > It is completely enabled.  However, enabled doesn't mean the service
> > is online.  It means that we're trying to make it be online, but its
> > dependencies may not be satisfied, it may have failed, or it may just
> > not be online yet.
> >
> > As I said:
> > > > Currently, an interface which is synchronous to online/disabled is
> > only
> > > > formally available through svcadm [en|dis]able -s.  I believe there's
> > an
> > > > RFE to make the synchronous semantics through libscf, but don't have
> > the
> > > > bugid to hand.  It'd make a great OpenSolaris RFE, though. :)
> >
> > In the meantime, you could wait a little bit to see if smf_get_state()
> > returns SCF_STATE_STRING_ONLINE before continuing.
> 
> 
> OK. So, if I have to wait a 'little bit', is there any standard or
> predefined value for this wait?

Nope, sorry -- I don't know (and the system doesn't either) a priori 
how long it could take for a service to start, especially filesystem
services that mount an administrator-defined arbitrary number of
filesystems.  (And that doesn't take into account if its dependencies 
haven't had the chance to start yet.)

That's why it's a bug there isn't a libscf function to do what svcadm
enable -s does: to implement a better algorithm than an arbitrary wait.
I wish that there was, but we just haven't had the chance yet to do the
work.  I was trying to give you a potential quick and dirty solution 
that could work for your situation.

You could look at the code in svcadm.c if you want the real algorithm...

  http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/cmd/svc/svcadm/

IIRC, most of the code is in synch.c.

liane
-- 
Liane Praza, Solaris Kernel Development
liane.praza at sun.com - http://blogs.sun.com/lianep

Reply via email to