9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] tree problem
@ 2007-05-03 14:22 Gorka Guardiola
  2007-05-03 15:01 ` Russ Cox
  0 siblings, 1 reply; 10+ messages in thread
From: Gorka Guardiola @ 2007-05-03 14:22 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

I was using a tree created by alloctree(), 9pfile(2) to write a
synthetic filesystem and got
into a problem I have seen before, but I can´t remember if I asked
about it here (google
doesn't find anything).

There is no way to register a close() function in Srv which can be
called when a clunk
is received for an open file.

The solution may, alternatively be to register a clunk()
function and each can do what they want with it though I
do not like it because I feel I should receive things related
with files and not with fids.

This is important to do garbage collection in some
cases (for example if you open something when you get an open and want to
close it). Is there a reason for this function not existing? am I
missing something?.

At some point in the past I had a modified version of the library (my
proposed solution)
and at another I played with the references (very ugly) if my memory
serves right.
-- 
- curiosity sKilled the cat


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9fans] tree problem
  2007-05-03 14:22 [9fans] tree problem Gorka Guardiola
@ 2007-05-03 15:01 ` Russ Cox
  2007-05-03 15:28   ` Axel Belinfante
  2007-05-03 16:25   ` Gorka Guardiola
  0 siblings, 2 replies; 10+ messages in thread
From: Russ Cox @ 2007-05-03 15:01 UTC (permalink / raw)
  To: 9fans

> The solution may, alternatively be to register a clunk()
> function and each can do what they want with it though I
> do not like it because I feel I should receive things related
> with files and not with fids.

the read and write requests you receive are for fids,
not files.  you pull out the file using fid->file.

you can use destroyfid to find out when a fid is 
completely clunked.  from 9p(2):

          Destroyfid
               When a Fid's reference count drops to zero (i.e., it
               has been clunked and there are no outstanding requests
               referring to it), destroyfid is called to allow the
               program to dispose of the fid->aux pointer.

you can get at the file by using fid->file.

russ



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9fans] tree problem
  2007-05-03 15:01 ` Russ Cox
@ 2007-05-03 15:28   ` Axel Belinfante
  2007-05-03 15:40     ` ron minnich
  2007-05-03 15:55     ` Russ Cox
  2007-05-03 16:25   ` Gorka Guardiola
  1 sibling, 2 replies; 10+ messages in thread
From: Axel Belinfante @ 2007-05-03 15:28 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> > The solution may, alternatively be to register a clunk()
> > function and each can do what they want with it though I
> > do not like it because I feel I should receive things related
> > with files and not with fids.
> 
> the read and write requests you receive are for fids,
> not files.  you pull out the file using fid->file.
> 
> you can use destroyfid to find out when a fid is 
> completely clunked.  from 9p(2):
> 
>           Destroyfid
>                When a Fid's reference count drops to zero (i.e., it
>                has been clunked and there are no outstanding requests
>                referring to it), destroyfid is called to allow the
>                program to dispose of the fid->aux pointer.
> 
> you can get at the file by using fid->file.

at a time I had modified my local lib9p to be able
to register a clunk function.

I needed it for a 'filterfs' that sits between a user
and another file server.
it forwarded each incoming request (potentially modified)
to the other file server, and handed back its responses
(potentially modified) to the user.
the forwarded requests contained the fids as given by the user.

I needed to forward the clunk immediately, because
otherwise the user might not be able to reuse a fid
immediately after having clunked it (more accurately:
if the user would do so, and the 'other' file server
would not see the clunk before the reuse, there might
be trouble.)


Axel.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9fans] tree problem
  2007-05-03 15:28   ` Axel Belinfante
@ 2007-05-03 15:40     ` ron minnich
  2007-05-03 15:55     ` Russ Cox
  1 sibling, 0 replies; 10+ messages in thread
From: ron minnich @ 2007-05-03 15:40 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

I'm sort of missing the point here. What was the case where destroyfid
was not sufficient? I don't understand the user reusing a fid if the
user had not stopped using it, i.e. if the user had two references to
the fid, and clunked it once, isn't reusing that fid an error of some
sort?

IIRC destroyfid is just what is called when the ref count is zero,
which is pretty close to what you want much of the time.

(that said, I keep thinking I want clunk in there anyway :)

thanks

ron


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9fans] tree problem
  2007-05-03 15:28   ` Axel Belinfante
  2007-05-03 15:40     ` ron minnich
