Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6208981ybv; Tue, 18 Feb 2020 12:04:14 -0800 (PST) X-Google-Smtp-Source: APXvYqx+rzwcu6K1a12wpAOujGZU5bW32lmIJWWeN9vgcFifbGsZFccbA0Jm9UpRJDeNfUlyhuf+ X-Received: by 2002:aca:1012:: with SMTP id 18mr2277055oiq.151.1582056253754; Tue, 18 Feb 2020 12:04:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582056253; cv=none; d=google.com; s=arc-20160816; b=BDDDJ59K6xGai37gghT8izZdzfK0E8AtSwEMQ3cyTJFsw92npY2zVqCKUQ2RC3yodR mOehW5g40tDWlIlOVNHN1y+OJHDh85Dz/hOoXkQkjxZSEiu/2SlRHKnZIf8GF3WzoW5i tciFn5qxVO0Gtk0f7PKwo/iHTY7gvtzF5gWcUYPC6lBcBIuu7xpXZrOnu43bCY3DtFhQ YfNjGwqouqmeEdnZ53nzwo3uMBhZFu/a5qy5k2hepNYgwDfQXl91SCeUcpK+rsZh7wIC 4z+eZNDot8QhmAuS4wSQnhM1wrjXX7ATw52Tk8t/P+QbcsIMI/LZl76eUWsaoXrEt+hF je4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=V3NZhLMK8Y4yp53ZlVBDjI35YSoh3Rzsph5A1caITNg=; b=YJqzJYZzyTpFHOkwFzJp1phC9GUHe349J18n66JvM+V8agqgXrdT7fu1hKF7fkKYD0 0Oe5WELAv/h7fGgMUqi9v1B3s+8ph46MXHrt6rEvkbUGVD4rhGwNV+SG0VawKNX77NKX C82xa0zkRjxEGcVKqlZFEcgBA4xKItPZq2ubjz8bsrAiTgDi1eb65kVEkr47liQk6iit 2hsTeoEbGSdxuyw4pgfdAG27t1a/M482XUyVMqSzwbQ57PMUwiqc8gzJs62F8RTnQyzq NPSmIQdeYQwx0LsUD2/JNeoKyRwVImZ0G5WdTc9MQva/mrcFbJ3iJ9TEWsPdHBVZij0D aVxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IprRHr+Z; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l140si9072082oib.114.2020.02.18.12.04.00; Tue, 18 Feb 2020 12:04:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IprRHr+Z; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729015AbgBRUD6 (ORCPT + 99 others); Tue, 18 Feb 2020 15:03:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:45332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729002AbgBRUDx (ORCPT ); Tue, 18 Feb 2020 15:03:53 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5101D21D56; Tue, 18 Feb 2020 20:03:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582056232; bh=q78o6HQ0yfZG7Zp7kLt0nFtwq1+DanlptBtvtQKA9rQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IprRHr+ZWnnSutS8Jws/fVJW7hdHq4Z3JO7fz9x/d/TS+YZgQTjLHArg6b/HY5QJq y8jUhVnTguw8d/fK86mFyAPeBSXVwgbuc9/jFpehO8GOuZ3gqCoMA2wJEmQl+fesLq 9iSIP12v9UpCDCUVNDKOqD6EzUxa/dZeQFxaO1Xk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , Anna Schumaker , Sasha Levin Subject: [PATCH 5.5 78/80] NFSv4: Add accounting for the number of active delegations held Date: Tue, 18 Feb 2020 20:55:39 +0100 Message-Id: <20200218190439.243798210@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200218190432.043414522@linuxfoundation.org> References: <20200218190432.043414522@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Trond Myklebust [ Upstream commit d2269ea14ebd2a73f291d6b3a7a7d320ec00270c ] In order to better manage our delegation caching, add a counter to track the number of active delegations. Signed-off-by: Trond Myklebust Signed-off-by: Anna Schumaker Signed-off-by: Sasha Levin --- fs/nfs/delegation.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 5f02d922f2173..8e322bacde699 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -25,13 +25,29 @@ #include "internal.h" #include "nfs4trace.h" -static void nfs_free_delegation(struct nfs_delegation *delegation) +static atomic_long_t nfs_active_delegations; + +static void __nfs_free_delegation(struct nfs_delegation *delegation) { put_cred(delegation->cred); delegation->cred = NULL; kfree_rcu(delegation, rcu); } +static void nfs_mark_delegation_revoked(struct nfs_delegation *delegation) +{ + if (!test_and_set_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) { + delegation->stateid.type = NFS4_INVALID_STATEID_TYPE; + atomic_long_dec(&nfs_active_delegations); + } +} + +static void nfs_free_delegation(struct nfs_delegation *delegation) +{ + nfs_mark_delegation_revoked(delegation); + __nfs_free_delegation(delegation); +} + /** * nfs_mark_delegation_referenced - set delegation's REFERENCED flag * @delegation: delegation to process @@ -348,7 +364,8 @@ nfs_update_inplace_delegation(struct nfs_delegation *delegation, delegation->stateid.seqid = update->stateid.seqid; smp_wmb(); delegation->type = update->type; - clear_bit(NFS_DELEGATION_REVOKED, &delegation->flags); + if (test_and_clear_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) + atomic_long_inc(&nfs_active_delegations); } } @@ -428,6 +445,8 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred, rcu_assign_pointer(nfsi->delegation, delegation); delegation = NULL; + atomic_long_inc(&nfs_active_delegations); + trace_nfs4_set_delegation(inode, type); spin_lock(&inode->i_lock); @@ -437,7 +456,7 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred, out: spin_unlock(&clp->cl_lock); if (delegation != NULL) - nfs_free_delegation(delegation); + __nfs_free_delegation(delegation); if (freeme != NULL) { nfs_do_return_delegation(inode, freeme, 0); nfs_free_delegation(freeme); @@ -765,13 +784,6 @@ static void nfs_client_mark_return_unused_delegation_types(struct nfs_client *cl rcu_read_unlock(); } -static void nfs_mark_delegation_revoked(struct nfs_server *server, - struct nfs_delegation *delegation) -{ - set_bit(NFS_DELEGATION_REVOKED, &delegation->flags); - delegation->stateid.type = NFS4_INVALID_STATEID_TYPE; -} - static void nfs_revoke_delegation(struct inode *inode, const nfs4_stateid *stateid) { @@ -799,7 +811,7 @@ static void nfs_revoke_delegation(struct inode *inode, } spin_unlock(&delegation->lock); } - nfs_mark_delegation_revoked(NFS_SERVER(inode), delegation); + nfs_mark_delegation_revoked(delegation); ret = true; out: rcu_read_unlock(); @@ -838,7 +850,7 @@ void nfs_delegation_mark_returned(struct inode *inode, delegation->stateid.seqid = stateid->seqid; } - nfs_mark_delegation_revoked(NFS_SERVER(inode), delegation); + nfs_mark_delegation_revoked(delegation); out_clear_returning: clear_bit(NFS_DELEGATION_RETURNING, &delegation->flags); -- 2.20.1