Received: from fout-b5-smtp.messagingengine.com (fout-b5-smtp.messagingengine.com [202.12.124.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F35B83624C9 for ; Mon, 13 Jul 2026 06:23:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.148 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783923821; cv=none; b=nKHlvt0lqy7JyEZTuNCShRaSE10WSX4dwU6IXaISTXGaM4byACpGM1bL7C5sKL4JBCiYO2DyLH34iVpoVjy4UxL/2yJ+n6HpYjsZiL7wITf+SpB0ZWdZDbwuIO/A7IqLUka+48rOWNtB4i6P1Y9oPRqe/OoQhmODEvqgNirMdB4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783923821; c=relaxed/simple; bh=QL0TAkjCAYdQ0HxpJHUS23RBa9MMLHOK0h3iyx4AWhM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O9yHqS22REW3YQVw7nGOgj0uh39Pm8ozws3VodCX5sS7rSnp/5yOzp+r3hj6Kg6YI8hZvooxpVpkQCmbPMSoAPwuv8QVvj3Lszaqcpq2iNKnYJGTtMcjMXmjONf1VlsDLZkvkUCTN3z3l5+8oHRfhKujHvUpIaCRvIrrSQpnFiY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=clIjLjLY; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Ec17qBtF; arc=none smtp.client-ip=202.12.124.148 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="clIjLjLY"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Ec17qBtF" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id 2EE921D00037; Mon, 13 Jul 2026 02:23:39 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Mon, 13 Jul 2026 02:23:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm2; t=1783923819; x=1784010219; bh=CtEurziv4dmJP7k1AI9BOpEAYMEEQuh3Bv8XKA/peGE=; b= clIjLjLYW6NTUxFv7TEHgwQS/dyYQSm7/FdBoog1/aCDsfXoLCOHPitLjAfSJixL 0d51kPqiZQOQvgedxbC3TSEYN+4AFJOwmjkxVuzEWg9RX319yOadTMEq3kgb1t2n MPM8yPHXQnb0VOnhug4tq+3CHQfqvSGHORLgjh2gOUkrDGXhVnET4ug+P3euJhhO A9qXBP5St5js38vvBFpsqVboDngtKoGaa4XnOJVt7PYTdhwHR+Ww4THqc9G4udpD WIcH0Ljz/ePjf58bBrIgkUjk/pP3yWJ9ulaqbU8lZONrWYA1k1tZkfKGR8KbB/Gu BHd3o2QmJaHpQ9jsFQyRRg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1783923819; x=1784010219; bh=C tEurziv4dmJP7k1AI9BOpEA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mwiWJF8EyqFJ2N+wfm0YwZ2Odo+zxN0XL4/BQ X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 13 Jul 2026 02:23:36 -0400 (EDT) From: NeilBrown To: Chuck Lever , Jeff Layton Cc: Olga Kornievskaia , Dai Ngo , Tom Talpey , linux-nfs@vger.kernel.org Subject: [PATCH v3 13/17] nfsd: move some code out of the d_really_is_negative() branch in nfsd4_create_file() Date: Mon, 13 Jul 2026 16:15:36 +1000 Message-ID: <20260713062219.6399-14-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260713062219.6399-1-neilb@ownmail.net> References: <20260713062219.6399-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: NeilBrown The benefit of this code movement isn't immediately obvious, but it will make it easier to switch to using vfs_lookup_open(). One immediate benefit is that common code in the d_is_positive() branch can be discarded. Reviewed-by: Jeff Layton Signed-off-by: NeilBrown --- fs/nfsd/nfs4proc.c | 73 ++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 45 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 32b6c0e507ea..adfc1f5ccd98 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -219,7 +219,11 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp, .na_iattr = iap, .na_seclabel = &open->op_label, }; + int oflags = O_CREAT | O_LARGEFILE; struct dentry *parent, *child = ERR_PTR(-EINVAL); + struct path path = { + .mnt = fhp->fh_export->ex_path.mnt, + }; __u32 v_mtime, v_atime; struct inode *inode; __be32 status, create_status; @@ -268,6 +272,24 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp, if (!IS_POSIXACL(inode)) iap->ia_mode &= ~current_umask(); + /* + * For the EXCLUSIVE modes we do our own uniqueness tests + * so don't want O_EXCL. + */ + if (open->op_createmode == NFS4_CREATE_GUARDED) + oflags |= O_EXCL; + + switch (open->op_share_access & NFS4_SHARE_ACCESS_BOTH) { + case NFS4_SHARE_ACCESS_WRITE: + oflags |= O_WRONLY; + break; + case NFS4_SHARE_ACCESS_BOTH: + oflags |= O_RDWR; + break; + default: + oflags |= O_RDONLY; + } + if (!is_create_with_attrs(open)) { /* No attrs to check */ } else if (open->op_acl) { @@ -324,27 +346,13 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp, status = nfserrno(PTR_ERR(child)); goto out; } + path.dentry = child; if (d_really_is_positive(child)) { /* * open the file so that we consistently have a valid * op_filp and consequently a valid ->f_path.dentry. */ - struct path path = {.mnt = fhp->fh_export->ex_path.mnt, - .dentry = child, - }; - unsigned int oflags = O_LARGEFILE; - - switch (open->op_share_access & NFS4_SHARE_ACCESS_BOTH) { - case NFS4_SHARE_ACCESS_WRITE: - oflags |= O_WRONLY; - break; - case NFS4_SHARE_ACCESS_BOTH: - oflags |= O_RDWR; - break; - default: - oflags |= O_RDONLY; - } status = nfsd_check_obj_isreg(child, cstate->minorversion); if (status == nfs_ok) { @@ -358,39 +366,14 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp, } else if (create_status) { status = create_status; } else { - struct file *filp; - struct path path; - int oflags; - - oflags = O_CREAT | O_LARGEFILE; - /* - * For the EXCLUSIVE modes we do our own uniqueness tests - * so don't want O_EXCL. - */ - if (open->op_createmode == NFS4_CREATE_GUARDED) - oflags |= O_EXCL; - - switch (open->op_share_access & NFS4_SHARE_ACCESS_BOTH) { - case NFS4_SHARE_ACCESS_WRITE: - oflags |= O_WRONLY; - break; - case NFS4_SHARE_ACCESS_BOTH: - oflags |= O_RDWR; - break; - default: - oflags |= O_RDONLY; - } - - path.mnt = fhp->fh_export->ex_path.mnt; - path.dentry = child; - filp = dentry_create(&path, oflags, open->op_iattr.ia_mode, - current_cred()); + open->op_filp = dentry_create(&path, oflags, open->op_iattr.ia_mode, + current_cred()); child = path.dentry; - if (IS_ERR(filp)) { - status = nfserrno(PTR_ERR(filp)); + if (IS_ERR(open->op_filp)) { + status = nfserrno(PTR_ERR(open->op_filp)); + open->op_filp = NULL; } else { - open->op_filp = filp; open->op_created = open->op_filp->f_mode & FMODE_CREATED; } } -- 2.50.0.107.gf914562f5916.dirty