Moving the main logic to a helper function makes the whole thing much easier to follow. Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx> Cc: Christian Brauner <christian.brauner@xxxxxxxxxx> Suggested-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> Link: https://lore.kernel.org/io-uring/CAHk-=wijsw1QSsQHFu_6dEoZEr_zvT7++WJWohcuEkLqqXBGrQ@xxxxxxxxxxxxxx/ Signed-off-by: Dmitry Kadashev <dkadashev@xxxxxxxxx> --- fs/namei.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index bb18b1adfea5..b9762e2cf3b9 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3850,18 +3850,16 @@ int vfs_mkdir(struct user_namespace *mnt_userns, struct inode *dir, } EXPORT_SYMBOL(vfs_mkdir); -int do_mkdirat(int dfd, struct filename *name, umode_t mode) +static int mkdirat_helper(int dfd, struct filename *name, umode_t mode, + unsigned int lookup_flags) { struct dentry *dentry; struct path path; int error; - unsigned int lookup_flags = LOOKUP_DIRECTORY; -retry: dentry = __filename_create(dfd, name, &path, lookup_flags); - error = PTR_ERR(dentry); if (IS_ERR(dentry)) - goto out_putname; + return PTR_ERR(dentry); if (!IS_POSIXACL(path.dentry->d_inode)) mode &= ~current_umask(); @@ -3873,11 +3871,21 @@ int do_mkdirat(int dfd, struct filename *name, umode_t mode) mode); } done_path_create(&path, dentry); + + return error; +} + +int do_mkdirat(int dfd, struct filename *name, umode_t mode) +{ + unsigned int lookup_flags = LOOKUP_DIRECTORY; + int error; + + error = mkdirat_helper(dfd, name, mode, lookup_flags); if (retry_estale(error, lookup_flags)) { lookup_flags |= LOOKUP_REVAL; - goto retry; + error = mkdirat_helper(dfd, name, mode, lookup_flags); } -out_putname: + putname(name); return error; } -- 2.30.2