Commit 5c2d4f65 authored by Christian Brauner's avatar Christian Brauner Committed by Jinjie Ruan
Browse files

fs: pull up trailing slashes check for O_CREAT

mainline inclusion
from mainline-v6.12-rc1
commit 4770d96a6d89c7dd5675056629c0008f7f8106bf
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=4770d96a6d89c7dd5675056629c0008f7f8106bf



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

Perform the check for trailing slashes right in the fastpath check and
don't bother with any additional work.

Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
Signed-off-by: default avatarJinjie Ruan <ruanjinjie@huawei.com>
parent c686925f
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -3516,6 +3516,9 @@ static struct dentry *lookup_fast_for_open(struct nameidata *nd, int open_flag)
	struct dentry *dentry;

	if (open_flag & O_CREAT) {
		if (trailing_slashes(nd))
			return ERR_PTR(-EISDIR);

		/* Don't bother on an O_EXCL create */
		if (open_flag & O_EXCL)
			return NULL;
@@ -3581,20 +3584,13 @@ static const char *open_last_lookups(struct nameidata *nd,
			bool unlazied;

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