linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Molnar <brian.molnar@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-fsdevel@vger.kernel.org
Subject: Re: fgetattr/fsetattr file operation
Date: Thu, 4 Jun 2009 10:42:32 -0700	[thread overview]
Message-ID: <b7ee1e6e0906041042q44dbc1a6ge7b82dc0736bc6f5@mail.gmail.com> (raw)
In-Reply-To: <E1MCAAh-0004tb-Hc@pomaz-ex.szeredi.hu>

> On Thu, Jun 4, 2009 at 3:27 AM, Miklos Szeredi <miklos@szeredi.hu> wrote:
> Can you tell us a bit more about your use case, and how you worked
> around the limitation?

In this FS, when a process opens a file for write mode access, it
maintains its own private copy of the file until it comes time to
close. Upon close, this private copy is "committed" and replaces the
file on-disk. Meanwhile, while the file is open for writing (before
close) the file on-disk remains untouched (both data and metadata).
Thus, any metadata-changing operations that take place against the
file descriptor must only be seen to the process(es) using that file
descriptor. The intended behavior is that an fstat(2) against the file
descriptor will return the attributes corresponding to the
uncommitted, private copy and a path-based stat(2) will return the
attributes of the file on-disk.

To achieve this behavior, the change I made to the FUSE fs code is
such that when a lookup is performed during a file open(2), the file's
dentry is immediately invalidated, so that we essentially get a
'private' dentry and inode, and subsequent path-walks won't find it.
Then when the file is opened, I stuff the file struct pointer into
dentry->d_fsdata. Then when the getattr is called, I check if the
dentry is disconnected and contains a non-null d_fsdata, and if so,
forward it to an fgetattr handler using the file pointer.

The code is deliciously hacktastic, and adds the cost of all these
unnecessary dentry invalidations and lookups. Plus, I haven't even
tested it thoroughly, so I'm sure it's gonna screw up some other
things. The desired approach here is to just cut to the chase and be
able to handle stats made directly to the file descriptor with an
fgetattr operation using the underlying file struct.

Cheers,
- Brian

  reply	other threads:[~2009-06-04 17:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-03 17:32 fgetattr/fsetattr file operation Brian Molnar
2009-06-04 10:27 ` Miklos Szeredi
2009-06-04 17:42   ` Brian Molnar [this message]
2009-06-04 19:04     ` Andreas Dilger
2009-06-04 19:46       ` Brian Molnar
2009-06-05 10:35         ` Miklos Szeredi
2009-06-08  1:59           ` Jamie Lokier
2009-06-08 22:26             ` Brian Molnar

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=b7ee1e6e0906041042q44dbc1a6ge7b82dc0736bc6f5@mail.gmail.com \
    --to=brian.molnar@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /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).