linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>,
	linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [RFC] dget_parent() misuse in xfs_filestream_get_parent()
Date: Mon, 8 Jul 2019 09:22:54 +1000	[thread overview]
Message-ID: <20190707232254.GF7689@dread.disaster.area> (raw)
In-Reply-To: <20190628060026.GR17978@ZenIV.linux.org.uk>

On Fri, Jun 28, 2019 at 07:00:27AM +0100, Al Viro wrote:
> 	dget_parent() never returns NULL.  So this
> 
>         parent = dget_parent(dentry);
>         if (!parent)
>                 goto out_dput;
> 
>         dir = igrab(d_inode(parent));
>         dput(parent);
> 
> out_dput:
> 
> is obviously fishy.  What is that code trying to do?  Is that
> "dentry might be a root of disconnected tree, in which case
> we want xfs_filestream_get_parent() to return NULL"? 

We want the parent inode of the current file inode if it is in
memory. We don't care about the parent dentry that is returned as
such, it's just the mechanism for finding the directory inode. The
directory inode is what holds the allocation policy for all files in
that directory, and that's what we need here.

If there is no parent directory inode in memory, then we'll just use
the default allocator behaviour rather than the context specific
one we get from the directory inode...

> If so,
> that should be
> 
>         parent = dget_parent(dentry);
>         if (parent != dentry)
> 		dir = igrab(d_inode(parent));
>         dput(parent);

Seems reasonable. This code is largely legacy functionality, the
allocator was really a specific workload policy that was never
widely deployed and so the combination of disconnected dentries and
this allocator have probably never been seen in real life...

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

      reply	other threads:[~2019-07-07 23:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-28  6:00 [RFC] dget_parent() misuse in xfs_filestream_get_parent() Al Viro
2019-07-07 23:22 ` Dave Chinner [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=20190707232254.GF7689@dread.disaster.area \
    --to=david@fromorbit.com \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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).