From: Al Viro <viro@zeniv.linux.org.uk>
To: linux-fsdevel@vger.kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Christian Brauner <brauner@kernel.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH 11/20] kill d_instantate_anon(), fold __d_instantiate_anon() into remaining caller
Date: Fri, 24 Nov 2023 06:06:35 +0000 [thread overview]
Message-ID: <20231124060644.576611-11-viro@zeniv.linux.org.uk> (raw)
In-Reply-To: <20231124060644.576611-1-viro@zeniv.linux.org.uk>
now that the only user of d_instantiate_anon() is gone...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
fs/dcache.c | 88 ++++++++++++++++--------------------------
include/linux/dcache.h | 1 -
2 files changed, 33 insertions(+), 56 deletions(-)
diff --git a/fs/dcache.c b/fs/dcache.c
index 9f5b2b5c1e6d..6dde21dbdd1a 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -2054,75 +2054,53 @@ struct dentry *d_make_root(struct inode *root_inode)
}
EXPORT_SYMBOL(d_make_root);
-static struct dentry *__d_instantiate_anon(struct dentry *dentry,
- struct inode *inode,
- bool disconnected)
-{
- struct dentry *res;
- unsigned add_flags;
-
- security_d_instantiate(dentry, inode);
- spin_lock(&inode->i_lock);
- res = __d_find_any_alias(inode);
- if (res) {
- spin_unlock(&inode->i_lock);
- dput(dentry);
- goto out_iput;
- }
-
- /* attach a disconnected dentry */
- add_flags = d_flags_for_inode(inode);
-
- if (disconnected)
- add_flags |= DCACHE_DISCONNECTED;
-
- spin_lock(&dentry->d_lock);
- __d_set_inode_and_type(dentry, inode, add_flags);
- hlist_add_head(&dentry->d_u.d_alias, &inode->i_dentry);
- if (!disconnected) {
- hlist_bl_lock(&dentry->d_sb->s_roots);
- hlist_bl_add_head(&dentry->d_hash, &dentry->d_sb->s_roots);
- hlist_bl_unlock(&dentry->d_sb->s_roots);
- }
- spin_unlock(&dentry->d_lock);
- spin_unlock(&inode->i_lock);
-
- return dentry;
-
- out_iput:
- iput(inode);
- return res;
-}
-
-struct dentry *d_instantiate_anon(struct dentry *dentry, struct inode *inode)
-{
- return __d_instantiate_anon(dentry, inode, true);
-}
-EXPORT_SYMBOL(d_instantiate_anon);
-
static struct dentry *__d_obtain_alias(struct inode *inode, bool disconnected)
{
- struct dentry *tmp;
- struct dentry *res;
+ struct super_block *sb = inode->i_sb;
+ struct dentry *new, *res;
if (!inode)
return ERR_PTR(-ESTALE);
if (IS_ERR(inode))
return ERR_CAST(inode);
- res = d_find_any_alias(inode);
+ res = d_find_any_alias(inode); /* existing alias? */
if (res)
- goto out_iput;
+ goto out;
- tmp = d_alloc_anon(inode->i_sb);
- if (!tmp) {
+ new = d_alloc_anon(sb);
+ if (!new) {
res = ERR_PTR(-ENOMEM);
- goto out_iput;
+ goto out;
}
- return __d_instantiate_anon(tmp, inode, disconnected);
+ security_d_instantiate(new, inode);
+ spin_lock(&inode->i_lock);
+ res = __d_find_any_alias(inode); /* recheck under lock */
+ if (likely(!res)) { /* still no alias, attach a disconnected dentry */
+ unsigned add_flags = d_flags_for_inode(inode);
+
+ if (disconnected)
+ add_flags |= DCACHE_DISCONNECTED;
+
+ spin_lock(&new->d_lock);
+ __d_set_inode_and_type(new, inode, add_flags);
+ hlist_add_head(&new->d_u.d_alias, &inode->i_dentry);
+ if (!disconnected) {
+ hlist_bl_lock(&sb->s_roots);
+ hlist_bl_add_head(&new->d_hash, &sb->s_roots);
+ hlist_bl_unlock(&sb->s_roots);
+ }
+ spin_unlock(&new->d_lock);
+ spin_unlock(&inode->i_lock);
+ inode = NULL; /* consumed by new->d_inode */
+ res = new;
+ } else {
+ spin_unlock(&inode->i_lock);
+ dput(new);
+ }
-out_iput:
+ out:
iput(inode);
return res;
}
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index fa0414cff85c..8c5e3bdf1147 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -218,7 +218,6 @@ extern seqlock_t rename_lock;
*/
extern void d_instantiate(struct dentry *, struct inode *);
extern void d_instantiate_new(struct dentry *, struct inode *);
-extern struct dentry * d_instantiate_anon(struct dentry *, struct inode *);
extern void __d_drop(struct dentry *dentry);
extern void d_drop(struct dentry *dentry);
extern void d_delete(struct dentry *);
--
2.39.2
next prev parent reply other threads:[~2023-11-24 6:10 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-24 6:05 [PATCHES] assorted dcache stuff Al Viro
2023-11-24 6:06 ` [PATCH 01/20] selinux: saner handling of policy reloads Al Viro
2023-11-24 6:06 ` [PATCH 02/20] ovl: stop using d_alloc_anon()/d_instantiate_anon() Al Viro
2023-11-24 6:06 ` [PATCH 03/20] struct dentry: get rid of randomize_layout idiocy Al Viro
2023-11-24 6:06 ` [PATCH 04/20] get rid of __dget() Al Viro
2023-11-24 6:06 ` [PATCH 05/20] DCACHE_... ->d_flags bits: switch to BIT() Al Viro
2023-11-24 6:06 ` [PATCH 06/20] DCACHE_COOKIE: RIP Al Viro
2023-11-24 6:06 ` [PATCH 07/20] kill d_{is,set}_fallthru() Al Viro
2023-11-24 6:06 ` [PATCH 08/20] dentry.h: trim externs Al Viro
2023-11-24 6:06 ` [PATCH 09/20] [software coproarchaeology] dentry.h: kill a mysterious comment Al Viro
2023-11-24 7:37 ` Amir Goldstein
2023-11-24 8:11 ` Al Viro
2023-11-24 8:26 ` Al Viro
2023-11-24 8:29 ` Christian Brauner
2023-11-24 6:06 ` [PATCH 10/20] kill d_backing_dentry() Al Viro
2023-11-24 6:06 ` Al Viro [this message]
2023-11-24 6:06 ` [PATCH 12/20] d_alloc_pseudo(): move setting ->d_op there from the (sole) caller Al Viro
2023-11-24 6:06 ` [PATCH 13/20] nsfs: use d_make_root() Al Viro
2023-11-24 6:06 ` [PATCH 14/20] simple_fill_super(): don't bother with d_genocide() on failure Al Viro
2023-11-24 6:06 ` [PATCH 15/20] d_genocide(): move the extern into fs/internal.h Al Viro
2023-11-24 6:35 ` d_genocide()? What about d_holodomor(), d_massmurder(), d_execute_warcrimes()? " Cedric Blancher
2023-11-24 6:57 ` Al Viro
2023-11-24 7:48 ` Al Viro
2023-11-24 9:36 ` Martin Steigerwald
2023-11-24 18:21 ` identifiers Al Viro
2025-12-09 22:29 ` d_genocide()? What about d_holodomor(), d_massmurder(), d_execute_warcrimes()? Re: [PATCH 15/20] d_genocide(): move the extern into fs/internal.h Askar Safin
2023-11-24 6:06 ` [PATCH 16/20] get rid of DCACHE_GENOCIDE Al Viro
2023-11-24 6:06 ` [PATCH 17/20] d_alloc_parallel(): in-lookup hash insertion doesn't need an RCU variant Al Viro
2023-11-24 6:06 ` [PATCH 18/20] __d_unalias() doesn't use inode argument Al Viro
2023-11-24 6:06 ` [PATCH 19/20] kill DCACHE_MAY_FREE Al Viro
2023-11-24 6:06 ` [PATCH 20/20] dcache: remove unnecessary NULL check in dget_dlock() Al Viro
2023-11-24 21:41 ` [PATCHES] assorted dcache stuff Linus Torvalds
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=20231124060644.576611-11-viro@zeniv.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/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
all inboxes | Powered by JetHome®