summaryrefslogtreecommitdiff
path: root/fs/hostfs
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2025-02-27 12:32:54 +1100
committerChristian Brauner <brauner@kernel.org>2025-02-27 20:00:17 +0100
commit3f90030e121201cb274cc4754d7be23099180d25 (patch)
tree65c5f07f9a2625c1f4fa57bd04efecf0721900be /fs/hostfs
parent88d5baf69082e5b410296435008329676b687549 (diff)
downloadlinux-3f90030e121201cb274cc4754d7be23099180d25.tar.gz
linux-3f90030e121201cb274cc4754d7be23099180d25.tar.bz2
linux-3f90030e121201cb274cc4754d7be23099180d25.zip
hostfs: store inode in dentry after mkdir if possible.
After handling a mkdir, get the inode for the name and use d_splice_alias() to store the correct dentry in the dcache. Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: NeilBrown <neilb@suse.de> Link: https://lore.kernel.org/r/20250227013949.536172-3-neilb@suse.de Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/hostfs')
-rw-r--r--fs/hostfs/hostfs_kern.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index ccbb48fe830d..a2c6b9051c5b 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -682,14 +682,22 @@ static int hostfs_symlink(struct mnt_idmap *idmap, struct inode *ino,
static struct dentry *hostfs_mkdir(struct mnt_idmap *idmap, struct inode *ino,
struct dentry *dentry, umode_t mode)
{
+ struct inode *inode;
char *file;
int err;
if ((file = dentry_name(dentry)) == NULL)
return ERR_PTR(-ENOMEM);
err = do_mkdir(file, mode);
+ if (err) {
+ dentry = ERR_PTR(err);
+ } else {
+ inode = hostfs_iget(dentry->d_sb, file);
+ d_drop(dentry);
+ dentry = d_splice_alias(inode, dentry);
+ }
__putname(file);
- return ERR_PTR(err);
+ return dentry;
}
static int hostfs_rmdir(struct inode *ino, struct dentry *dentry)