From patchwork Wed Jun 17 07:52:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 6622601 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 E3B6BC0020 for ; Wed, 17 Jun 2015 07:52:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1074520835 for ; Wed, 17 Jun 2015 07:52:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0790E20834 for ; Wed, 17 Jun 2015 07:52:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757822AbbFQHwp (ORCPT ); Wed, 17 Jun 2015 03:52:45 -0400 Received: from mail-pd0-f181.google.com ([209.85.192.181]:36732 "EHLO mail-pd0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757818AbbFQHwo (ORCPT ); Wed, 17 Jun 2015 03:52:44 -0400 Received: by pdjm12 with SMTP id m12so32761426pdj.3; Wed, 17 Jun 2015 00:52:44 -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=+gusDA4tou2NZ0S8WjTrCoTVMxzq1luh0DjOyzumiUw=; b=B4+Q/JWcNjj/znXLqpSDlyXOwCFw7SXnJfp5Rkw4WCV7QcUKvbx4mG5RtUZSWddnvi 7lQeczA/kclDvM3C2vSsF/tyiUOW3el6xFlRGidcZFBtg6FsSKsh7088Xi9RUzHfe989 r/o/6ghviroqnjHi0WwCfHLwrSojJHIGAyqfKgxmV/vydIvyzJJ6vEm95SVhm30addlV YMg7cdfMmPOccKbvqmi8yKOhimx/Pagndx6m/9E1+0YnRTNi2Ge8drNrEgpYjo3OtTx9 F/HryoEKBrFANd7IUPhP1QQdJOeSQMKy7QdtS0pUh/CdPyfJac7wTl/Ik3nDCCUP+ftT E24A== X-Received: by 10.66.194.201 with SMTP id hy9mr8448705pac.140.1434527564354; Wed, 17 Jun 2015 00:52:44 -0700 (PDT) Received: from [192.168.99.30] ([104.143.41.79]) by mx.google.com with ESMTPSA id h11sm3712548pdj.27.2015.06.17.00.52.41 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jun 2015 00:52:43 -0700 (PDT) Message-ID: <55812746.8010704@gmail.com> Date: Wed, 17 Jun 2015 15:52:38 +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: Al Viro , "J. Bruce Fields" , "linux-nfs@vger.kernel.org" , linux-fsdevel@vger.kernel.org CC: NeilBrown , Trond Myklebust , kinglongmee@gmail.com Subject: [PATCH 5/6 v5] sunrpc: New helper cache_force_expire for cache cleanup References: <5581266C.9080404@gmail.com> In-Reply-To: <5581266C.9080404@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=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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. v5, same 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);