Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1678263pxb; Wed, 9 Feb 2022 01:59:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxDWSqohey9MwJoKICC+g/FjK5T6nL7Mjb31NA1vBzsOR3TZcfbrOdw1pFzoJ2d7/7Vm43g X-Received: by 2002:a17:902:9343:: with SMTP id g3mr1364667plp.11.1644400764169; Wed, 09 Feb 2022 01:59:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644400764; cv=none; d=google.com; s=arc-20160816; b=jbf8swTinXiHkG/JFFox7ZUda9FmoiEJS1rL1GfBc5ag/GalDZK5M9F8vQuMxxZNsq FlpvZOb8ch9j4zMnUaiqKr6tXbyjGhiTWzSrRZfdwTvz8RjkLAgqyfKMb5vwJiI8n+xb SW+sKbXzsGBm96sc8MXqcDXVp3eHLPuRERF7v0xe3jn6WOarkqjGiW2NJ8b0bJL1VrHk WZ3w2Oc/48GgNFuvHdw93EnxN7cdBIP6J7oBsc2QcTJBMYmcD0J6BJ08NcXwS8UcN0sy 4cX1gVHg6hqyCB2bUgFP84doMUyeTaqgviTBXNxhXtgj6xQKopevPND+sLmr9HoYMTn7 zzVA== 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=d5p0MIHswhcS0+g7iLFtPUAf+O5Ri22V68bNXUlBffw=; b=jU6Rz1Yeoa3cAQmAbKOzt6PQ4o/ePqmlPxp5342byzQMcm/lUD9akakgkrA+L3XCzS i5aINAocE4pI5phpSkslHzbJDLhQYOUg75FkBZgQPF1QoL2QZOr5/uxZSXgIXQPDm7yj 0mBe6NuxIdQU5c0n5pI+VGL7M5MEwGC3bqutHJGYXc58dHRLt4qc7yHUNalqs6f9tjtT esUnAwHuDpmaNGhf9N8k0PGBwxLk38FUsAcZR0QI0plVvKsKGNK1W/0fLs12cvQfkbJ8 L4FmR6MwwiqMZzaaUIQ8R7YtHqA9lPqLerkdH6gaW8+GZMS7yqeF9nO0Vh/S4dmG66nr gQZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Wc5rIzjc; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=TsJcAIcj; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nv2si5456496pjb.20.2022.02.09.01.59.09; Wed, 09 Feb 2022 01:59:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Wc5rIzjc; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=TsJcAIcj; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 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 S1347270AbiBGGP4 (ORCPT + 99 others); Mon, 7 Feb 2022 01:15:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241374AbiBGEQi (ORCPT ); Sun, 6 Feb 2022 23:16:38 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A536C061A73 for ; Sun, 6 Feb 2022 20:16:37 -0800 (PST) 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-out1.suse.de (Postfix) with ESMTPS id AB223210E5; Mon, 7 Feb 2022 04:16:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1644207395; 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=d5p0MIHswhcS0+g7iLFtPUAf+O5Ri22V68bNXUlBffw=; b=Wc5rIzjckDqmiyJdtf+x9Y4UktzST04PjVy7GYZMc9HK8kIF5RjXg5fb9jFLJNtSxcN6hD k5Oh5Gm1Ox/qwmklF79SCX8JuB0JGwmVIl7RO1y/WBke6SPIovYX0PlPtV4TXGP/SiL0iX tthHs9S1K5BvAuEUddM86He54WyPpIg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1644207395; 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=d5p0MIHswhcS0+g7iLFtPUAf+O5Ri22V68bNXUlBffw=; b=TsJcAIcjXlsHaMUxo4Gj3osnxJJo1A7Bwppdzzr7C5zogE/Xu0GDhZ1r1MB+TpkULQtF03 g33tjNItLrIcawDw== 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 051A41330E; Mon, 7 Feb 2022 04:16:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ZvVxLCGdAGK3LQAAMHmgww (envelope-from ); Mon, 07 Feb 2022 04:16:33 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 From: "NeilBrown" To: "inoguchi.yuki@fujitsu.com" Cc: "'Trond Myklebust'" , "'bfields@fieldses.org'" , "'linux-nfs@vger.kernel.org'" , "'mbenjami@redhat.com'" Subject: RE: client caching and locks In-reply-to: =?utf-8?q?=3COSZPR01MB7050AD4E6F85ABE698EC4CA3EF289=40OSZPR01MB?= =?utf-8?q?7050=2Ejpnprd01=2Eprod=2Eoutlook=2Ecom=3E?= References: <20201001214749.GK1496@fieldses.org>, , <20201006172607.GA32640@fieldses.org>, <164066831190.25899.16641224253864656420@noble.neil.brown.name>, <20220103162041.GC21514@fieldses.org>, =?utf-8?q?=3COSZPR01MB7050F9737016E8?= =?utf-8?q?E3F0FD5255EF4A9=40OSZPR01MB7050=2Ejpnprd01=2Eprod=2Eoutlook=2Ecom?= =?utf-8?q?=3E=2C?= <03e4cc01e9e66e523474c10846ee22147b78addf.camel@hammerspace.com>, <20220104153205.GA7815@fieldses.org>, <1257915fc5fd768e6c1c70fd3e8e3ed3fa1dc33e.camel@hammerspace.com>, =?utf-8?q?=3COSZPR01MB7050C5098D47514FFEC2DA82EF4B9=40OSZPR01MB7050=2Ejpnpr?= =?utf-8?q?d01=2Eprod=2Eoutlook=2Ecom=3E=2C?= <20220105220353.GF25384@fieldses.org>, <164176553564.25899.8328729314072677083@noble.neil.brown.name>, =?utf-8?q??= =?utf-8?q?=3COSZPR01MB7050A3B0D15D38420532CD31EF579=40OSZPR01MB7050=2Ejpnpr?= =?utf-8?q?d01=2Eprod=2Eoutlook=2Ecom=3E=2C?= <164245842205.24166.5326728089527364990@noble.neil.brown.name>, =?utf-8?q??= =?utf-8?q?=3COSZPR01MB7050DF6073AB2EC4F82A589AEF279=40OSZPR01MB7050=2Ejpnpr?= =?utf-8?q?d01=2Eprod=2Eoutlook=2Ecom=3E=2C?= <164377705404.1660.1273338182990772730@noble.neil.brown.name>, =?utf-8?q??= =?utf-8?q?=3COSZPR01MB7050AD4E6F85ABE698EC4CA3EF289=40OSZPR01MB7050=2Ejpnpr?= =?utf-8?q?d01=2Eprod=2Eoutlook=2Ecom=3E?= Date: Mon, 07 Feb 2022 15:16:19 +1100 Message-id: <164420737943.1660.1723177400171021481@noble.neil.brown.name> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Thu, 03 Feb 2022, inoguchi.yuki@fujitsu.com wrote: > Thank you for the review. >=20 > > I would make 2 changes. > > 1/ invalidate when opening a file, rather than when closing. > > This fits better with the understanding of close-to-open consistency > > that we flush writes when closing and verify the cache when opening > > 2/ I would be more careful about determining exactly when the > > invalidation might be needed. >=20 > Yes, I'm willing to make these changes. >=20 > > In nfs_post_op_updatE_inode() there is the code: > >=20 > > if ((fattr->valid & NFS_ATTR_FATTR_CHANGE) !=3D 0 && > > (fattr->valid & NFS_ATTR_FATTR_PRECHANGE) =3D=3D 0) { > > fattr->pre_change_attr =3D inode_peek_iversion_raw(inode); > > fattr->valid |=3D NFS_ATTR_FATTR_PRECHANGE; > > } >=20 > You mean nfs_post_op_update_inode_force_wcc_locked(), not nfs_post_op_updat= e_inode(), right? > This is just make sure --- so I can set the new flag in appropriate place :) Yes, you are correct. >=20 > > I assume that code doesn't end up running when you write to a file for > > which you have a delegation, but I'm not at all certain - we would have > > to check. >=20 > Maybe it is nfs_check_inode_attributes()?=20 > It returns without doing anything if you have a delegation.=20 > It is called from:=20 > nfs_post_op_update_inode_force_wcc_locked() > -> nfs_post_op_update_inode_locked() > -> nfs_refresh_inode_locked() > -> nfs_check_inode_attributes() >=20 > 1476 static int nfs_check_inode_attributes(struct inode *inode, struct nfs_= fattr *fattr) > 1477 { > 1478 struct nfs_inode *nfsi =3D NFS_I(inode); > 1479 loff_t cur_size, new_isize; > 1480 unsigned long invalid =3D 0; > 1481 struct timespec64 ts; > 1482=20 > 1483 if (NFS_PROTO(inode)->have_delegation(inode, FMODE_READ)) > 1484 return 0; >=20 I don't *think* that is relevant. If you set the new flag where I suggested, that code will already have run before it gets to the have_delegation test. nfs4_write_need_cache_consistency_data() seems relevant. If that returns false (which it does when there is a delegation) the WRITE request doesn't even ask for attributes. In that case if nfs_post_op_update_inode_force_wcc_locked() is called, it will find that NFS_ATTR_FATTR_CHANGE is not set, so it won't try to set ->pre_change_attr with a "fake" value, and so won't set the new flag. NeilBrown