Commit 37d69284 authored by Christian Brauner's avatar Christian Brauner Committed by Jinjie Ruan
Browse files

fs: rearrange general fastpath check now that O_CREAT uses it

mainline inclusion
from mainline-v6.12-rc1
commit 0f93bb54a3a502077bca4d7beb1fe2a90d3b59db
category: performance
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IB1S01

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0f93bb54a3a502077bca4d7beb1fe2a90d3b59db



--------------------------------

If we find a positive dentry we can now simply try and open it. All
prelimiary checks are already done with or without O_CREAT.

Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
Conflicts:
	fs/namei.c
[Context conflict]
Signed-off-by: default avatarJinjie Ruan <ruanjinjie@huawei.com>
parent cba71769
Loading
Loading
Loading
Loading
+4 −13
Original line number Diff line number Diff line
@@ -3564,25 +3564,16 @@ static const char *open_last_lookups(struct nameidata *nd,
	if (IS_ERR(dentry))
		return ERR_CAST(dentry);

	if (!(open_flag & O_CREAT)) {
	if (likely(dentry))
		goto finish_lookup;

	if (!(open_flag & O_CREAT)) {
		BUG_ON(nd->flags & LOOKUP_RCU);
	} else {
		if (nd->flags & LOOKUP_RCU) {
			bool unlazied;

			/* can stay in rcuwalk if not auditing */
			if (dentry)
				goto finish_lookup;
			unlazied = dentry ? try_to_unlazy_next(nd, dentry) :
					    try_to_unlazy(nd);
			if (!unlazied)
			if (!try_to_unlazy(nd))
				return ERR_PTR(-ECHILD);
		}
		if (dentry)
			goto finish_lookup;
	}

	if (open_flag & (O_CREAT | O_TRUNC | O_WRONLY | O_RDWR)) {