devfs
[Top] [All Lists]

RE: Why removables revalidation works at all?

To: "'Richard Gooch'" <rgooch@xxxxxxxxxxxxxxx>
Subject: RE: Why removables revalidation works at all?
From: Borsenkow Andrej <Andrej.Borsenkow@xxxxxxxxxxxxxx>
Date: Fri, 22 Feb 2002 19:55:00 +0300
Cc: "'devfs mailing list'" <devfs@xxxxxxxxxxx>
Importance: Normal
In-reply-to: <200202221630.g1MGUJ102155@xxxxxxxxxxxxxxxxxxxxxxxx>
Sender: owner-devfs@xxxxxxxxxxx
> 
> Borsenkow Andrej writes:
> > I am sorry if this is stupid question but if it should not work if I
> > understand devfs properly ... I mean these dd's in devfsd.
> >
> > What happens is
> >
> > User accesses /dev/sda4
> >        |
> > devfs lookup calls devfsd with LOOKUP
> >        |
> > devfsd runs dd if=/dev/sda
> >        |
> >        |-----------------------+
> >        |                       |
> > devfsd returns to devfs      devfs calls devfsd with REGISTER
> >        |                       |
> > devfs repeats lookup         devfsd creates /dev/sda4
> >        |
> > devfs returns /dev/sda4?
> >
> > So to my eyes there are two independent threads with obvious race
> > condition here. There is no way known to me to synchronize them. It
> > assumes second threads completes BEFORE devfs does second lookup. Is
> > it really garanteed?
> 
> If I understand your question: you're wondering about races between
> devfsd and it's child dd process. There are no such races, because
> devfsd will wait for the child process to finish. Devfsd is
> explicitely single-threaded (i.e. it waits for children to finish) to
> avoid any such problems.
> 

Not quite. If it is single threaded the thread looks like:

User lookup /dev/sda4 waits
  |
devfs calls devfsd with LOOKUP /dev/sda4
  |
devfsd calls dd
  |
dd returns
  |
devfsd acknowledges LOOKUP
  |
devfs repeats lookup /dev/sda4 - but it does not yet exist?
  |
devfs returns error to user
  |
devfs calls devfsd with REGISTER .../part4 which is now irrelevant

Please, bear with me. I'd like to be sure I understand how it works and
that it is not just an accident.

-andrej

<Prev in Thread] Current Thread [Next in Thread>