From: Stanislav Kinsbursky <skinsbursky@parallels.com>
To: bfields@fieldses.org
Cc: linux-nfs@vger.kernel.org, Trond.Myklebust@netapp.com,
linux-kernel@vger.kernel.org, devel@openvz.org
Subject: [PATCH v2 1/6] NFS: use SUNRPC cache creation and destruction helper for DNS cache
Date: Mon, 04 Feb 2013 14:02:35 +0300 [thread overview]
Message-ID: <20130204110235.11633.59600.stgit@localhost.localdomain> (raw)
In-Reply-To: <20130204105728.11633.53621.stgit@localhost.localdomain>
This cache was the first containerized and doesn't use net-aware cache
creation and destruction helpers.
This is a cleanup patch which just makes code looks clearer and reduce amount
of lines of code.
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
---
fs/nfs/dns_resolve.c | 60 +++++++++++++++++++++-----------------------------
1 files changed, 25 insertions(+), 35 deletions(-)
diff --git a/fs/nfs/dns_resolve.c b/fs/nfs/dns_resolve.c
index ca4b11e..5015447 100644
--- a/fs/nfs/dns_resolve.c
+++ b/fs/nfs/dns_resolve.c
@@ -351,48 +351,39 @@ ssize_t nfs_dns_resolve_name(struct net *net, char *name,
}
EXPORT_SYMBOL_GPL(nfs_dns_resolve_name);
+static struct cache_detail nfs_dns_resolve_template = {
+ .owner = THIS_MODULE,
+ .hash_size = NFS_DNS_HASHTBL_SIZE,
+ .name = "dns_resolve",
+ .cache_put = nfs_dns_ent_put,
+ .cache_upcall = nfs_dns_upcall,
+ .cache_parse = nfs_dns_parse,
+ .cache_show = nfs_dns_show,
+ .match = nfs_dns_match,
+ .init = nfs_dns_ent_init,
+ .update = nfs_dns_ent_update,
+ .alloc = nfs_dns_ent_alloc,
+};
+
+
int nfs_dns_resolver_cache_init(struct net *net)
{
- int err = -ENOMEM;
+ int err;
struct nfs_net *nn = net_generic(net, nfs_net_id);
- struct cache_detail *cd;
- struct cache_head **tbl;
- cd = kzalloc(sizeof(struct cache_detail), GFP_KERNEL);
- if (cd == NULL)
- goto err_cd;
-
- tbl = kzalloc(NFS_DNS_HASHTBL_SIZE * sizeof(struct cache_head *),
- GFP_KERNEL);
- if (tbl == NULL)
- goto err_tbl;
-
- cd->owner = THIS_MODULE,
- cd->hash_size = NFS_DNS_HASHTBL_SIZE,
- cd->hash_table = tbl,
- cd->name = "dns_resolve",
- cd->cache_put = nfs_dns_ent_put,
- cd->cache_upcall = nfs_dns_upcall,
- cd->cache_parse = nfs_dns_parse,
- cd->cache_show = nfs_dns_show,
- cd->match = nfs_dns_match,
- cd->init = nfs_dns_ent_init,
- cd->update = nfs_dns_ent_update,
- cd->alloc = nfs_dns_ent_alloc,
-
- nfs_cache_init(cd);
- err = nfs_cache_register_net(net, cd);
+ nn->nfs_dns_resolve = cache_create_net(&nfs_dns_resolve_template, net);
+ if (IS_ERR(nn->nfs_dns_resolve))
+ return PTR_ERR(nn->nfs_dns_resolve);
+
+ nfs_cache_init(nn->nfs_dns_resolve);
+ err = nfs_cache_register_net(net, nn->nfs_dns_resolve);
if (err)
goto err_reg;
- nn->nfs_dns_resolve = cd;
return 0;
err_reg:
- nfs_cache_destroy(cd);
- kfree(cd->hash_table);
-err_tbl:
- kfree(cd);
-err_cd:
+ nfs_cache_destroy(nn->nfs_dns_resolve);
+ cache_destroy_net(nn->nfs_dns_resolve, net);
return err;
}
@@ -403,8 +394,7 @@ void nfs_dns_resolver_cache_destroy(struct net *net)
nfs_cache_unregister_net(net, cd);
nfs_cache_destroy(cd);
- kfree(cd->hash_table);
- kfree(cd);
+ cache_destroy_net(nn->nfs_dns_resolve, net);
}
static int rpc_pipefs_event(struct notifier_block *nb, unsigned long event,
next prev parent reply other threads:[~2013-02-04 11:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-04 11:02 [PATCH v2 0/6] SUNRPC: rework cache upcall to avoid NFSd root Stanislav Kinsbursky
2013-02-04 11:02 ` Stanislav Kinsbursky [this message]
2013-02-08 21:13 ` [PATCH v2 1/6] NFS: use SUNRPC cache creation and destruction helper for DNS cache J. Bruce Fields
2013-02-04 11:02 ` [PATCH v2 2/6] NFS; simlify and clean cache library Stanislav Kinsbursky
2013-02-08 21:14 ` J. Bruce Fields
2013-02-04 11:02 ` [PATCH v2 3/6] SUNRPC: introduce cache_detail->cache_request callback Stanislav Kinsbursky
2013-02-04 11:02 ` [PATCH v2 4/6] SUNRPC: rework cache upcall logic Stanislav Kinsbursky
2013-02-04 11:02 ` [PATCH v2 5/6] SUNRPC: remove "cache_request" argument in sunrpc_cache_pipe_upcall() function Stanislav Kinsbursky
2013-02-04 11:03 ` [PATCH v2 6/6] SUNRPC: move cache_detail->cache_request callback call to cache_read() Stanislav Kinsbursky
2013-02-04 14:17 ` [PATCH v2 0/6] SUNRPC: rework cache upcall to avoid NFSd root J. Bruce Fields
2013-02-05 5:36 ` Stanislav Kinsbursky
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=20130204110235.11633.59600.stgit@localhost.localdomain \
--to=skinsbursky@parallels.com \
--cc=Trond.Myklebust@netapp.com \
--cc=bfields@fieldses.org \
--cc=devel@openvz.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.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