From: NeilBrown Date: Fri, 20 Mar 2026 00:03:16 +0000 (+1100) Subject: ext4: split __ext4_add_entry() out of ext4_add_entry() X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2879374604b72bd43b346777fa05d3ac6dea9c45;p=thirdparty%2Fkernel%2Flinux.git ext4: split __ext4_add_entry() out of ext4_add_entry() __ext4_add_entry() is not given a dentry - just inodes and name. This will help the next patch which simplifies __ex4_link(). Reviewed-by: Andreas Dilger Reviewed-by: Jan Kara Signed-off-by: NeilBrown Link: https://patch.msgid.link/20260320000838.3797494-2-neilb@ownmail.net Signed-off-by: Theodore Ts'o --- diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 4fdfc81f79028..ba3d85a9c1206 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -2353,10 +2353,10 @@ out_frames: * may not sleep between calling this and putting something into * the entry, as someone else might have used it while you slept. */ -static int ext4_add_entry(handle_t *handle, struct dentry *dentry, +static int __ext4_add_entry(handle_t *handle, struct inode *dir, + const struct qstr *d_name, struct inode *inode) { - struct inode *dir = d_inode(dentry->d_parent); struct buffer_head *bh = NULL; struct ext4_dir_entry_2 *de; struct super_block *sb; @@ -2373,13 +2373,10 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry, sb = dir->i_sb; blocksize = sb->s_blocksize; - if (fscrypt_is_nokey_name(dentry)) - return -ENOKEY; - - if (!generic_ci_validate_strict_name(dir, &dentry->d_name)) + if (!generic_ci_validate_strict_name(dir, d_name)) return -EINVAL; - retval = ext4_fname_setup_filename(dir, &dentry->d_name, 0, &fname); + retval = ext4_fname_setup_filename(dir, d_name, 0, &fname); if (retval) return retval; @@ -2460,6 +2457,16 @@ out: return retval; } +static int ext4_add_entry(handle_t *handle, struct dentry *dentry, + struct inode *inode) +{ + struct inode *dir = d_inode(dentry->d_parent); + + if (fscrypt_is_nokey_name(dentry)) + return -ENOKEY; + return __ext4_add_entry(handle, dir, &dentry->d_name, inode); +} + /* * Returns 0 for success, or a negative error value */