From mboxrd@z Thu Jan 1 00:00:00 1970 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 D96733815F9 for ; Mon, 13 Jul 2026 06:22:55 +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=1783923777; cv=none; b=G9ygRkhMT9cfY2ImOSOFpJa2/JABKyDWzMLJPedQZrWjkxoKOfjsZXoGOF99OFdJhCW75nElsNyKgZ4/ponkK1oOOYXLrVasnQ18eii02kNqQH5SE2mw28kO7RivewjXmYFmg/xr5rLdHI82+0sC40aekxC5dfxOvcvIuRC5b28= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783923777; c=relaxed/simple; bh=op+2Wl1aPikAUcdiWYgc/njInRpQJZvvKte6SES4VcY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LogcACBPIUyaX3wVwXr2JXhZyP5xuI3THZ8AoJNljZwiTNcw+dL/UlzxWKxcOxFTEtD3KRaELkDQohgGBq6ab8p8sYOV5QWNeb6ev7H/r1kuDfTwYYTMxhcqy9UlTu3Xc5yA9kmlsC51pu5Dr83qtZ+y74m2gX/iqO4GgRUlrOQ= 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=IeXVOHi/; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=qIOu+i0G; 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="IeXVOHi/"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="qIOu+i0G" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.stl.internal (Postfix) with ESMTP id 26A1D1D00037; Mon, 13 Jul 2026 02:22:55 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Mon, 13 Jul 2026 02:22:55 -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=1783923775; x=1784010175; bh=ZeyC/nem1pRuWB+nOmsyjIjSYltljiu/J0jaayAYlb4=; b= IeXVOHi/g4deGZcVB554WGbHtM/nFZ73yZcYYqw8l93n2RuJDzRnL+XIUG+g+NUu vci21umkjw/Mvwwj4qAjDb28D0abTGiK9EQY7lmv5d1Z5k1wsCQcsZdnvwU3sPqc dts/6r7er5Pjc9TvX/VPQx76bvbrXzBLG5cGu/20D1aUvOGFQmj6AngVWmHp6ZuX Y1geyX8GesOtZ2xSf29kQ5+OwI2Rf1QMKDqqTjS3pFW78UcVNY2nhTSFITUwHfre j4HoJ4osoWHRHT9H22wIySNwMzPzXodpIb6IMMn4fvLGOGgwBopps7AFszXgFETQ mkB1444PDXe9cGQBwDT9MQ== 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=1783923775; x=1784010175; bh=Z eyC/nem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YtaNxQ4UBdieQsrDOjyoig X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 13 Jul 2026 02:22:52 -0400 (EDT) From: NeilBrown To: Chuck Lever , Jeff Layton Cc: Olga Kornievskaia , Dai Ngo , Tom Talpey , linux-nfs@vger.kernel.org Subject: [PATCH v3 04/17] nfsd: move fh_want_write() after preamble in nfsd4_create_file() Date: Mon, 13 Jul 2026 16:15:27 +1000 Message-ID: <20260713062219.6399-5-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 As part of separating the nfsd-specific code from the VFS interaction code in nfsd4_create_file(), move fh_want_write() to just before we need it. Consequently errors in the "if" statement that this code is moved over can now be returned immediately rather than needing to "goto out". Also restructure that "if" statement to only test is_create_with_attrs() once. Reviewed-by: Jeff Layton Signed-off-by: NeilBrown --- fs/nfsd/nfs4proc.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 3e5c1fdde57b..443ed535e092 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -299,22 +299,18 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp, dput(child); } - host_err = fh_want_write(fhp); - if (host_err) - return nfserrno(host_err); - - if (open->op_acl) { + if (!is_create_with_attrs(open)) { + /* No attrs to check */ + } else if (open->op_acl) { if (open->op_dpacl || open->op_pacl) { - status = nfserr_inval; - goto out; + /* Cannot specify both NFSv4 and Posix ACLs */ + return nfserr_inval; } - if (is_create_with_attrs(open)) { - status = nfsd4_acl_to_attr(NF4REG, open->op_acl, + status = nfsd4_acl_to_attr(NF4REG, open->op_acl, &attrs); - if (status) - goto out; - } - } else if (is_create_with_attrs(open)) { + if (status) + return status; + } else { /* The dpacl and pacl will get released by nfsd_attrs_free(). */ attrs.na_dpacl = open->op_dpacl; attrs.na_pacl = open->op_pacl; @@ -322,6 +318,12 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp, open->op_pacl = NULL; } + host_err = fh_want_write(fhp); + if (host_err) { + status = nfserrno(host_err); + goto out_free; + } + child = start_creating(&nop_mnt_idmap, parent, &QSTR_LEN(open->op_fname, open->op_fnamelen)); if (IS_ERR(child)) { @@ -438,8 +440,9 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp, open->op_bmval[2] &= ~FATTR4_WORD2_POSIX_ACCESS_ACL; out: end_creating(child); - nfsd_attrs_free(&attrs); fh_drop_write(fhp); +out_free: + nfsd_attrs_free(&attrs); return status; } -- 2.50.0.107.gf914562f5916.dirty