Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2779940imw; Sun, 17 Jul 2022 17:02:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tI5xl9CeeK9FVuZeJKxJOxWFV1qraSEJtwxboWszfjAKNk6Q63qrpv+x9TPh++huvK/Ug5 X-Received: by 2002:a63:fc55:0:b0:412:a6e8:b974 with SMTP id r21-20020a63fc55000000b00412a6e8b974mr22755378pgk.279.1658102569937; Sun, 17 Jul 2022 17:02:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658102569; cv=none; d=google.com; s=arc-20160816; b=AibUdE5MRCRgO5ifhUsSgEj2czA/wwRNWT0uleKtr2SUbY/V7AcfwU/1r+ftc0p0u7 ZVlS7TXSqwbYioDEvSmrF931tY6WieQIUIBruZsBPCzYhQtndPt8iUvm0Cglpc+Y5K3p F+erkeU8BflTFmfiQUD7Qa8BulUt3oWvlkX9zE3R68h744pXQlu2ms8tWwctt4f1uOXx IEoY3vc2ge02mIfHh1LHpSoFibbkSFbD0CqsEgstXif5qR4Bz9H/pfkxUJy8YgGNX7bs RM7lIrDEx9DFStLY7VhkLc+IxTAbQouiaYHhm6GtSA5BoCOyaFJ3R3NHTgnzcUhPxlkE sghg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:references:in-reply-to:subject :cc:to:from:mime-version:content-transfer-encoding:dkim-signature :dkim-signature; bh=bxGy6Iff4591Td1q7RnPeMDGgLsq3pC/nzhRniB6ogw=; b=i/j5AH1VzXpHI885car1wVaEcqLrrBCZBrR1d1FMaxWqxqhYU3BJNuEBu7DdfJ+RCv yWNBJm0HTQkk2ZzeK2JpPZFoMlcCoHAEXJ9Y/r1GLHuCqkMI7qWlXr54pMMmGm+w/Czz LVmv83FC3nmCW5zg6AOrjGFbpBYP7BlQUSCGR8XwT7K/ist29ewAHHDsXd7tG5pkcSVp oXPxMGzWrp5XnqV4Sq8sR9xDqga9ZJXIRv1o5+h12RgD4+EGSswaWICR2RmV54X7Noy4 ezh+gGjK4DN+TAuOf/0ud0cugolyykEvX5gDuPYMcctZuLU1h7P3JA7vsMsaGBcxRKQy Q/uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="wWycUr/6"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t2-20020a170902d20200b0016cf48bd5cfsi1008298ply.78.2022.07.17.17.02.28; Sun, 17 Jul 2022 17:02:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="wWycUr/6"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231370AbiGRAAH (ORCPT + 99 others); Sun, 17 Jul 2022 20:00:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230504AbiGRAAG (ORCPT ); Sun, 17 Jul 2022 20:00:06 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2774F12A81 for ; Sun, 17 Jul 2022 17:00:05 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id A656C20544; Mon, 18 Jul 2022 00:00:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1658102403; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bxGy6Iff4591Td1q7RnPeMDGgLsq3pC/nzhRniB6ogw=; b=wWycUr/6YfcqroHnFYJdF6m7V8yGGDVpyAeYFyNJ2rV6DSe6Kjp1msUSNbkvaT0iQ0XTHg fMOPfsew+wDopGkXovkGB9wPazdJpg4EUw19Wk3o/nKVnxMwrUGrteo3eJkH85+C88l8or XD51zUw4XhDYklVFe76n5KrpzAt83Gc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1658102403; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bxGy6Iff4591Td1q7RnPeMDGgLsq3pC/nzhRniB6ogw=; b=wMIDYJUsjItSunSQ7x6XuA/qNTvW5f2H+l72z79hKEutEzYIf+lnyGMyU/ibwvr4vFtL1V gShyXhHe3zma/1DA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 84FF313A89; Mon, 18 Jul 2022 00:00:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CKAzD4Ki1GJebwAAMHmgww (envelope-from ); Mon, 18 Jul 2022 00:00:02 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 From: "NeilBrown" To: "Jeff Layton" Cc: "Chuck Lever" , linux-nfs@vger.kernel.org Subject: Re: [PATCH 6/8] NFSD: use explicit lock/unlock for directory ops In-reply-to: References: <165708033167.1940.3364591321728458949.stgit@noble.brown>, <165708109259.1940.685583862810495747.stgit@noble.brown>, , Date: Mon, 18 Jul 2022 09:59:59 +1000 Message-id: <165810239926.25184.11331523885793016989@noble.neil.brown.name> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Sat, 16 Jul 2022, Jeff Layton wrote: > On Fri, 2022-07-15 at 12:11 -0400, Jeff Layton wrote: >=20 >=20 > [PATCH] SQUASH: nfsd: ensure we fill in pre-op-attrs in > nfsd4_create_file >=20 > In some cases, they're left uninitialized. This also ensures that the > post_op attrs are properly filled in all cases too. >=20 > Signed-off-by: Jeff Layton Thanks Jeff, but I think this is more noisy than necessary. The problem is that the d_really_is_positive() doesn't actually change the directory (obviously) but can succeed - so pre/post attributes are needed by NFSv4 even though they aren't really relevant. I would rather use the same approach as in the !open->op_create branch in d_open_lookup() : fh_fill_pre_attrs(current_fh); fh_fill_post_attrs(current_fh); with a comment explaining that as the directory is locked, and as it isn't being changed, this makes sense. I'll fold that in. Thanks, NeilBrown > --- > fs/nfsd/nfs4proc.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) >=20 > diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c > index 242f059e6788..05652a7dabe8 100644 > --- a/fs/nfsd/nfs4proc.c > +++ b/fs/nfsd/nfs4proc.c > @@ -346,6 +346,7 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh= *fhp, > =20 > switch (open->op_createmode) { > case NFS4_CREATE_UNCHECKED: > + fh_fill_pre_attrs(fhp); > if (!d_is_reg(child)) > break; > =20 > @@ -365,6 +366,7 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh= *fhp, > if (d_inode(child)->i_mtime.tv_sec =3D=3D v_mtime && > d_inode(child)->i_atime.tv_sec =3D=3D v_atime && > d_inode(child)->i_size =3D=3D 0) { > + fh_fill_pre_attrs(fhp); > open->op_created =3D true; > break; /* subtle */ > } > @@ -374,6 +376,7 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh= *fhp, > if (d_inode(child)->i_mtime.tv_sec =3D=3D v_mtime && > d_inode(child)->i_atime.tv_sec =3D=3D v_atime && > d_inode(child)->i_size =3D=3D 0) { > + fh_fill_pre_attrs(fhp); > open->op_created =3D true; > goto set_attr; /* subtle */ > } > @@ -385,12 +388,10 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_= fh *fhp, > if (!IS_POSIXACL(inode)) > iap->ia_mode &=3D ~current_umask(); > =20 > - fh_fill_pre_attrs(fhp); > status =3D nfsd4_vfs_create(fhp, child, open); > if (status !=3D nfs_ok) > goto out; > open->op_created =3D true; > - fh_fill_post_attrs(fhp); > =20 > /* A newly created file already has a file size of zero. */ > if ((iap->ia_valid & ATTR_SIZE) && (iap->ia_size =3D=3D 0)) > @@ -408,6 +409,8 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh= *fhp, > status =3D nfsd_create_setattr(rqstp, fhp, resfhp, iap); > =20 > out: > + if (status =3D=3D nfs_ok) > + fh_fill_post_attrs(fhp); > inode_unlock(inode); > if (child && !IS_ERR(child)) > dput(child); > --=20 > 2.36.1 >=20 >=20 >=20