Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp1519781rwl; Thu, 5 Jan 2023 15:04:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXuci2j85rYNa/nBPuh0bEPgW35KQxdX3ApFWKBVhHTaHB3aajbdmlOepdC14Ap9JkBDJV4l X-Received: by 2002:aa7:86ce:0:b0:582:f129:7b93 with SMTP id h14-20020aa786ce000000b00582f1297b93mr7560962pfo.33.1672959855176; Thu, 05 Jan 2023 15:04:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672959855; cv=none; d=google.com; s=arc-20160816; b=m9thXUeWWm6jGbsCHCjOR2Y/WbbrmXtzjgJzD12rFIyllNgCjAVwkjweG1dJkvF0Nx c03W75pwDqLUk1hVM5Q5oGcrVcuoMR5ixoVMwqLRRltsqQtjQvaeMaQNSA04PhIXG88L 9JRtKOWUcQnI6gWV0gjt8bz6+QhEyVoSkX3Bf0RHO/phlJXp2lWsEW+jlD/ea/7sJLzU aHgzfq5ln6D5Wri5ZdpJbqSE2Xyek/WeHH0F0vFcv3sphXuNWv7NWzNBVngt8vVyPyk6 9Lb8mCEhJtrOaviv5ST3Mr7IfC3NXC8JmTEnGFH7RotzG7m00MS3u0gT+3dGk5YZqlAg ZRnA== 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=QCN4ijWoohssoRjOSRDt/nX4FoCQl0w6fE1EpxKy7z0=; b=0KCCehM1vQiSO6bUFqOSmjMtuwF0bx1p1FnVVZsy/5p/VgTLa5FhAnJPAyLK0tr33V NqsBidcFr1eJPb9cmvkrW6dHTKDuiyOqsQ2s+uUKHxuvfKOwUyTTgGBBX5IG14/QlU2E HF8FF+3JBEWn8+xpD2rQ45FQmPg21MhGqF73whwZrn7koTgPwtyyELwolNVYmeIMYroP IX9Nqe0rhYBHyfoqgtIEYJIJ5AmgQgi+UInXytfqVoc4eNwiIIsw9geSIFCofJlVmoX1 7awa+xkSb9MYK6IIWMbh1bbyS+of+dgMfEyh270LQ1esfoGw1qRT4lP97lZT8yoSb6Qh k6hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=1Iu8j49H; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=pQlWQQ+k; 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 o11-20020a056a0015cb00b00572ef957b35si43964065pfu.210.2023.01.05.15.03.50; Thu, 05 Jan 2023 15:04:15 -0800 (PST) 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=1Iu8j49H; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=pQlWQQ+k; 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 S235715AbjAEW4o (ORCPT + 99 others); Thu, 5 Jan 2023 17:56:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236039AbjAEW4e (ORCPT ); Thu, 5 Jan 2023 17:56:34 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08E5F392C2 for ; Thu, 5 Jan 2023 14:56:32 -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-out2.suse.de (Postfix) with ESMTPS id 0C8176771B; Thu, 5 Jan 2023 22:56:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1672959390; 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=QCN4ijWoohssoRjOSRDt/nX4FoCQl0w6fE1EpxKy7z0=; b=1Iu8j49Hf5quSuTujLsxUIqI/6yd69ymYcs3MyxnSa8l63umd4xOnRRkdmEyQAP8bpWRA8 IX3UrZ8bwfBHGDefpxEnbBt0jgzRjpQDj3/CeoBA1IuxVfZZcD3tS5HgZtwtzrLqXQXQ/W IfyqYuT8yfahL+tHNdkxP740eJO87hg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1672959390; 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=QCN4ijWoohssoRjOSRDt/nX4FoCQl0w6fE1EpxKy7z0=; b=pQlWQQ+k0B0j0p81/JeaXEnrdOU3PLq/YXfrR+QBYrL3mhnC83YrzFE5mwrz+HKjCkZQOn 6k3uMiset6Uu7GDw== 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 3DA3C13338; Thu, 5 Jan 2023 22:56:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id r99lOZtVt2PNZwAAMHmgww (envelope-from ); Thu, 05 Jan 2023 22:56:27 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 From: "NeilBrown" To: "Trond Myklebust" Cc: "Trond Myklebust" , "Anna Schumaker" , "Olga Kornievskaia" , "Linux NFS Mailing List" Subject: Re: [PATCH] NFS: Handle missing attributes in OPEN reply In-reply-to: <167279837032.13974.12155714770736077636@noble.neil.brown.name> References: <167279203612.13974.15063003557908413815@noble.neil.brown.name>, <7a98c3e70bae70c44418ce8ac4b84f387b4ff850.camel@kernel.org>, <167279409373.13974.16504090316814568327@noble.neil.brown.name>, <210f08ae5f0ba47c289293981f490fca848dd2ed.camel@kernel.org>, <167279837032.13974.12155714770736077636@noble.neil.brown.name> Date: Fri, 06 Jan 2023 09:56:05 +1100 Message-id: <167295936597.13974.7568769884598065471@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 Wed, 04 Jan 2023, NeilBrown wrote: > On Wed, 04 Jan 2023, Trond Myklebust wrote: > > On Wed, 2023-01-04 at 12:01 +1100, NeilBrown wrote: > > > On Wed, 04 Jan 2023, Trond Myklebust wrote: > > > >=20 > > > >=20 > > > > If the server starts to reply NFS4ERR_STALE to GETATTR requests, > > > > why do > > > > we care about stateid values? Just mark the inode as stale and drop > > > > it > > > > on the floor. > > >=20 > > > We have a valid state from the server - we really shouldn't just > > > ignore > > > it. > > >=20 > > > Maybe it would be OK to mark the inode stale.=C2=A0 I don't know if > > > various > > > retry loops abort properly when the inode is stale. > >=20 > > Yes, they are all supposed to do that. Otherwise we would end up > > looping forever in close(), for instance, since the PUTFH, GETATTR and > > CLOSE can all return NFS4ERR_STALE as well. >=20 > To mark the inode as STALE we still need to find the inode, and that is > the key bit missing in the current code. Once we find the inode, we > could mark it stale, but maybe some other error resulted in the missing > GETATTR... >=20 > It might make sense to put the new code in _nfs4_proc_open() after the > explicit nfs4_proc_getattr() fails. We would need to find the inode > given only the filehandle. Is there any easy way to do that? >=20 > Thanks, > NeilBrown >=20 I couldn't see a consistent pattern to follow for when to mark an inode as stale. Do this, on top of the previous patch, seem reasonable? Thanks, NeilBrown diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index b441b1d14a50..04497cb42154 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -489,6 +489,8 @@ static int nfs4_do_handle_exception(struct nfs_server *se= rver, case -ESTALE: if (inode !=3D NULL && S_ISREG(inode->i_mode)) pnfs_destroy_layout(NFS_I(inode)); + if (inode) + nfs_set_inode_stale(inode); break; case -NFS4ERR_DELEG_REVOKED: case -NFS4ERR_ADMIN_REVOKED: @@ -2713,8 +2715,12 @@ static int _nfs4_proc_open(struct nfs4_opendata *data, return status; } if (!(o_res->f_attr->valid & NFS_ATTR_FATTR)) { + struct inode *inode =3D nfs4_get_inode_by_stateid( + &data->o_res.stateid, + data->owner); nfs4_sequence_free_slot(&o_res->seq_res); - nfs4_proc_getattr(server, &o_res->fh, o_res->f_attr, NULL); + nfs4_proc_getattr(server, &o_res->fh, o_res->f_attr, inode); + iput(inode); } return 0; } @@ -4335,6 +4341,7 @@ int nfs4_proc_getattr(struct nfs_server *server, struct= nfs_fh *fhandle, { struct nfs4_exception exception =3D { .interruptible =3D true, + .inode =3D inode, }; int err; do {