linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Michael Thayer <michael.thayer@oracle.com>,
	Larry Finger <Larry.Finger@lwfinger.net>,
	Christoph Hellwig <hch@infradead.org>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v2] fs: Add VirtualBox guest shared folder (vboxsf) support
Date: Wed, 17 Jan 2018 03:19:10 +0000	[thread overview]
Message-ID: <20180117031910.GR13338@ZenIV.linux.org.uk> (raw)
In-Reply-To: <02e61d96-75b0-cb29-ecb5-36f91f41695e@redhat.com>

On Tue, Jan 16, 2018 at 11:15:15AM +0100, Hans de Goede wrote:
> > * your ->rename() can race with ->get_link().  Look at the place where
> >    the former reassigns ->path and frees the old value and think what
> >    happens if the latter is called just prior to that kfree().
> > 
> > * the same goes for sf_inode_revalidate() vs. rename().
> > 
> > * just what happens to ->path of inode when e.g. its grandparent
> >    directory is renamed?
> 
> Can I summarize all 3 above with: Caching the path is a bad idea and
> instead the code should always look up the name from e.g. file->f_path.dentry ?

Caching the path is very likely to be a bad idea.  OTOH, caching conversions
of individual components, which appear to be completely independent of
any inodes, might be useful, especially if you attach the results to dentries
instead of inodes.  That way you only do nls shite on lookups.  Concatenation
of pieces into the pathname is probably best done later and in each case
we really want to decide what to do with racing renames of ancestors *DURING*
vboxsf_...() primitives.  We can be clever and careful while building the
pathname, but what's to prevent it going stale just as we'd formed the damn
string and started to do whatever it was we'd formed it for and what happens
in case of such races?

> > * AFAICS, you consider all negative dentries invalid.  Why do you even
> >    hash them, then?
> 
> I'm afraid I'm not entirely following you. Note I've no experience with fs
> code prior to this. Also I'm not the original author of this code, this
> code started as part of the out-of-tree kernel modules used by the
> VirtualBox guest-additions. I've been working on cleaning these modules up
> and then mainlinging them (there are 3 of them, this is the last).
> 
> Note I believe that this code is based on the fs/hostfs code.
> 
> Can you reword your question keeping my lack of experience wrt fs code
> in mind ?

Your ->d_revalidate() flat-out returns 0 on negative dentries.  Which
means "consider them invalid when found by dcache lookup".  So what's
the point of hashing them at all?  Note that the right answer might
very well be "build a pathname anyway, stat the sucker and consider
ENOENT as it's still valid"...

  reply	other threads:[~2018-01-17  3:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-15 17:51 [PATCH v2 0/1] fs: Add VirtualBox guest shared folder (vboxsf) support Hans de Goede
2018-01-15 17:51 ` [PATCH v2] " Hans de Goede
2018-01-15 17:55   ` Christoph Hellwig
2018-01-15 18:01     ` Hans de Goede
2018-01-15 19:32   ` Amir Goldstein
2018-01-15 19:41     ` Hans de Goede
2018-01-15 20:22       ` Amir Goldstein
2018-01-15 22:36   ` Al Viro
2018-01-16 10:15     ` Hans de Goede
2018-01-17  3:19       ` Al Viro [this message]
2018-01-17 10:45         ` Hans de Goede

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=20180117031910.GR13338@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=Larry.Finger@lwfinger.net \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@infradead.org \
    --cc=hdegoede@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.thayer@oracle.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).