From patchwork Tue Jun 2 01:26:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 6525841 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 280BE9F1CC for ; Tue, 2 Jun 2015 01:26:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5519C2055D for ; Tue, 2 Jun 2015 01:26:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 663172055B for ; Tue, 2 Jun 2015 01:26:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754269AbbFBB0p (ORCPT ); Mon, 1 Jun 2015 21:26:45 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:36202 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753511AbbFBB0o (ORCPT ); Mon, 1 Jun 2015 21:26:44 -0400 Received: by pdjm12 with SMTP id m12so37762778pdj.3; Mon, 01 Jun 2015 18:26:43 -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 :content-type:content-transfer-encoding; bh=ztLzj/qzBbAppdq2J6vwXBzokcrsZGeEuD0+IgbB11Y=; b=wMtn1ImdbRErnr3GorUySgqC/F+shTDGjwQbbVk3ji96Oww7/WKDUaq8uFq2hfc43i Foex9yfpayDRJLkKRr8jZ1U85WEohQYg6BdSP3oAcYE7obUPmnwUDkHLeSQ/IIL0OIbV vQ0pZhvMh9do12fL2kly4oePuoZ102eOzStNVb8I3ATwqhVtg6EnA09PppcG8xQcT1Fj oC9SnoWhqRr/eNObJo3LYJYnU1PbJBdQYhGA5Zo4Ra94TxxV0VqIBtttbPsVjp11c+A3 BjDviC2gRiFIPP8pRLLHb/RmuBU/gbd/BIue1lgTZ0EdWqsLEwokMklyP3dveQiYOZHI CS1Q== X-Received: by 10.66.233.132 with SMTP id tw4mr45068794pac.80.1433208403761; Mon, 01 Jun 2015 18:26:43 -0700 (PDT) Received: from [192.168.99.19] ([104.143.41.79]) by mx.google.com with ESMTPSA id sc1sm15898479pac.36.2015.06.01.18.26.40 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Jun 2015 18:26:43 -0700 (PDT) Message-ID: <556D064D.2020802@gmail.com> Date: Tue, 02 Jun 2015 09:26:37 +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" , linux-fsdevel@vger.kernel.org, "linux-nfs@vger.kernel.org" , Al Viro CC: Trond Myklebust , NeilBrown , kinglongmee@gmail.com Subject: [PATCH 4/5 v3] sunrpc: New helper cache_force_expire for cache cleanup 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. v3: 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);