From: Christoph Hellwig <hch@lst.de>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>, linux-fsdevel@vger.kernel.org
Subject: Re: [RFC] weird use of dget_parent() in xfs_filestream_get_parent()
Date: Tue, 8 Apr 2025 08:26:28 +0200 [thread overview]
Message-ID: <20250408062628.GA1361@lst.de> (raw)
In-Reply-To: <20250324215215.GJ2023217@ZenIV>
On Mon, Mar 24, 2025 at 09:52:15PM +0000, Al Viro wrote:
> 1) dget_parent(dentry) never returns NULL; if you have IS_ROOT(dentry) you
> get an equivalent of dget(dentry). What do you want returned in that
> case?
xfs_filestream_get_parent is only called for regular files. IS_ROOT can
probably only happen for partially connected trees on nfs exports, in which
case we'd want NULL;
>
> 2) why bother with dget_parent() in the first place? What's wrong with
> spin_lock(&dentry->d_lock); // stabilizes ->d_parent
> dir = igrab(dentry->d_parent->d_inode);
> spin_unlock(&dentry->d_lock);
>
> or, if you intended NULL for root,
> spin_lock(&dentry->d_lock); // stabilizes ->d_parent
> if (!IS_ROOT(dentry))
> dir = igrab(dentry->d_parent->d_inode);
> spin_unlock(&dentry->d_lock);
>
>
> Is there anything subtle I'm missing here?
Nothing really, except that this probably feelt like poking a bit too
much into internals.
prev parent reply other threads:[~2025-04-08 6:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-24 21:52 [RFC] weird use of dget_parent() in xfs_filestream_get_parent() Al Viro
2025-03-25 5:50 ` Al Viro
2025-04-08 6:26 ` Christoph Hellwig [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=20250408062628.GA1361@lst.de \
--to=hch@lst.de \
--cc=linux-fsdevel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.