From patchwork Mon Sep 7 14:05:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 7135651 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 8A3A59F1CD for ; Mon, 7 Sep 2015 14:05:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B1D8A20617 for ; Mon, 7 Sep 2015 14:05:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CDA102060B for ; Mon, 7 Sep 2015 14:05:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751499AbbIGOFr (ORCPT ); Mon, 7 Sep 2015 10:05:47 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:33854 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751143AbbIGOFq (ORCPT ); Mon, 7 Sep 2015 10:05:46 -0400 Received: by padhy16 with SMTP id hy16so95965496pad.1; Mon, 07 Sep 2015 07:05:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=5wxmE+sHqAgDYug01g8jLr0Wa7why5tgg2VfKKSZBBo=; b=kOQdbN2GQMkzWCxi8b/LAP2bdxi731EisLeGRot4lnmzLkVJP3vlAgnpd4qNGFfshW TaB1XUmX4iCQOJtlaYMs/+r8PHOggy7lL4BvKC86JB5SgPaaupigCEFqCdXhk8jMJgZB L9YhUYBKUheeprbP7QYCAVlwQQqgHrI1OSg9i2jR2pXjQGpATW8Ptkc3nG0soPpzs9Ux 12nnUBxQDI2CpaDyn2Ah5mtTrP4cesR3MTKBcHyUwTJPSbARa4SVUJgiq5UbDRC2qyhx yshRuZjtLouWLfAvdy/hqAAQRa35a+vxns1P+1kFOMn8tsFWS56+Y6hW2euJcupIQ8J2 LpUQ== X-Received: by 10.66.189.194 with SMTP id gk2mr46638885pac.4.1441634746515; Mon, 07 Sep 2015 07:05:46 -0700 (PDT) Received: from [192.168.99.8] ([104.143.41.79]) by smtp.googlemail.com with ESMTPSA id z1sm11953308pdh.36.2015.09.07.07.05.39 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Sep 2015 07:05:45 -0700 (PDT) Subject: [PATCH 5/6 v10] sunrpc: New helper cache_delete_entry for deleting cache_head directly To: "J. Bruce Fields" , Al Viro References: <55ED9899.9010401@gmail.com> Cc: "linux-nfs@vger.kernel.org" , linux-fsdevel@vger.kernel.org, NeilBrown , Trond Myklebust , kinglongmee@gmail.com From: Kinglong Mee Message-ID: <55ED99AF.4030409@gmail.com> Date: Mon, 7 Sep 2015 22:05:35 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55ED9899.9010401@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 A new helper cache_delete_entry() for delete cache_head from cache_detail directly. It will be used by pin_kill, so make sure the cache_detail is valid before deleting is needed. Because pin_kill is not many times, so the influence of performance is accepted. v9, delete duplicate checking of cache_detail v10, same as v9 Signed-off-by: Kinglong Mee --- include/linux/sunrpc/cache.h | 1 + net/sunrpc/cache.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h index 03d3b4c..2824db5 100644 --- a/include/linux/sunrpc/cache.h +++ b/include/linux/sunrpc/cache.h @@ -210,6 +210,7 @@ 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); +extern void cache_delete_entry(struct cache_detail *cd, struct cache_head *h); #define NEVER (0x7FFFFFFF) extern void __init cache_initialize(void); extern int cache_register_net(struct cache_detail *cd, struct net *net); diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index 4a2340a..430b5fa 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -454,6 +454,26 @@ static int cache_clean(void) return rv; } +void cache_delete_entry(struct cache_detail *detail, struct cache_head *h) +{ + if (!detail || !h) + return; + + write_lock(&detail->hash_lock); + if (hlist_unhashed(&h->cache_list)) { + write_unlock(&detail->hash_lock); + return ; + } + + hlist_del_init(&h->cache_list); + detail->entries--; + set_bit(CACHE_CLEANED, &h->flags); + write_unlock(&detail->hash_lock); + + cache_put(h, detail); +} +EXPORT_SYMBOL_GPL(cache_delete_entry); + /* * We want to regularly clean the cache, so we need to schedule some work ... */