Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp850102rdh; Thu, 26 Oct 2023 18:57:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH9MCyQGVRFh4Y0gQPwpUek4dCU6IiSmd+IIEGeRADs02K+S81V+qrGBrym3C9yuBVpH0Dh X-Received: by 2002:a81:410d:0:b0:586:a684:e7ba with SMTP id o13-20020a81410d000000b00586a684e7bamr1197428ywa.39.1698371826139; Thu, 26 Oct 2023 18:57:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698371826; cv=none; d=google.com; s=arc-20160816; b=r1fZku1T/9CnyPLzpe8+hXDK5OFZyfr1Z5g9GQLE0U+apnK1qbMsIGb3VaxQ6IHH6G 2GJJ2S9dQA2lYkNX6NHd9jfp9/9sJgSpHmWGkc2vm8WhCj602Av2BaDJcsK3kTGwmthD kB8KOSWtO+DOn4qcVnOK9/pI1AEErJ9qy+SW4hpA04YrwGBCWNg6TYkuxlISTUTMhiMV pde+Nb1Q98nIP91iaZnHTajgtoFwLnv1TrUz/X5+Wx1sRAla9wZEFeKBpyXeREHNfbEr UZLt3GyepN/CGvme73UfrWyLMNFI6beqI30mlkhCZrynd5TLRprb2s8n1SzdsISF0DJx g5qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=Tj5pWtTUOLpRHtvu2nA1JS7CGQYcX19Z1mVswlf6CAU=; fh=oGCWKUgN5rqvEqhxhGaFnCKhx0upqxg87fHnuYmJPFg=; b=LBG+DLzZHOhMVkGfJK1Ui7JI37ocg56L8rhNIvOFjY2SN4kt6oYSj8R4I37Md3j6a/ wGdm+PlUHGO+0iOumT8YwegOcLQjdDkHcLJNdODVVeuXOYa8xcwpd4KF7rRO6ScNw9Ex y3yCtdAZkdmA6uBVzSiiU5slRptxFf8fdNI1FiYyyk3AheYJ5M9eWQyTeqtwC5ecc97W jWq87LjKlLqUc2WY4JPbZU4h0YcjzegN/tVgfUUAbLZncCH99FPFsVFGOa0L0kUWZX7M LWTx6bYF0/yx3vojQVWE9iU3BR+U/aJg7zXPkUa8TcyaIBL+21rmjAswy0JC/lKG/gi/ ZtuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=j6CTIpDY; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id o62-20020a0dfe41000000b0058d34ea58a3si977835ywf.380.2023.10.26.18.57.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 18:57:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=j6CTIpDY; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 703578053CCE; Thu, 26 Oct 2023 18:57:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345128AbjJ0B47 (ORCPT + 99 others); Thu, 26 Oct 2023 21:56:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345140AbjJ0B46 (ORCPT ); Thu, 26 Oct 2023 21:56:58 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 694301BC for ; Thu, 26 Oct 2023 18:56:56 -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 168BE1FDB3; Fri, 27 Oct 2023 01:56:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1698371815; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Tj5pWtTUOLpRHtvu2nA1JS7CGQYcX19Z1mVswlf6CAU=; b=j6CTIpDY7lDe5eo7cq8LEyrYE8Ikk9O2jN5C8CFz/WHgHBh8tT/abvg6DdtQFAz+Qeqzxi 4WxA6NB1zuFXVlJf4t1oG+22fSDrLhKw2UAdNhQcsh+YPMI1CMr3vkuZ4CZDHREz/MM8zu KqYUbZaDXNJiXqhAxEPT+vyUYGKZ5U0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1698371815; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Tj5pWtTUOLpRHtvu2nA1JS7CGQYcX19Z1mVswlf6CAU=; b=5W6o5sRxZRZEb1MR3lt/aczjEGAQ7TRUlTHY6ywmDGEAwYq5oCUuQdWgnzSa2sU0oGVftA n1CmBDeeUaZw4MCQ== 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 0B069133F5; Fri, 27 Oct 2023 01:56:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ARAZLeQYO2UqCgAAMHmgww (envelope-from ); Fri, 27 Oct 2023 01:56:52 +0000 From: NeilBrown To: Chuck Lever , Jeff Layton Cc: linux-nfs@vger.kernel.org, Olga Kornievskaia , Dai Ngo , Tom Talpey Subject: [PATCH 5/6] nfsd: allow open state ids to be revoked and then freed Date: Fri, 27 Oct 2023 12:45:33 +1100 Message-ID: <20231027015613.26247-6-neilb@suse.de> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231027015613.26247-1-neilb@suse.de> References: <20231027015613.26247-1-neilb@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 26 Oct 2023 18:57:03 -0700 (PDT) Revoking state through 'unlock_filesystem' now revokes any open states found. When the stateids are then freed by the client, the revoked stateids will be cleaned up correctly. Possibly the related lock states should be revoked too, but a subsequent patch will do that for all lock state on the superblock. Signed-off-by: NeilBrown --- fs/nfsd/nfs4state.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 4e912c377d63..ee93ab5d1e0f 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -1708,7 +1708,7 @@ void nfsd4_revoke_states(struct net *net, struct super_block *sb) unsigned int idhashval; unsigned short sc_types; - sc_types = NFS4_LOCK_STID; + sc_types = NFS4_OPEN_STID | NFS4_LOCK_STID; spin_lock(&nn->client_lock); for (idhashval = 0; idhashval < CLIENT_HASH_MASK; idhashval++) { @@ -1723,6 +1723,18 @@ void nfsd4_revoke_states(struct net *net, struct super_block *sb) spin_unlock(&nn->client_lock); switch (stid->sc_type) { + case NFS4_OPEN_STID: + stp = openlockstateid(stid); + mutex_lock_nested(&stp->st_mutex, + OPEN_STATEID_MUTEX); + if (stid->sc_type == NFS4_OPEN_STID) { + release_all_access(stp); + stid->sc_type = + NFS4_ADMIN_REVOKED_STID; + atomic_inc(&clp->cl_admin_revoked); + } + mutex_unlock(&stp->st_mutex); + break; case NFS4_LOCK_STID: stp = openlockstateid(stid); mutex_lock_nested(&stp->st_mutex, @@ -4681,10 +4693,18 @@ nfsd4_find_existing_open(struct nfs4_file *fp, struct nfsd4_open *open) static void nfsd_drop_revoked_stid(struct nfs4_stid *s) { struct nfs4_client *cl = s->sc_client; + LIST_HEAD(reaplist); struct nfs4_ol_stateid *stp; bool unhashed; switch (s->sc_type) { + case NFS4_ADMIN_REVOKED_STID: + stp = openlockstateid(s); + if (unhash_open_stateid(stp, &reaplist)) + put_ol_stateid_locked(stp, &reaplist); + spin_unlock(&cl->cl_lock); + free_ol_stateid_reaplist(&reaplist); + break; case NFS4_ADMIN_REVOKED_LOCK_STID: stp = openlockstateid(s); unhashed = unhash_lock_stateid(stp); -- 2.42.0