aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStanislav Kinsbursky <skinsbursky@parallels.com>2011-11-25 09:12:40 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-01-31 18:20:26 -0500
commit820f9442e711a81749e70c40f149fc54c4ce0ca8 (patch)
treed3e3f9b6e32cc8f19189d9760ce60ee502b81ee8
parent30507f58ce11e7664512059c708347d7a7d75271 (diff)
SUNRPC: split cache creation and PipeFS registration
This precursor patch splits SUNRPC cache creation and PipeFS registartion. It's required for latter split of NFS DNS resolver cache creation per network namespace context and PipeFS registration/unregistration on MOUNT/UMOUNT events. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--fs/nfs/cache_lib.c3
-rw-r--r--include/linux/sunrpc/cache.h2
-rw-r--r--net/sunrpc/cache.c12
3 files changed, 10 insertions, 7 deletions
diff --git a/fs/nfs/cache_lib.c b/fs/nfs/cache_lib.c
index c98b439332fc..d62a8951cb12 100644
--- a/fs/nfs/cache_lib.c
+++ b/fs/nfs/cache_lib.c
@@ -120,6 +120,7 @@ int nfs_cache_register(struct cache_detail *cd)
120 mnt = rpc_get_mount(); 120 mnt = rpc_get_mount();
121 if (IS_ERR(mnt)) 121 if (IS_ERR(mnt))
122 return PTR_ERR(mnt); 122 return PTR_ERR(mnt);
123 sunrpc_init_cache_detail(cd);
123 ret = vfs_path_lookup(mnt->mnt_root, mnt, "/cache", 0, &path); 124 ret = vfs_path_lookup(mnt->mnt_root, mnt, "/cache", 0, &path);
124 if (ret) 125 if (ret)
125 goto err; 126 goto err;
@@ -128,6 +129,7 @@ int nfs_cache_register(struct cache_detail *cd)
128 if (!ret) 129 if (!ret)
129 return ret; 130 return ret;
130err: 131err:
132 sunrpc_destroy_cache_detail(cd);
131 rpc_put_mount(); 133 rpc_put_mount();
132 return ret; 134 return ret;
133} 135}
@@ -135,6 +137,7 @@ err:
135void nfs_cache_unregister(struct cache_detail *cd) 137void nfs_cache_unregister(struct cache_detail *cd)
136{ 138{
137 sunrpc_cache_unregister_pipefs(cd); 139 sunrpc_cache_unregister_pipefs(cd);
140 sunrpc_destroy_cache_detail(cd);
138 rpc_put_mount(); 141 rpc_put_mount();
139} 142}
140 143
diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h
index 57531f8e5956..590a8ab0cec3 100644
--- a/include/linux/sunrpc/cache.h
+++ b/include/linux/sunrpc/cache.h
@@ -202,6 +202,8 @@ extern int cache_register_net(struct cache_detail *cd, struct net *net);
202extern void cache_unregister(struct cache_detail *cd); 202extern void cache_unregister(struct cache_detail *cd);
203extern void cache_unregister_net(struct cache_detail *cd, struct net *net); 203extern void cache_unregister_net(struct cache_detail *cd, struct net *net);
204 204
205extern void sunrpc_init_cache_detail(struct cache_detail *cd);
206extern void sunrpc_destroy_cache_detail(struct cache_detail *cd);
205extern int sunrpc_cache_register_pipefs(struct dentry *parent, const char *, 207extern int sunrpc_cache_register_pipefs(struct dentry *parent, const char *,
206 umode_t, struct cache_detail *); 208 umode_t, struct cache_detail *);
207extern void sunrpc_cache_unregister_pipefs(struct cache_detail *); 209extern void sunrpc_cache_unregister_pipefs(struct cache_detail *);
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 465df9ae1046..fefe06729f9d 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -344,7 +344,7 @@ static int current_index;
344static void do_cache_clean(struct work_struct *work); 344static void do_cache_clean(struct work_struct *work);
345static struct delayed_work cache_cleaner; 345static struct delayed_work cache_cleaner;
346 346
347static void sunrpc_init_cache_detail(struct cache_detail *cd) 347void sunrpc_init_cache_detail(struct cache_detail *cd)
348{ 348{
349 rwlock_init(&cd->hash_lock); 349 rwlock_init(&cd->hash_lock);
350 INIT_LIST_HEAD(&cd->queue); 350 INIT_LIST_HEAD(&cd->queue);
@@ -360,8 +360,9 @@ static void sunrpc_init_cache_detail(struct cache_detail *cd)
360 /* start the cleaning process */ 360 /* start the cleaning process */
361 schedule_delayed_work(&cache_cleaner, 0); 361 schedule_delayed_work(&cache_cleaner, 0);
362} 362}
363EXPORT_SYMBOL_GPL(sunrpc_init_cache_detail);
363 364
364static void sunrpc_destroy_cache_detail(struct cache_detail *cd) 365void sunrpc_destroy_cache_detail(struct cache_detail *cd)
365{ 366{
366 cache_purge(cd); 367 cache_purge(cd);
367 spin_lock(&cache_list_lock); 368 spin_lock(&cache_list_lock);
@@ -384,6 +385,7 @@ static void sunrpc_destroy_cache_detail(struct cache_detail *cd)
384out: 385out:
385 printk(KERN_ERR "nfsd: failed to unregister %s cache\n", cd->name); 386 printk(KERN_ERR "nfsd: failed to unregister %s cache\n", cd->name);
386} 387}
388EXPORT_SYMBOL_GPL(sunrpc_destroy_cache_detail);
387 389
388/* clean cache tries to find something to clean 390/* clean cache tries to find something to clean
389 * and cleans it. 391 * and cleans it.
@@ -1787,17 +1789,14 @@ int sunrpc_cache_register_pipefs(struct dentry *parent,
1787 struct dentry *dir; 1789 struct dentry *dir;
1788 int ret = 0; 1790 int ret = 0;
1789 1791
1790 sunrpc_init_cache_detail(cd);
1791 q.name = name; 1792 q.name = name;
1792 q.len = strlen(name); 1793 q.len = strlen(name);
1793 q.hash = full_name_hash(q.name, q.len); 1794 q.hash = full_name_hash(q.name, q.len);
1794 dir = rpc_create_cache_dir(parent, &q, umode, cd); 1795 dir = rpc_create_cache_dir(parent, &q, umode, cd);
1795 if (!IS_ERR(dir)) 1796 if (!IS_ERR(dir))
1796 cd->u.pipefs.dir = dir; 1797 cd->u.pipefs.dir = dir;
1797 else { 1798 else
1798 sunrpc_destroy_cache_detail(cd);
1799 ret = PTR_ERR(dir); 1799 ret = PTR_ERR(dir);
1800 }
1801 return ret; 1800 return ret;
1802} 1801}
1803EXPORT_SYMBOL_GPL(sunrpc_cache_register_pipefs); 1802EXPORT_SYMBOL_GPL(sunrpc_cache_register_pipefs);
@@ -1806,7 +1805,6 @@ void sunrpc_cache_unregister_pipefs(struct cache_detail *cd)
1806{ 1805{
1807 rpc_remove_cache_dir(cd->u.pipefs.dir); 1806 rpc_remove_cache_dir(cd->u.pipefs.dir);
1808 cd->u.pipefs.dir = NULL; 1807 cd->u.pipefs.dir = NULL;
1809 sunrpc_destroy_cache_detail(cd);
1810} 1808}
1811EXPORT_SYMBOL_GPL(sunrpc_cache_unregister_pipefs); 1809EXPORT_SYMBOL_GPL(sunrpc_cache_unregister_pipefs);
1812 1810