From patchwork Mon Jul 27 03:10:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 6868061 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 E7EF09F380 for ; Mon, 27 Jul 2015 03:10:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1940E2052C for ; Mon, 27 Jul 2015 03:10:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1BE7320529 for ; Mon, 27 Jul 2015 03:10:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754965AbbG0DKy (ORCPT ); Sun, 26 Jul 2015 23:10:54 -0400 Received: from mail-pd0-f182.google.com ([209.85.192.182]:35774 "EHLO mail-pd0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754071AbbG0DKy (ORCPT ); Sun, 26 Jul 2015 23:10:54 -0400 Received: by pdrg1 with SMTP id g1so43772952pdr.2; Sun, 26 Jul 2015 20:10:53 -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=tP2qtLVs8qaLCekQHH9NII4t5937alJDz8ZKaFbpztI=; b=k5n8z1or/Xc6yfu046hEmfqAX+Vqg99/V/NdCZFfi6Lbu1aOmXjBXVaxqcb7/jdnU2 N1BPvW3xoLGS4MMhPkeaP2YFb4DaqobmywC4z39vrZxJO5TSx48ba6S3iWIQGb4TdSWg kUsPsn9kz+Y38zDi8lSxo5LYwa3WwssJc9xYtD2OC84MhofH0uEaDidzdDeHga/mTOod b2sQNDXmP9COxNesLzAXXozJBHn/iLymLuzkzXTfij212fZ1UiUFxqiIvxx7Wxbntpvq Jzb5OWJzzD9QdrcuONxUeaSRIKMo8Z8EeY4Hb/DuNp02y8v1tUaeqz3bdafcZNpvyp3z rvTw== X-Received: by 10.70.48.34 with SMTP id i2mr62502457pdn.125.1437966653599; Sun, 26 Jul 2015 20:10:53 -0700 (PDT) Received: from [192.168.99.25] ([104.143.41.79]) by smtp.googlemail.com with ESMTPSA id br14sm21755853pdb.47.2015.07.26.20.10.50 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Jul 2015 20:10:53 -0700 (PDT) Message-ID: <55B5A135.9050800@gmail.com> Date: Mon, 27 Jul 2015 11:10:45 +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 CC: "linux-nfs@vger.kernel.org" , linux-fsdevel@vger.kernel.org, NeilBrown , Trond Myklebust , kinglongmee@gmail.com Subject: [PATCH 8/9 v8] sunrpc: New helper cache_delete_entry for deleting cache_head directly References: <55B5A012.1030006@gmail.com> In-Reply-To: <55B5A012.1030006@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, 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 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. v8, same as v6. 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 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..b722aea 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -454,6 +454,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); + + hlist_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 ... */