From patchwork Fri Oct 19 12:20:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1618301 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 8B1E93FC1A for ; Fri, 19 Oct 2012 12:21:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754045Ab2JSMVH (ORCPT ); Fri, 19 Oct 2012 08:21:07 -0400 Received: from mail-ye0-f174.google.com ([209.85.213.174]:51130 "EHLO mail-ye0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756022Ab2JSMVG (ORCPT ); Fri, 19 Oct 2012 08:21:06 -0400 Received: by mail-ye0-f174.google.com with SMTP id m12so20411yen.19 for ; Fri, 19 Oct 2012 05:21:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=/AwIn4FeOBzYFM1Tp5q4emTFilHn7kZbZ9sxyAAQpNs=; b=TlxAWhJJgctDLjDDnQg1InmFPCYTm1Ph6ORdxLkEL58g2uJbYPABHwWTGIkcKVbmec JYppUJrPozGjOVRdLIN5WyJtnO9wT0Pd9RKYeNzbL3yzGmkki/A6KDyIZ1ytLzytALMQ QhigawxY9NoegDyhMmNmoNr5Pz1Y9wLLq14hztMabjYQ9gIjGZ/Cl3RM++LHbM5KY9GV ltUd7Cem1iTLpLNdl3LK7Aa5FD6+1BSclkylX7+MRwvz9NgxXcu6c2j1TLFChHTRGP7u awnMKKcan7imAVnLANPFmMnz9Z8HYT+FYvMsURQynPhXeYOo+S1WrpUxHOQZDEUCXWI2 Pm1Q== Received: by 10.236.131.138 with SMTP id m10mr857032yhi.101.1350649265869; Fri, 19 Oct 2012 05:21:05 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-107-015-110-129.nc.res.rr.com. [107.15.110.129]) by mx.google.com with ESMTPS id o9sm504022anp.14.2012.10.19.05.21.04 (version=SSLv3 cipher=OTHER); Fri, 19 Oct 2012 05:21:05 -0700 (PDT) From: Jeff Layton To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org Subject: [PATCH v2 8/9] cifs: set a timeout on keys in cifs.idmap cache Date: Fri, 19 Oct 2012 08:20:49 -0400 Message-Id: <1350649250-5343-9-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1350649250-5343-1-git-send-email-jlayton@redhat.com> References: <1350649250-5343-1-git-send-email-jlayton@redhat.com> X-Gm-Message-State: ALoCoQm7JpgnCDxKtUZ0/lDPynYrhjKGVFrEA7a5JTMa7P1I8ycQ63wdYbX4dm8/5gOEj4lBs2U9 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org We want to allow unused idmap keys to eventually be purged from the cache. Implement that by simply setting a timeout on the key whenever we use it. We use the same default timeout as the NFS idmap cache, but add a module parm to make it tunable. Signed-off-by: Jeff Layton --- fs/cifs/cifsacl.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index 12d70ee..0c0a594 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include "cifspdu.h" #include "cifsglob.h" @@ -44,6 +45,11 @@ static const struct cifs_sid sid_user = {1, 2 , {0, 0, 0, 0, 0, 5}, {} }; static const struct cred *root_cred; +static unsigned int cifs_idmap_cache_timeout = 600; +module_param(cifs_idmap_cache_timeout, uint, 0644); +MODULE_PARM_DESC(cifs_idmap_cache_timeout, "Number of seconds that ID mappings " + "stay in cache. (default=600)"); + static int cifs_idmap_key_instantiate(struct key *key, struct key_preparsed_payload *prep) { @@ -214,6 +220,7 @@ id_to_sid(unsigned int cid, uint sidtype, struct cifs_sid *ssid) goto out_key_put; } cifs_copy_sid(ssid, (struct cifs_sid *)sidkey->payload.data); + key_set_timeout(sidkey, cifs_idmap_cache_timeout); out_key_put: key_put(sidkey); out_revert_creds: @@ -272,6 +279,7 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid, else fgid = (gid_t)sidkey->payload.value; + key_set_timeout(sidkey, cifs_idmap_cache_timeout); out_key_put: key_put(sidkey); out_revert_creds: