From patchwork Thu Jun 25 14:34:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 6675671 Return-Path: X-Original-To: patchwork-linux-fsdevel@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 19BA09F380 for ; Thu, 25 Jun 2015 14:34:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4F2B9206C0 for ; Thu, 25 Jun 2015 14:34:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 657BD206D4 for ; Thu, 25 Jun 2015 14:34:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752193AbbFYOeh (ORCPT ); Thu, 25 Jun 2015 10:34:37 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:33022 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751940AbbFYOe3 (ORCPT ); Thu, 25 Jun 2015 10:34:29 -0400 Received: by pdjn11 with SMTP id n11so54750958pdj.0; Thu, 25 Jun 2015 07:34:28 -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=7JpsBflyNpfGIslIs5AXPoa1BIw6GwMuLPVo48sj/JU=; b=jz2Bo/GISRRKaxdwNVxM7ugxdd0aAJO/LayeRYEC4thgh26boDKGxkzCHTnCGIliRM w0xxxjkY1xvadW6dF/6kaUhHchl1NOc52SCRdS0y53TNbcwXRgHP0N04XISWo1L6MOAw 61aFkiX455Dy0K08phtOvYdr30I238QYcCcfUd7UwSGIY4ju4idZ/Tyza2SS7vin/Jyg FHllKHsik8EuCXUM6qNcyryb7QPmj1TNMQbrvgdqFJJ5JcYB4WdUZ+j8LVSDT67e8X/H kq8LlL3Q6LAGhA+HDidQ+9ABQIavhJE11hs5y4gNilQgEy6ifYjiLquzlJehB1MnD7Gm 8rWw== X-Received: by 10.68.69.15 with SMTP id a15mr365715pbu.106.1435242868519; Thu, 25 Jun 2015 07:34:28 -0700 (PDT) Received: from [192.168.99.10] ([104.143.41.79]) by mx.google.com with ESMTPSA id pq3sm28432976pbb.24.2015.06.25.07.34.24 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jun 2015 07:34:27 -0700 (PDT) Message-ID: <558C116A.2080609@gmail.com> Date: Thu, 25 Jun 2015 22:34:18 +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 08/10] sunrpc: New helper cache_delete_entry for deleting cache_head directly References: <558C0D6A.9050104@gmail.com> In-Reply-To: <558C0D6A.9050104@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-8.2 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=unavailable 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. Signed-off-by: Kinglong Mee --- include/linux/sunrpc/cache.h | 1 + net/sunrpc/cache.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h index ecc0ff6..5a4b921 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 ad2155c..8a27483 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -458,6 +458,36 @@ static int cache_clean(void) return rv; } +void cache_delete_entry(struct cache_detail *detail, struct cache_head *h) +{ + struct cache_detail *tmp; + + if (!detail || !h) + return; + + spin_lock(&cache_list_lock); + list_for_each_entry(tmp, &cache_list, others) { + if (tmp == detail) + goto found; + } + spin_unlock(&cache_list_lock); + printk(KERN_WARNING "%s: Deleted cache detail %p\n", __func__, detail); + return ; + +found: + write_lock(&detail->hash_lock); + + list_del_init(&h->cache_list); + detail->entries--; + set_bit(CACHE_CLEANED, &h->flags); + + write_unlock(&detail->hash_lock); + spin_unlock(&cache_list_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 ... */