From patchwork Mon Jan 27 14:58:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11352809 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 16A9D924 for ; Mon, 27 Jan 2020 15:00:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E99EC20720 for ; Mon, 27 Jan 2020 15:00:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ImeWTxbU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726443AbgA0PAc (ORCPT ); Mon, 27 Jan 2020 10:00:32 -0500 Received: from mail-yw1-f68.google.com ([209.85.161.68]:39402 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729267AbgA0PAb (ORCPT ); Mon, 27 Jan 2020 10:00:31 -0500 Received: by mail-yw1-f68.google.com with SMTP id h126so4829413ywc.6 for ; Mon, 27 Jan 2020 07:00:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+53wEaO9sr3iZGt29UZUjIeOI2BiLFw4FnrTlFPrmzw=; b=ImeWTxbUub3NObJ3gOMyvkm7X1mmxnBIfqC6QcmU1nOd0UMvqqOisl4pca/tnvO1Md eL0VDvHaYn9gIcnO5OxsTOSvN+ZhmfmSj3A+c/bcxxAImdKca2+kisJq47b1KLyLvXwt dbrtDzbuKPeiskp31Hx95kVyXxKZ4tH4BsaYbxbwjSwwbjlXGPEKywu/0w8gD7y4yzqn fqnRYs7tr9H8IqE6+L4q4LlwDCRwg/69ZLESSwU+M7ZgHLdFAQMdNma/z+3FKTbZB7Ug 1eEk4skv8knjHLdUl8cBnUWf+ob68l3+N7JIFkNqMH/9oC/GJC21JP3CuVOYbIjQtzNz qtkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+53wEaO9sr3iZGt29UZUjIeOI2BiLFw4FnrTlFPrmzw=; b=o6v7apnidQHyI7IJ2WDEiRvyxsvRWfAq8mGQ7SMeybq9jm9ABJOJWBHZxUrcnaCa9M Fk5ss7WzRH84in88SPgnsfhVwuBWIYBYydK+lV6ZtTVZ1bpPkqTm30FgKmhZew534mga eQ8bIyT7tN3g6ked8rQJy/fXTcZgOdc7xYDCeVUmmEvanYn4Tr1qOYtep4uTY/XfzXpA 7nZTB9ahiGRqmgtU+kD8qLF2VRjABCBCYF1UEyFHGJRZEDXrIcTeUNOGA8Qho14UjMOM nCRJD//GlCgoxtsnpYZColqhhXpsAPoiIg0HmPbgPIZ+SU+BF45jT97Bj4tOnPspVm2L nwGA== X-Gm-Message-State: APjAAAWmZaFel+MhYvVXl7Askw95m9d/NWe0cB/FXgRN00omjX0BUTM+ lED0+3ctRzcBb/PmvJP1C3YUNzQ97g== X-Google-Smtp-Source: APXvYqwTTSreqaZWTJnS+SAtUI3lAl7QzAbA6pMSTAS7bLeWScMYkMsrRsqXguDisZ3ouRHDFGfsvQ== X-Received: by 2002:a0d:d850:: with SMTP id a77mr12581529ywe.464.1580137229830; Mon, 27 Jan 2020 07:00:29 -0800 (PST) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id d186sm6809096ywe.0.2020.01.27.07.00.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2020 07:00:29 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 1/5] NFSv4: nfs_inode_evict_delegation() should set NFS_DELEGATION_RETURNING Date: Mon, 27 Jan 2020 09:58:15 -0500 Message-Id: <20200127145819.350982-2-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200127145819.350982-1-trond.myklebust@hammerspace.com> References: <20200127145819.350982-1-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org In particular, the pnfs return-on-close code will check for that flag, so ensure we set it appropriately. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index fe57b2b5314a..a7e42725c3b1 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -607,6 +607,7 @@ void nfs_inode_evict_delegation(struct inode *inode) delegation = nfs_inode_detach_delegation(inode); if (delegation != NULL) { + set_bit(NFS_DELEGATION_RETURNING, &delegation->flags); set_bit(NFS_DELEGATION_INODE_FREEING, &delegation->flags); nfs_do_return_delegation(inode, delegation, 1); nfs_free_delegation(delegation); From patchwork Mon Jan 27 14:58:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11352813 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8B392188B for ; Mon, 27 Jan 2020 15:00:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6919A20716 for ; Mon, 27 Jan 2020 15:00:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RzVkpexw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729267AbgA0PAc (ORCPT ); Mon, 27 Jan 2020 10:00:32 -0500 Received: from mail-yw1-f67.google.com ([209.85.161.67]:47017 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729268AbgA0PAc (ORCPT ); Mon, 27 Jan 2020 10:00:32 -0500 Received: by mail-yw1-f67.google.com with SMTP id u139so4808469ywf.13 for ; Mon, 27 Jan 2020 07:00:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s+aiyqaA0x50RdWGHHvSb0M06M3Y7o7aVgQoJMBsV4M=; b=RzVkpexwhvFSmVeI17bQ0B5EZSIwQTVRv6B9t1duuEKjaTnKhoRb8gMfS4NftyLKTc zvezK4CQHxV5O2+TsoZrJXoZ06ZIJUfyXtzt6tjrGW8AoMmid8i/KMOoJrbK/O1/EewL LXay+U/O3R88h/qu5eAD69pkKU6hTDQkC+jo7EI+u/KnSqXOwJF9raf+JxF/En9pa3MY rgIKYMEQOWmDFfX1z7KSdmZvDOzZsNDiJBw7slwwHz5WqrQeZCVyRO7skGifBWnzbZHF 7kEQvk9SDJx/Pxp0kKY/sj0SM/AcESYGk3hOV3I1JZuuj8e++lrSTXzOASd3u50SdDTG snsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s+aiyqaA0x50RdWGHHvSb0M06M3Y7o7aVgQoJMBsV4M=; b=JBdduJ7Z9Vbq4btnHVFEVuivVUMQHm11LEhBt+se6PMdlRJ2sCOYU9SDMwsem1VbPt i3VUx8ZSoK3u0FpsaLdKqeSdf8hrq/jh/UCombks7GnCh6G5Pe7BHpzNNmFYk7hMkDjA ViS+haPB8A5z2WF7JEJ7DkYG3cpPcL3NvUNjMUTzJBa3cM2hLfAsodlUCqj94y/XimQE jrXIKw9rIE1CndyG+xZ/n4ZV9/VNx/tI2NDS9/LmNNe3AU/VytvhAns402MbeqjCFtHF X18vGodhg/VyTiiogkeWEeUDKdK2A8Me44bue14u6zXxYVx2J9PrSMshCzCekbTlYEd+ fXMA== X-Gm-Message-State: APjAAAXU77vCfZ0bO8YiilHCcGgLVbjU2cRJHVE2A3D4AC/YSeHNHzRN uOB33y882jJJ2PJr5BwepJeD3BFA4g== X-Google-Smtp-Source: APXvYqyS7XDRqBeZT/lx5BHoghokKsWSbL1oTsUbsRrKphf+rK+ipKzz2viqBCo8Exx1I8UYCdV37A== X-Received: by 2002:a0d:f2c2:: with SMTP id b185mr1430099ywf.380.1580137230755; Mon, 27 Jan 2020 07:00:30 -0800 (PST) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id d186sm6809096ywe.0.2020.01.27.07.00.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2020 07:00:30 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 2/5] NFS: Clear NFS_DELEGATION_RETURN_IF_CLOSED when the delegation is returned Date: Mon, 27 Jan 2020 09:58:16 -0500 Message-Id: <20200127145819.350982-3-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200127145819.350982-2-trond.myklebust@hammerspace.com> References: <20200127145819.350982-1-trond.myklebust@hammerspace.com> <20200127145819.350982-2-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If a delegation is marked as needing to be returned when the file is closed, then don't clear that marking until we're ready to return it. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index a7e42725c3b1..b5b14618b73e 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -479,7 +479,7 @@ static bool nfs_delegation_need_return(struct nfs_delegation *delegation) if (test_and_clear_bit(NFS_DELEGATION_RETURN, &delegation->flags)) ret = true; - if (test_and_clear_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags) && !ret) { + else if (test_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags)) { struct inode *inode; spin_lock(&delegation->lock); @@ -488,6 +488,8 @@ static bool nfs_delegation_need_return(struct nfs_delegation *delegation) ret = true; spin_unlock(&delegation->lock); } + if (ret) + clear_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags); if (test_bit(NFS_DELEGATION_RETURNING, &delegation->flags) || test_bit(NFS_DELEGATION_REVOKED, &delegation->flags)) ret = false; From patchwork Mon Jan 27 14:58:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11352815 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F7601395 for ; Mon, 27 Jan 2020 15:00:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4E8D920720 for ; Mon, 27 Jan 2020 15:00:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="S6txtl/d" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729337AbgA0PAd (ORCPT ); Mon, 27 Jan 2020 10:00:33 -0500 Received: from mail-yb1-f196.google.com ([209.85.219.196]:46137 "EHLO mail-yb1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729268AbgA0PAd (ORCPT ); Mon, 27 Jan 2020 10:00:33 -0500 Received: by mail-yb1-f196.google.com with SMTP id p129so4997679ybc.13 for ; Mon, 27 Jan 2020 07:00:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6B3yGDOcSaTD9sQQXvABaRU4hdv2XxmWkW+LyfP79EU=; b=S6txtl/dEEooNQpTtI9LONvOprXrh9udxqgQLeXxjYKSvZLcP/zdrjQ8ytIo5bjKl5 40iXvJJD+9XHNIzhuolFLhNg7E+ev6AAUHOssXMUz9g506l6rXvP72lWbEJx4ZcTh6D3 Lr1yyllnLBF6ZCe0n1kgMTElt9Cporzr1oO8f5E1wz2HZWVzUwGBoUaZ+HU94+aUH/0s NvCpewmt8+Di86JNdbQMETX2tWy+To3jNFvLXZ+nkdNE9DNZUzupsQr51X9MBN+K6rDT xqT7ZWlhqM51ASB+nuLyCntkj2kWqksdOChprZ617wwgCZwP+HMQiZGpJATjoR6YU7rd e6zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6B3yGDOcSaTD9sQQXvABaRU4hdv2XxmWkW+LyfP79EU=; b=NsmOe1kgtRg+O2Hh2a5vCYdZiwPvlK3RqrXYrn53saF83R55OfzxeFxotSMC81gfj/ fZ9620Jk4Qio1dNJD3mBk1msEaJGI3UAYX97I+j/nssc1Y3sRMZDNKhdH0M0DbIu1CZU z1idICcHeSYzU3Vo9k9FfF9N9XFen9DCXfFtflia9SKRrCoplrxalMdvPj4vfV0HInEV lhIyfHYY/cLQVuTar74MvTtwXb2Ai+uLeVJc89AhsHc0h3Jpbg1yv4zDem0CEnYqL1+k /vCJWnO1s+HUogmO1r+0ThOzXmxhpDEAPj4dPUd2/xkRc422FfSHp/PFv1uQFLmLKmQ+ vgSg== X-Gm-Message-State: APjAAAUKngvMPMj54sBQwvdCBGdHXyf7/o+YeEuEftES+gXxgFWvm4Vp M3pYPT+kr2PbTN+h/KC/Z0O0mtsw+g== X-Google-Smtp-Source: APXvYqwd4RUDxRRSGXxZlwJ1O1wdPlEx8PxMg+hOZgsOrwgDhp2JSmYnNvRIXIdabHkDRqUC2xuM/g== X-Received: by 2002:a25:cf49:: with SMTP id f70mr13693495ybg.11.1580137231727; Mon, 27 Jan 2020 07:00:31 -0800 (PST) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id d186sm6809096ywe.0.2020.01.27.07.00.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2020 07:00:31 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 3/5] NFSv4: Try to return the delegation immediately when marked for return on close Date: Mon, 27 Jan 2020 09:58:17 -0500 Message-Id: <20200127145819.350982-4-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200127145819.350982-3-trond.myklebust@hammerspace.com> References: <20200127145819.350982-1-trond.myklebust@hammerspace.com> <20200127145819.350982-2-trond.myklebust@hammerspace.com> <20200127145819.350982-3-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Add a routine to return the delegation immediately upon close of the file if it was marked for return-on-close. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 33 +++++++++++++++++++++++++++++++++ fs/nfs/delegation.h | 1 + fs/nfs/nfs4state.c | 1 + 3 files changed, 35 insertions(+) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index b5b14618b73e..90e50f32f3e0 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -639,6 +639,39 @@ int nfs4_inode_return_delegation(struct inode *inode) return err; } +/** + * nfs_inode_return_delegation_on_close - asynchronously return a delegation + * @inode: inode to process + * + * This routine is called on file close in order to determine if the + * inode delegation needs to be returned immediately. + */ +void nfs4_inode_return_delegation_on_close(struct inode *inode) +{ + struct nfs_delegation *delegation; + struct nfs_delegation *ret = NULL; + + if (!inode) + return; + rcu_read_lock(); + delegation = nfs4_get_valid_delegation(inode); + if (!delegation) + goto out; + if (test_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags)) { + spin_lock(&delegation->lock); + if (delegation->inode && + list_empty(&NFS_I(inode)->open_files) && + !test_and_set_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) { + clear_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags); + ret = delegation; + } + spin_unlock(&delegation->lock); + } +out: + rcu_read_unlock(); + nfs_end_delegation_return(inode, ret, 0); +} + /** * nfs4_inode_make_writeable * @inode: pointer to inode diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h index 15d3484be028..31b84604d383 100644 --- a/fs/nfs/delegation.h +++ b/fs/nfs/delegation.h @@ -42,6 +42,7 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred, void nfs_inode_reclaim_delegation(struct inode *inode, const struct cred *cred, fmode_t type, const nfs4_stateid *stateid, unsigned long pagemod_limit); int nfs4_inode_return_delegation(struct inode *inode); +void nfs4_inode_return_delegation_on_close(struct inode *inode); int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid); void nfs_inode_evict_delegation(struct inode *inode); diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 34552329233d..958ed4e4cde2 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -766,6 +766,7 @@ void nfs4_put_open_state(struct nfs4_state *state) list_del(&state->open_states); spin_unlock(&inode->i_lock); spin_unlock(&owner->so_lock); + nfs4_inode_return_delegation_on_close(inode); iput(inode); nfs4_free_open_state(state); nfs4_put_state_owner(owner); From patchwork Mon Jan 27 14:58:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11352817 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D4E541580 for ; Mon, 27 Jan 2020 15:00:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B3FD820720 for ; Mon, 27 Jan 2020 15:00:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ORV6J7YZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729268AbgA0PAe (ORCPT ); Mon, 27 Jan 2020 10:00:34 -0500 Received: from mail-yw1-f67.google.com ([209.85.161.67]:40547 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729331AbgA0PAd (ORCPT ); Mon, 27 Jan 2020 10:00:33 -0500 Received: by mail-yw1-f67.google.com with SMTP id i126so4828325ywe.7 for ; Mon, 27 Jan 2020 07:00:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tCP7XDbwqynjsMWfGGEVx8n6y4Sbr/5RTCXLxam2NFw=; b=ORV6J7YZs4kFr2STL8OHs7qRchkdN4A/BOSJcFnFAcVZHTUVcyDk/TXm2o3tzDf8Tr NNky3kUXm+6EUecSl3PVQHj1BVBUnC8Y3MPyQ5/vCkSsRjJf9oVPQ9eYZH0JuaAizOoh 2l+fpGcebznabty90nuOyVtYY0XdVETtqPtmWPQp5vEY38xQgaRfl0ZPowFFpofER3DG 9GjbHbn+LbioVnRPI8eoQdEUnSAC7xnEWL8oB9ay7Vnh1MNmGiezuPlfWhIzTBjMi5A6 tcYnvevPQoFwqN/B2iKcMC0I8OFp9Y0xxsGAXO916UTlNaq1Llm2JxVCNIPuh09mtZ3U XnkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tCP7XDbwqynjsMWfGGEVx8n6y4Sbr/5RTCXLxam2NFw=; b=XdjVUclagiPs5XOnE/UFOW8hSxj+h6mI54nREfJmGIDH/cQy3AYZAa0G6sPadUjLaA TZfXLgiLZLcUx4hrQY6UKNuLbOyrOzT2uTTikSDRWDFw4/TofCsIz++IxQa8xCffNOLr ZbKOF1tM6s9RqaxaRjLmGlOLciEZXOgY5+ofZR5n3GDiWLLTgwfQRr3VKe2YOmqofYO6 sEYHVjWDv/HUcLMYZX3fOAXnriDBqwAAz1LsB3H68IZWJAAZofiDVy0TSyy1P9JU0zSp eWb0TKclyUvDZF7QIauTjylq49VU970T8ItQbqxG+bY2SB1wG6Lfh5kQQ/FX1uvsXhuY 2WlA== X-Gm-Message-State: APjAAAURBksCqdRngFLUpUaA1Z1OT0VSgjDzoB35+lJtlZQwc8wdCIUq 0CPD+V3eJn6NHZDrRUhqInrBBnaq6w== X-Google-Smtp-Source: APXvYqztY34f0SpXByhmZVcRk5UjZ6iPgSQFV1VPCtNsxUBqN0p8LXorGnaWCtP36L7nVfTwGB0jag== X-Received: by 2002:a81:5dc1:: with SMTP id r184mr13157421ywb.433.1580137232840; Mon, 27 Jan 2020 07:00:32 -0800 (PST) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id d186sm6809096ywe.0.2020.01.27.07.00.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2020 07:00:32 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 4/5] NFSv4: Add accounting for the number of active delegations held Date: Mon, 27 Jan 2020 09:58:18 -0500 Message-Id: <20200127145819.350982-5-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200127145819.350982-4-trond.myklebust@hammerspace.com> References: <20200127145819.350982-1-trond.myklebust@hammerspace.com> <20200127145819.350982-2-trond.myklebust@hammerspace.com> <20200127145819.350982-3-trond.myklebust@hammerspace.com> <20200127145819.350982-4-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org In order to better manage our delegation caching, add a counter to track the number of active delegations. Signed-off-by: Trond Myklebust --- 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 90e50f32f3e0..a777b3d0e720 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 @@ -343,7 +359,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); } } @@ -423,6 +440,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); @@ -432,7 +451,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); @@ -796,13 +815,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) { @@ -830,7 +842,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(); @@ -869,7 +881,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); From patchwork Mon Jan 27 14:58:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11352819 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D3EA1924 for ; Mon, 27 Jan 2020 15:00:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B172120716 for ; Mon, 27 Jan 2020 15:00:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XxmVUa4n" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729346AbgA0PAf (ORCPT ); Mon, 27 Jan 2020 10:00:35 -0500 Received: from mail-yw1-f66.google.com ([209.85.161.66]:37718 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729331AbgA0PAe (ORCPT ); Mon, 27 Jan 2020 10:00:34 -0500 Received: by mail-yw1-f66.google.com with SMTP id l5so4842117ywd.4 for ; Mon, 27 Jan 2020 07:00:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6Q2WASrVeOtQanKwbCvAjhkLhlIJFkVlgCXup/Le3SI=; b=XxmVUa4nwhGJxsXDPMOHrYQR+2yURzk/3MbFa/pzKCjN0gqS2EZcVVry6T4xMzPg1W 7VhWZwPnySx9+Odm6VHwgagoCFKFtsh/oyjhrRdjpbyZ0oMaRekmnI8HGkI+RcvZevgC BKG6GWdb6ISz1tYzO6SwwmvZKcnatfNIGA0MGi+TMDaIyaTl/xmLcyQLkYN5B+/pLP3Z tynAGF3SH/mYj1kFiit0LQSXuTXYiSM8ne/1L/N+RU+FySKVIJCesgFbnwLDyXdrfAbs w15DRe1SrlU8lEGB+5B4TV5a0h/Bu9q6BU1502xKsvc5MzvUQHIKf61uoNZlOq1ugRk3 fDsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6Q2WASrVeOtQanKwbCvAjhkLhlIJFkVlgCXup/Le3SI=; b=YtCgeheaJseKLoFVWHgX7U5HL4B44pjMI1Kb+69dojdlnLGlPs5M3D4MHXNHbucDuc ZYrsesZ2Ow0mJggNjoCg88lCALjHsivUhe2T4I4T9we2pggmJRlcd+8tPM0NZuefPyCq bOCKPJK7pCdCHU8RM830nHd+Kf1DxvWSk+FjeQ2aX4CBIcuLKx1kXCOSBEZxn4IcLMD7 9SnWkDgbUxqBslzT+1hm9Z1iMsz7R90RefdzU5oo9m5C9nb8Y9zHp96yOe4wTCapzqDN fwIWKR81nEkXc7TswuPqa+0SwVrTEKaKbixHXEzkxEx6WGKCCqxh/nnwyee7EjecGVce n/yg== X-Gm-Message-State: APjAAAU5sBEi+QzCIFedyNQ5UXKIwwN8sabhA9sYAUHADdzh65vaRrvM QcCsg+NzcBQBjPSe8Umlpg== X-Google-Smtp-Source: APXvYqwW/1WzNPZB77UOO+up1yimSWTM/mzIidW9kBpc5kobc+fzG5dii+GDi/qfZXK3kKy221/bGg== X-Received: by 2002:a0d:f804:: with SMTP id i4mr13019182ywf.508.1580137233769; Mon, 27 Jan 2020 07:00:33 -0800 (PST) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id d186sm6809096ywe.0.2020.01.27.07.00.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2020 07:00:33 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 5/5] NFSv4: Limit the total number of cached delegations Date: Mon, 27 Jan 2020 09:58:19 -0500 Message-Id: <20200127145819.350982-6-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200127145819.350982-5-trond.myklebust@hammerspace.com> References: <20200127145819.350982-1-trond.myklebust@hammerspace.com> <20200127145819.350982-2-trond.myklebust@hammerspace.com> <20200127145819.350982-3-trond.myklebust@hammerspace.com> <20200127145819.350982-4-trond.myklebust@hammerspace.com> <20200127145819.350982-5-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Delegations can be expensive to return, and can cause scalability issues for the server. Let's therefore try to limit the number of inactive delegations we hold. Once the number of delegations is above a certain threshold, start to return them on close. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index a777b3d0e720..4a841071d8a7 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -25,7 +25,10 @@ #include "internal.h" #include "nfs4trace.h" +#define NFS_DEFAULT_DELEGATION_WATERMARK (5000U) + static atomic_long_t nfs_active_delegations; +static unsigned nfs_delegation_watermark = NFS_DEFAULT_DELEGATION_WATERMARK; static void __nfs_free_delegation(struct nfs_delegation *delegation) { @@ -676,7 +679,8 @@ void nfs4_inode_return_delegation_on_close(struct inode *inode) delegation = nfs4_get_valid_delegation(inode); if (!delegation) goto out; - if (test_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags)) { + if (test_bit(NFS_DELEGATION_RETURN_IF_CLOSED, &delegation->flags) || + atomic_long_read(&nfs_active_delegations) >= nfs_delegation_watermark) { spin_lock(&delegation->lock); if (delegation->inode && list_empty(&NFS_I(inode)->open_files) && @@ -1365,3 +1369,5 @@ bool nfs4_delegation_flush_on_close(const struct inode *inode) rcu_read_unlock(); return ret; } + +module_param_named(delegation_watermark, nfs_delegation_watermark, uint, 0644);