From patchwork Sun May 24 15:10:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 6471631 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E558FC0020 for ; Sun, 24 May 2015 15:11:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5572920384 for ; Sun, 24 May 2015 15:11:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9828A2039E for ; Sun, 24 May 2015 15:11:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751209AbbEXPKv (ORCPT ); Sun, 24 May 2015 11:10:51 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:35127 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751132AbbEXPKu (ORCPT ); Sun, 24 May 2015 11:10:50 -0400 Received: by pdea3 with SMTP id a3so53087184pde.2; Sun, 24 May 2015 08:10:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=A5mopLL84ULCsTmq587xx0CN+StaL3KUd48DAenKLxg=; b=ASpPjHH13k9B4FUHHK4D6/F4wqoQ0iFWn154M6gR37p78T3MYTZ9qfmvjjNTPq2UOJ Wnx32mPFeyMT14+eNy4Nluypj7OjCGZ0nKQA3hCymO+//q87FlPjlTp641b5fV/f0XDL xI/gp+KSNDbNq889+sy8JG0zSduEe2bCQNfjJya+vuzXh0NlZFeMgP7EIvWXeQ3yGmwx 6GcXQBeUudTvIcpsz5ahMhi000QCeHrMBEqdvWrLpoQZxzdQ0VTM2JIQPv6ANvwnB8KI OGE6CUwRon10P5SI6XdPvW1HM4IhFrasbTVGnSSU6WoY/YOqz4XzOc33i5zTEWmK6Lta wTlw== X-Received: by 10.70.65.10 with SMTP id t10mr5564521pds.151.1432480249838; Sun, 24 May 2015 08:10:49 -0700 (PDT) Received: from [192.168.99.4] ([104.143.41.79]) by mx.google.com with ESMTPSA id da2sm7426128pbb.57.2015.05.24.08.10.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 May 2015 08:10:49 -0700 (PDT) Message-ID: <5561E9F3.8080806@gmail.com> Date: Sun, 24 May 2015 23:10:43 +0800 From: Kinglong Mee User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: "J. Bruce Fields" , Al Viro , linux-fsdevel@vger.kernel.org, "linux-nfs@vger.kernel.org" , NeilBrown CC: Trond Myklebust , Steve Dickson , kinglongmee@gmail.com Subject: [PATCH 4/5 v2] sunrpc: New helper cache_force_expire for cache cleanup References: <5561E7E4.50604@gmail.com> In-Reply-To: <5561E7E4.50604@gmail.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Using expiry_time force cleanup a cache. v2, same as v1. Signed-off-by: Kinglong Mee --- include/linux/sunrpc/cache.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h index 437ddb6..ce75e9c 100644 --- a/include/linux/sunrpc/cache.h +++ b/include/linux/sunrpc/cache.h @@ -210,6 +210,17 @@ extern int cache_check(struct cache_detail *detail, struct cache_head *h, struct cache_req *rqstp); extern void cache_flush(void); extern void cache_purge(struct cache_detail *detail); + +static inline void cache_force_expire(struct cache_detail *detail, struct cache_head *h) +{ + write_lock(&detail->hash_lock); + h->expiry_time = seconds_since_boot() - 1; + detail->nextcheck = seconds_since_boot(); + write_unlock(&detail->hash_lock); + + cache_flush(); +} + #define NEVER (0x7FFFFFFF) extern void __init cache_initialize(void); extern int cache_register_net(struct cache_detail *cd, struct net *net);