linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikita Danilov <nikita@clusterfs.com>
To: Jan Blunck <j.blunck@tu-harburg.de>
Cc: linux-fsdevel@vger.kernel.org, Zitat von Tomas Hruby <thruby@gmail.com>
Subject: Re: readdir behaviour
Date: Tue, 2 Aug 2005 19:01:17 +0400	[thread overview]
Message-ID: <17135.35517.560941.435505@gargle.gargle.HOWL> (raw)
In-Reply-To: <1122976468.42ef42d4df4ea@webmail.tu-harburg.de>

Jan Blunck writes:
 > This was also topic on lkml 2 weeks ago.
 > 
 > Zitat von Tomas Hruby <thruby@gmail.com>:
 > 
 > > First of all I would like to know what exactly is the meaning of the
 > > 'offset' parameter of filldir and whether it is used somewhere? Unlike
 > > ext2, our directories are not easily read sequentially and this value
 > > (copied by filldir to dirent->d_off) seems to be quite useless outside
 > > our fs code.
 > 
 > The offset of the dirent has no common meaning. Think of it as a cookie or
 > something like that. It should not be interpreted either by VFS or by the
 > user-space.

->d_off is remembered by glibc, and returned to the user as a result of
telldir(3). As such it is valid argument for the following seekdir(3).

 > 
 > > Related question is what is the correct behaviour of readdir in case
 > > of user's seeking in the directory? If I understand correctly, in case
 > > of ext3 (indexed directories), when seeking is detected, readdir
 > > starts reading from the directory beginning again.
 > 
 > On different archs the libc is seeking (to d_off) after each call to getdents().
 > Therefore the implementation should honor it.
 > 
 > > The last is about concurrency. How is solved problem when a directory
 > > is read by readdir and between two readdir calls the same directory is
 > > changed?

Single UNIX specification
(http://www.opengroup.org/onlinepubs/007904875/functions/readdir.html)
is vague about whether directory entries added asynchronously should be
returned.

 > 
 > This is the filesystems duty to seek to the next valid dentry. Although it is
 > not defined if the new directories contents is returned or the one on
 > opendir().
 > 
 > Although I think it would be nice (and convenient to the "everything is a file"
 > paradigm) when the directory is presented like a sequential file this is not
 > the common practice. Due to the fact that there are no applications which are
 > reading and seeking the directories directly this is a good tradeoff to achieve
 > high performance for readdir().

Unfortunately, seekdir and telldir are standard (albeit optional)
interfaces, and libc translates seekdir into lseek. File systems have to
support this.

 > 
 > Jan

Nikita.

      reply	other threads:[~2005-08-02 15:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <5931eebf050801162174f6f54@mail.gmail.com>
2005-08-02  9:54 ` readdir behaviour Jan Blunck
2005-08-02 15:01   ` Nikita Danilov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17135.35517.560941.435505@gargle.gargle.HOWL \
    --to=nikita@clusterfs.com \
    --cc=j.blunck@tu-harburg.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=thruby@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).