From patchwork Thu Dec 8 18:17:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Adamson X-Patchwork-Id: 9466939 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 25C42607D3 for ; Thu, 8 Dec 2016 18:19:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19DD1285ED for ; Thu, 8 Dec 2016 18:19:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D6B7285EF; Thu, 8 Dec 2016 18:19:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67908285ED for ; Thu, 8 Dec 2016 18:19:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752804AbcLHSTY (ORCPT ); Thu, 8 Dec 2016 13:19:24 -0500 Received: from mx141.netapp.com ([216.240.21.12]:5887 "EHLO mx141.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752691AbcLHSTX (ORCPT ); Thu, 8 Dec 2016 13:19:23 -0500 X-IronPort-AV: E=Sophos;i="5.33,320,1477983600"; d="scan'208";a="168388933" Received: from vmwexchts02-prd.hq.netapp.com ([10.122.105.23]) by mx141-out.netapp.com with ESMTP; 08 Dec 2016 10:17:09 -0800 Received: from smtp1.corp.netapp.com (10.57.156.124) by VMWEXCHTS02-PRD.hq.netapp.com (10.122.105.23) with Microsoft SMTP Server id 15.0.1210.3; Thu, 8 Dec 2016 10:19:08 -0800 Received: from rhel7-2-ga-2.androsad.fake (andros-new.vpn.netapp.com [10.55.77.11]) by smtp1.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id uB8IJ8a4002759; Thu, 8 Dec 2016 10:19:08 -0800 (PST) From: To: CC: , Andy Adamson Subject: [PATCH 1/2] SVCAUTH update the rsc cache on RPC_GSS_PROC_DESTROY Date: Thu, 8 Dec 2016 13:17:26 -0500 Message-ID: <1481221046-4999-1-git-send-email-andros@netapp.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andy Adamson The current code sets the expiry_time on the local copy of the rsc cache entry - but not on the actual cache entry. Note that currently, the rsc cache entries are not cleaned up even when nfsd is stopped. Update the cache with the new expiry_time of now so that cache_clean will clean up (free) the context to be destroyed. Signed-off-by: Andy Adamson --- net/sunrpc/auth_gss/svcauth_gss.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c index 45662d7..1e720ae 100644 --- a/net/sunrpc/auth_gss/svcauth_gss.c +++ b/net/sunrpc/auth_gss/svcauth_gss.c @@ -1393,6 +1393,38 @@ static void destroy_use_gss_proxy_proc_entry(struct net *net) {} #endif /* CONFIG_PROC_FS */ +/** + * rscp has been looked up in svcauth_gss_accept. Should have a + * refcount = 1. + */ +static int gss_svc_rsc_destroy(struct sunrpc_net *sn, + struct rsc *rscp) +{ + struct rsc new; + int ret = -ENOMEM; + + memset(&new, 0, sizeof(struct rsc)); + if (dup_netobj(&new.handle, &rscp->handle)) + goto out; + new.h.expiry_time = get_seconds(); + set_bit(CACHE_NEGATIVE, &new.h.flags); + + /** + * Balance the cache_put at the end of svcauth_gss_accept.This + * will leave the refcount = 1 so that the cache_clean cache_put + * will call rsc_put. + */ + cache_get(&rscp->h); + + rscp = rsc_update(sn->rsc_cache, &new, rscp); + if (!rscp) + goto out; + ret = 0; +out: + rsc_free(&new); + return ret; +} + /* * Accept an rpcsec packet. * If context establishment, punt to user space @@ -1489,8 +1521,8 @@ static void destroy_use_gss_proxy_proc_entry(struct net *net) {} case RPC_GSS_PROC_DESTROY: if (gss_write_verf(rqstp, rsci->mechctx, gc->gc_seq)) goto auth_err; - rsci->h.expiry_time = get_seconds(); - set_bit(CACHE_NEGATIVE, &rsci->h.flags); + if (gss_svc_rsc_destroy(sn, rsci)) + goto drop; if (resv->iov_len + 4 > PAGE_SIZE) goto drop; svc_putnl(resv, RPC_SUCCESS);