@ 2007-05-03 15:55     ` Russ Cox
  1 sibling, 0 replies; 10+ messages in thread
From: Russ Cox @ 2007-05-03 15:55 UTC (permalink / raw)
  To: 9fans

> at a time I had modified my local lib9p to be able
> to register a clunk function.
> 
> I needed it for a 'filterfs' that sits between a user
> and another file server.
> it forwarded each incoming request (potentially modified)
> to the other file server, and handed back its responses
> (potentially modified) to the user.
> the forwarded requests contained the fids as given by the user.

an alternate solution would have been to use your own
fid space, though that's not as convenient.

destroyfid != clunk because i was worried about buggy
or malicious clients that might clunk a fid while there 
were still pending requests using that fid.  for example
issue a Tread and then Tclunk the fid before
the Rread comes back.  then the Tclunk handler can't
free associated data structures because the Tread
handler might still be using them.

i suppose i could have still had a clunk handler
and just delayed processing Tclunk until any pending
ops on that fid finished.

russ



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9fans] tree problem
  2007-05-03 15:01 ` Russ Cox
  2007-05-03 15:28   ` Axel Belinfante
@ 2007-05-03 16:25   ` Gorka Guardiola
  2007-05-03 17:22     ` Russ Cox
  2007-05-03 17:30     ` rog
  1 sibling, 2 replies; 10+ messages in thread
From: Gorka Guardiola @ 2007-05-03 16:25 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On 5/3/07, Russ Cox <rsc@swtch.com> wrote:
>
> the read and write requests you receive are for fids,
> not files.  you pull out the file using fid->file.
>

Then I want the clunk :-).

> you can use destroyfid to find out when a fid is
> completely clunked.  from 9p(2)

I want each clunk, not the last one...


-- 
- curiosity sKilled the cat


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9fans] tree problem
  2007-05-03 16:25   ` Gorka Guardiola
@ 2007-05-03 17:22     ` Russ Cox
  2007-05-04  7:53       ` Gorka Guardiola
  2007-05-03 17:30     ` rog
  1 sibling, 1 reply; 10+ messages in thread
From: Russ Cox @ 2007-05-03 17:22 UTC (permalink / raw)
  To: 9fans

>> you can use destroyfid to find out when a fid is
>> completely clunked.  from 9p(2)
> 
> I want each clunk, not the last one...

there is only one per fid, and you'll get it.

russ



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9fans] tree problem
  2007-05-03 16:25   ` Gorka Guardiola
  2007-05-03 17:22     ` Russ Cox
@ 2007-05-03 17:30     ` rog
  2007-05-03 20:21       ` Charles Forsyth
  1 sibling, 1 reply; 10+ messages in thread
From: rog @ 2007-05-03 17:30 UTC (permalink / raw)
  To: 9fans

> I want each clunk, not the last one...

there will be at most one clunk for an open
file, as it's illegal to clone an open fid.

in the usual case (when clients are being non-malicious)
destroyfid on an open file will be trigged
by that clunk.

it does seem a pity that there seems to
be no way of delaying the response to a clunk
without stopping the server read loop.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9fans] tree problem
  2007-05-03 17:30     ` rog
@ 2007-05-03 20:21       ` Charles Forsyth
  0 siblings, 0 replies; 10+ messages in thread
From: Charles Forsyth @ 2007-05-03 20:21 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 157 bytes --]

i think that for unusual servers, including filters, it's easier just to serve
the protocol, rather than try to second-guess an otherwise helpful library.

[-- Attachment #2: Type: message/rfc822, Size: 2485 bytes --]

From: rog@vitanuova.com
To: 9fans@cse.psu.edu
Subject: Re: [9fans] tree problem
Date: Thu, 3 May 2007 18:30:19 +0100
Message-ID: <b8c6c51342c73bbb63ec0d0f766fd6a3@vitanuova.com>

> I want each clunk, not the last one...

there will be at most one clunk for an open
file, as it's illegal to clone an open fid.

in the usual case (when clients are being non-malicious)
destroyfid on an open file will be trigged
by that clunk.

it does seem a pity that there seems to
be no way of delaying the response to a clunk
without stopping the server read loop.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [9fans] tree problem
  2007-05-03 17:22     ` Russ Cox
@ 2007-05-04  7:53       ` Gorka Guardiola
  0 siblings, 0 replies; 10+ messages in thread
From: Gorka Guardiola @ 2007-05-04  7:53 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On 5/3/07, Russ Cox <rsc@swtch.com> wrote:
> >> you can use destroyfid to find out when a fid is
> >> completely clunked.  from 9p(2)
> >
> > I want each clunk, not the last one...
>

I meant I want to get the clunk inmediately not
after the last reference drop, sorry.


-- 
- curiosity sKilled the cat


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-05-04  7:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-03 14:22 [9fans] tree problem Gorka Guardiola
2007-05-03 15:01 ` Russ Cox
2007-05-03 15:28   ` Axel Belinfante
2007-05-03 15:40     ` ron minnich
2007-05-03 15:55     ` Russ Cox
2007-05-03 16:25   ` Gorka Guardiola
2007-05-03 17:22     ` Russ Cox
2007-05-04  7:53       ` Gorka Guardiola
2007-05-03 17:30     ` rog
2007-05-03 20:21       ` Charles Forsyth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).