Return-Path: 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 Message-ID: <5561E9F3.8080806@gmail.com> Date: Sun, 24 May 2015 23:10:43 +0800 From: Kinglong Mee 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> Content-Type: text/plain; charset=utf-8 Sender: linux-nfs-owner@vger.kernel.org List-ID: 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); -- 2.4.1