9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Listing a directory
@ 2011-03-08  1:09 Venkatesh Srinivas
  2011-03-08  1:17 ` Eric Van Hensbergen
  2011-03-09 23:38 ` Latchesar Ionkov
  0 siblings, 2 replies; 3+ messages in thread
From: Venkatesh Srinivas @ 2011-03-08  1:09 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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

Hi,

In 9P, if I wish to list a directory, I need to TWalk to the directory,
TOpen the directory fid from the walk, and then TRead till I have all of the
contents of the directory.
If the directory's contents do not fit in a single read, I imagine I need to
loop around TOpen / Tread / .... / Tread / TOpen, till I get the whole
contents and see the same QIDs in each open, to get a coherent listing. (is
this accurate?)

Unfortunately, a TOpened FID to a directory cannot be used for walking it
(why?); so the only use of a TOpened fid to a directory is to list it or to
get a QID. Would it be reasonable for a TOpened fid to a directory to create
a copy of the directory listing at the time of the RPC?

-- vs

[-- Attachment #2: Type: text/html, Size: 763 bytes --]

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

* Re: [9fans] Listing a directory
  2011-03-08  1:09 [9fans] Listing a directory Venkatesh Srinivas
@ 2011-03-08  1:17 ` Eric Van Hensbergen
  2011-03-09 23:38 ` Latchesar Ionkov
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Van Hensbergen @ 2011-03-08  1:17 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Mon, Mar 7, 2011 at 7:09 PM, Venkatesh Srinivas <me@acm.jhu.edu> wrote:
>
> In 9P, if I wish to list a directory, I need to TWalk to the directory,
> TOpen the directory fid from the walk, and then TRead till I have all of the
> contents of the directory.
> If the directory's contents do not fit in a single read, I imagine I need to
> loop around TOpen / Tread / .... / Tread / TOpen, till I get the whole
> contents and see the same QIDs in each open, to get a coherent listing. (is
> this accurate?)
>

Offsets track where you are in the metadata, servers have multiple
approaches to dealing with this, usually there is some form of cookie
in the fid which tracks the last offset red and maybe a cache of where
it was in the directory listing.  I think the QID matching and
coalescing is more of a union bind mechanism and happens if I am not
mistaken by a higher level entity (like ls)

> Unfortunately, a TOpened FID to a directory cannot be used for walking it
> (why?); so the only use of a TOpened fid to a directory is to list it or to
> get a QID. Would it be reasonable for a TOpened fid to a directory to create
> a copy of the directory listing at the time of the RPC?

That may be a potential back-end implementation on the server, I
believe it to be the only way to avoid the sort of race conditions you
might expect otherwise.  But I haven't implemented the server side of
that code, only the client which is tricky, but easier -- so I'm sure
someone else may have a better opinion.

     -eric



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

* [9fans] Listing a directory
  2011-03-08  1:09 [9fans] Listing a directory Venkatesh Srinivas
  2011-03-08  1:17 ` Eric Van Hensbergen
@ 2011-03-09 23:38 ` Latchesar Ionkov
  1 sibling, 0 replies; 3+ messages in thread
From: Latchesar Ionkov @ 2011-03-09 23:38 UTC (permalink / raw)


I don't think there is a way for you to get a coherent listing no
matter what you do. Files may be created and removed all the time, so
coherent listing doesn't have much sense.

In some cases it may be reasonable to atomically create a copy of the
directory listings (some of my file servers do), but I wouldn't like
to see it as required for all 9P implementations.

Thanks,
    Lucho

On Mon, Mar 7, 2011 at 6:09 PM, Venkatesh Srinivas <me at acm.jhu.edu> wrote:
> Hi,
>
> In 9P, if I wish to list a directory, I need to TWalk to the directory,
> TOpen the directory fid from the walk, and then TRead till I have all of the
> contents of the directory.
> If the directory's contents do not fit in a single read, I imagine I need to
> loop around TOpen / Tread / .... / Tread / TOpen, till I get the whole
> contents and see the same QIDs in each open, to get a coherent listing. (is
> this accurate?)
>
> Unfortunately, a TOpened FID to a directory cannot be used for walking it
> (why?); so the only use of a TOpened fid to a directory is to list it or to
> get a QID. Would it be reasonable for a TOpened fid to a directory to create
> a copy of the directory listing at the time of the RPC?
>
> -- vs
>



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

end of thread, other threads:[~2011-03-09 23:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-08  1:09 [9fans] Listing a directory Venkatesh Srinivas
2011-03-08  1:17 ` Eric Van Hensbergen
2011-03-09 23:38 ` Latchesar Ionkov

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).