From: Kinglong Mee <kinglongmee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: "J. Bruce Fields"
<bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>,
Al Viro <viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
Cc: "linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
NeilBrown <neilb-l3A5Bk7waGM@public.gmane.org>,
Trond Myklebust
<trond.myklebust-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org>,
kinglongmee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Subject: [PATCH 5/6 v10] sunrpc: New helper cache_delete_entry for deleting cache_head directly
Date: Mon, 7 Sep 2015 22:05:35 +0800 [thread overview]
Message-ID: <55ED99AF.4030409@gmail.com> (raw)
In-Reply-To: <55ED9899.9010401-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
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 <kinglongmee-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
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 ...
*/
--
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-09-07 14:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-07 14:00 [PATCH 0/6 v10] NFSD: Pin to vfsmount for nfsd exports cache Kinglong Mee
2015-09-07 14:04 ` [PATCH 3/6 v10] path: New helpers path_get_pin/path_put_unpin for path,pin Kinglong Mee
[not found] ` <55ED9899.9010401-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-09-07 14:02 ` [PATCH 1/6 v10] fs-pin: allow pin_remove() to be called other than from->kill() Kinglong Mee
2015-09-07 14:03 ` [PATCH 2/6 v10] fs_pin: Export functions for specific filesystem Kinglong Mee
2015-09-07 14:04 ` [PATCH 4/6 v10] fs: New helper legitimize_mntget() for getting a legitimize mnt Kinglong Mee
2015-09-07 14:05 ` Kinglong Mee [this message]
2015-09-07 14:06 ` [PATCH 6/6 v10] nfsd: Allows user un-mounting filesystem where nfsd exports base on Kinglong Mee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55ED99AF.4030409@gmail.com \
--to=kinglongmee-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org \
--cc=linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=neilb-l3A5Bk7waGM@public.gmane.org \
--cc=trond.myklebust-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org \
--cc=viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).