From patchwork Sat Jun 6 14:41:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 6559741 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 1B86EC0020 for ; Sat, 6 Jun 2015 14:42:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4416620621 for ; Sat, 6 Jun 2015 14:42:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 572A420624 for ; Sat, 6 Jun 2015 14:42:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932358AbbFFOl7 (ORCPT ); Sat, 6 Jun 2015 10:41:59 -0400 Received: from mail-qc0-f196.google.com ([209.85.216.196]:36802 "EHLO mail-qc0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932331AbbFFOl6 (ORCPT ); Sat, 6 Jun 2015 10:41:58 -0400 Received: by qcvp6 with SMTP id p6so4420017qcv.3; Sat, 06 Jun 2015 07:41:57 -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=l8TYNQm+BEKS1sbUOp/11z5UogxUcQYbfnF8ck5/O/4=; b=xhZuuKYsn1IGk8nVD4f64qMqOPL3plCNr4upk+Q+tbMpmaNCy89XieB1Tw7IZY8glu 9KNnF64Nqi3c08/Zc2Rut3LKbosS9X8f4sq2p7+SZWaiS6aDIiUokb7WPKxFEC0XOmfw BI8qWaoUVTk4OC5g6pfZPRZUtiQF2seW6ZqufJbr1dqUSo+Y9q8FpV3t7mY2mx9JEpLp i24lSKUVNcy8Vg4LPzfK69+G4fcuXsompXzVUp93FSHtHMdUfqnfBGSKKGG1Sai4FYGq ap5yyk6fjFKmSphYkkHC+YNXT8uDCAH438jrHe6RzOAWTKZXBQNKFlrZ7Vx7ussbppC0 sLrA== X-Received: by 10.140.46.75 with SMTP id j69mr9814877qga.17.1433601717769; Sat, 06 Jun 2015 07:41:57 -0700 (PDT) Received: from [192.168.99.5] ([104.143.41.79]) by mx.google.com with ESMTPSA id 4sm5411840qku.20.2015.06.06.07.41.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 06 Jun 2015 07:41:57 -0700 (PDT) Message-ID: <557306AF.4020609@gmail.com> Date: Sat, 06 Jun 2015 22:41:51 +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" CC: NeilBrown , Trond Myklebust , kinglongmee@gmail.com Subject: [PATCH 4/5 v4] 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. v4, 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);