aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2009-08-10 17:45:58 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2009-08-10 17:45:58 -0400
commitf884dcaead5f17bf586ac5fe6a3ad07b5203616a (patch)
tree2406444df167f1d67b38733b544f2e2a96c778c7 /net/sunrpc
parent976a6f921cad26651d25e73826c05c7a023f5fa4 (diff)
parent8854e82d9accc80f43c0bc3ff06b5979ac858185 (diff)
Merge branch 'sunrpc_cache-for-2.6.32' into nfs-for-2.6.32
Diffstat (limited to 'net/sunrpc')
-rw-r--r--net/sunrpc/auth_gss/auth_gss.c12
-rw-r--r--net/sunrpc/auth_gss/svcauth_gss.c7
-rw-r--r--net/sunrpc/cache.c550
-rw-r--r--net/sunrpc/clnt.c60
-rw-r--r--net/sunrpc/rpc_pipe.c678
-rw-r--r--net/sunrpc/svcauth_unix.c14
6 files changed, 858 insertions, 463 deletions
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index 66d458fc6920..fc6a43ccd950 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -89,8 +89,8 @@ static struct rpc_wait_queue pipe_version_rpc_waitqueue;
89static DECLARE_WAIT_QUEUE_HEAD(pipe_version_waitqueue); 89static DECLARE_WAIT_QUEUE_HEAD(pipe_version_waitqueue);
90 90
91static void gss_free_ctx(struct gss_cl_ctx *); 91static void gss_free_ctx(struct gss_cl_ctx *);
92static struct rpc_pipe_ops gss_upcall_ops_v0; 92static const struct rpc_pipe_ops gss_upcall_ops_v0;
93static struct rpc_pipe_ops gss_upcall_ops_v1; 93static const struct rpc_pipe_ops gss_upcall_ops_v1;
94 94
95static inline struct gss_cl_ctx * 95static inline struct gss_cl_ctx *
96gss_get_ctx(struct gss_cl_ctx *ctx) 96gss_get_ctx(struct gss_cl_ctx *ctx)
@@ -777,7 +777,7 @@ gss_create(struct rpc_clnt *clnt, rpc_authflavor_t flavor)
777 * that we supported only the old pipe. So we instead create 777 * that we supported only the old pipe. So we instead create
778 * the new pipe first. 778 * the new pipe first.
779 */ 779 */
780 gss_auth->dentry[1] = rpc_mkpipe(clnt->cl_dentry, 780 gss_auth->dentry[1] = rpc_mkpipe(clnt->cl_path.dentry,
781 "gssd", 781 "gssd",
782 clnt, &gss_upcall_ops_v1, 782 clnt, &gss_upcall_ops_v1,
783 RPC_PIPE_WAIT_FOR_OPEN); 783 RPC_PIPE_WAIT_FOR_OPEN);
@@ -786,7 +786,7 @@ gss_create(struct rpc_clnt *clnt, rpc_authflavor_t flavor)
786 goto err_put_mech; 786 goto err_put_mech;
787 } 787 }
788 788
789 gss_auth->dentry[0] = rpc_mkpipe(clnt->cl_dentry, 789 gss_auth->dentry[0] = rpc_mkpipe(clnt->cl_path.dentry,
790 gss_auth->mech->gm_name, 790 gss_auth->mech->gm_name,
791 clnt, &gss_upcall_ops_v0, 791 clnt, &gss_upcall_ops_v0,
792 RPC_PIPE_WAIT_FOR_OPEN); 792 RPC_PIPE_WAIT_FOR_OPEN);
@@ -1507,7 +1507,7 @@ static const struct rpc_credops gss_nullops = {
1507 .crunwrap_resp = gss_unwrap_resp, 1507 .crunwrap_resp = gss_unwrap_resp,
1508}; 1508};
1509 1509
1510static struct rpc_pipe_ops gss_upcall_ops_v0 = { 1510static const struct rpc_pipe_ops gss_upcall_ops_v0 = {
1511 .upcall = gss_pipe_upcall, 1511 .upcall = gss_pipe_upcall,
1512 .downcall = gss_pipe_downcall, 1512 .downcall = gss_pipe_downcall,
1513 .destroy_msg = gss_pipe_destroy_msg, 1513 .destroy_msg = gss_pipe_destroy_msg,
@@ -1515,7 +1515,7 @@ static struct rpc_pipe_ops gss_upcall_ops_v0 = {
1515 .release_pipe = gss_pipe_release, 1515 .release_pipe = gss_pipe_release,
1516}; 1516};
1517 1517
1518static struct rpc_pipe_ops gss_upcall_ops_v1 = { 1518static const struct rpc_pipe_ops gss_upcall_ops_v1 = {
1519 .upcall = gss_pipe_upcall, 1519 .upcall = gss_pipe_upcall,
1520 .downcall = gss_pipe_downcall, 1520 .downcall = gss_pipe_downcall,
1521 .destroy_msg = gss_pipe_destroy_msg, 1521 .destroy_msg = gss_pipe_destroy_msg,
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
index 2278a50c6444..2e6a148d277c 100644
--- a/net/sunrpc/auth_gss/svcauth_gss.c
+++ b/net/sunrpc/auth_gss/svcauth_gss.c
@@ -181,6 +181,11 @@ static void rsi_request(struct cache_detail *cd,
181 (*bpp)[-1] = '\n'; 181 (*bpp)[-1] = '\n';
182} 182}
183 183
184static int rsi_upcall(struct cache_detail *cd, struct cache_head *h)
185{
186 return sunrpc_cache_pipe_upcall(cd, h, rsi_request);
187}
188
184 189
185static int rsi_parse(struct cache_detail *cd, 190static int rsi_parse(struct cache_detail *cd,
186 char *mesg, int mlen) 191 char *mesg, int mlen)
@@ -270,7 +275,7 @@ static struct cache_detail rsi_cache = {
270 .hash_table = rsi_table, 275 .hash_table = rsi_table,
271 .name = "auth.rpcsec.init", 276 .name = "auth.rpcsec.init",
272 .cache_put = rsi_put, 277 .cache_put = rsi_put,
273 .cache_request = rsi_request, 278 .cache_upcall = rsi_upcall,
274 .cache_parse = rsi_parse, 279 .cache_parse = rsi_parse,
275 .match = rsi_match, 280 .match = rsi_match,
276 .init = rsi_init, 281 .init = rsi_init,
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index ff0c23053d2f..db7720e453c3 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -27,10 +27,12 @@
27#include <linux/net.h> 27#include <linux/net.h>
28#include <linux/workqueue.h> 28#include <linux/workqueue.h>
29#include <linux/mutex.h> 29#include <linux/mutex.h>
30#include <linux/pagemap.h>
30#include <asm/ioctls.h> 31#include <asm/ioctls.h>
31#include <linux/sunrpc/types.h> 32#include <linux/sunrpc/types.h>
32#include <linux/sunrpc/cache.h> 33#include <linux/sunrpc/cache.h>
33#include <linux/sunrpc/stats.h> 34#include <linux/sunrpc/stats.h>
35#include <linux/sunrpc/rpc_pipe_fs.h>
34 36
35#define RPCDBG_FACILITY RPCDBG_CACHE 37#define RPCDBG_FACILITY RPCDBG_CACHE
36 38
@@ -175,7 +177,13 @@ struct cache_head *sunrpc_cache_update(struct cache_detail *detail,
175} 177}
176EXPORT_SYMBOL_GPL(sunrpc_cache_update); 178EXPORT_SYMBOL_GPL(sunrpc_cache_update);
177 179
178static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h); 180static int cache_make_upcall(struct cache_detail *cd, struct cache_head *h)
181{
182 if (!cd->cache_upcall)
183 return -EINVAL;
184 return cd->cache_upcall(cd, h);
185}
186
179/* 187/*
180 * This is the generic cache management routine for all 188 * This is the generic cache management routine for all
181 * the authentication caches. 189 * the authentication caches.
@@ -284,76 +292,11 @@ static DEFINE_SPINLOCK(cache_list_lock);
284static struct cache_detail *current_detail; 292static struct cache_detail *current_detail;
285static int current_index; 293static int current_index;
286 294
287static const struct file_operations cache_file_operations;
288static const struct file_operations content_file_operations;
289static const struct file_operations cache_flush_operations;
290
291static void do_cache_clean(struct work_struct *work); 295static void do_cache_clean(struct work_struct *work);
292static DECLARE_DELAYED_WORK(cache_cleaner, do_cache_clean); 296static DECLARE_DELAYED_WORK(cache_cleaner, do_cache_clean);
293 297
294static void remove_cache_proc_entries(struct cache_detail *cd) 298static void sunrpc_init_cache_detail(struct cache_detail *cd)
295{
296 if (cd->proc_ent == NULL)
297 return;
298 if (cd->flush_ent)
299 remove_proc_entry("flush", cd->proc_ent);
300 if (cd->channel_ent)
301 remove_proc_entry("channel", cd->proc_ent);
302 if (cd->content_ent)
303 remove_proc_entry("content", cd->proc_ent);
304 cd->proc_ent = NULL;
305 remove_proc_entry(cd->name, proc_net_rpc);
306}
307
308#ifdef CONFIG_PROC_FS
309static int create_cache_proc_entries(struct cache_detail *cd)
310{
311 struct proc_dir_entry *p;
312
313 cd->proc_ent = proc_mkdir(cd->name, proc_net_rpc);
314 if (cd->proc_ent == NULL)
315 goto out_nomem;
316 cd->channel_ent = cd->content_ent = NULL;
317
318 p = proc_create_data("flush", S_IFREG|S_IRUSR|S_IWUSR,
319 cd->proc_ent, &cache_flush_operations, cd);
320 cd->flush_ent = p;
321 if (p == NULL)
322 goto out_nomem;
323
324 if (cd->cache_request || cd->cache_parse) {
325 p = proc_create_data("channel", S_IFREG|S_IRUSR|S_IWUSR,
326 cd->proc_ent, &cache_file_operations, cd);
327 cd->channel_ent = p;
328 if (p == NULL)
329 goto out_nomem;
330 }
331 if (cd->cache_show) {
332 p = proc_create_data("content", S_IFREG|S_IRUSR|S_IWUSR,
333 cd->proc_ent, &content_file_operations, cd);
334 cd->content_ent = p;
335 if (p == NULL)
336 goto out_nomem;
337 }
338 return 0;
339out_nomem:
340 remove_cache_proc_entries(cd);
341 return -ENOMEM;
342}
343#else /* CONFIG_PROC_FS */
344static int create_cache_proc_entries(struct cache_detail *cd)
345{
346 return 0;
347}
348#endif
349
350int cache_register(struct cache_detail *cd)
351{ 299{
352 int ret;
353
354 ret = create_cache_proc_entries(cd);
355 if (ret)
356 return ret;
357 rwlock_init(&cd->hash_lock); 300 rwlock_init(&cd->hash_lock);
358 INIT_LIST_HEAD(&cd->queue); 301 INIT_LIST_HEAD(&cd->queue);
359 spin_lock(&cache_list_lock); 302 spin_lock(&cache_list_lock);
@@ -367,11 +310,9 @@ int cache_register(struct cache_detail *cd)
367 310
368 /* start the cleaning process */ 311 /* start the cleaning process */
369 schedule_delayed_work(&cache_cleaner, 0); 312 schedule_delayed_work(&cache_cleaner, 0);
370 return 0;
371} 313}
372EXPORT_SYMBOL_GPL(cache_register);
373 314
374void cache_unregister(struct cache_detail *cd) 315static void sunrpc_destroy_cache_detail(struct cache_detail *cd)
375{ 316{
376 cache_purge(cd); 317 cache_purge(cd);
377 spin_lock(&cache_list_lock); 318 spin_lock(&cache_list_lock);
@@ -386,7 +327,6 @@ void cache_unregister(struct cache_detail *cd)
386 list_del_init(&cd->others); 327 list_del_init(&cd->others);
387 write_unlock(&cd->hash_lock); 328 write_unlock(&cd->hash_lock);
388 spin_unlock(&cache_list_lock); 329 spin_unlock(&cache_list_lock);
389 remove_cache_proc_entries(cd);
390 if (list_empty(&cache_list)) { 330 if (list_empty(&cache_list)) {
391 /* module must be being unloaded so its safe to kill the worker */ 331 /* module must be being unloaded so its safe to kill the worker */
392 cancel_delayed_work_sync(&cache_cleaner); 332 cancel_delayed_work_sync(&cache_cleaner);
@@ -395,7 +335,6 @@ void cache_unregister(struct cache_detail *cd)
395out: 335out:
396 printk(KERN_ERR "nfsd: failed to unregister %s cache\n", cd->name); 336 printk(KERN_ERR "nfsd: failed to unregister %s cache\n", cd->name);
397} 337}
398EXPORT_SYMBOL_GPL(cache_unregister);
399 338
400/* clean cache tries to find something to clean 339/* clean cache tries to find something to clean
401 * and cleans it. 340 * and cleans it.
@@ -687,18 +626,18 @@ struct cache_reader {
687 int offset; /* if non-0, we have a refcnt on next request */ 626 int offset; /* if non-0, we have a refcnt on next request */
688}; 627};
689 628
690static ssize_t 629static ssize_t cache_read(struct file *filp, char __user *buf, size_t count,
691cache_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos) 630 loff_t *ppos, struct cache_detail *cd)
692{ 631{
693 struct cache_reader *rp = filp->private_data; 632 struct cache_reader *rp = filp->private_data;
694 struct cache_request *rq; 633 struct cache_request *rq;
695 struct cache_detail *cd = PDE(filp->f_path.dentry->d_inode)->data; 634 struct inode *inode = filp->f_path.dentry->d_inode;
696 int err; 635 int err;
697 636
698 if (count == 0) 637 if (count == 0)
699 return 0; 638 return 0;
700 639
701 mutex_lock(&queue_io_mutex); /* protect against multiple concurrent 640 mutex_lock(&inode->i_mutex); /* protect against multiple concurrent
702 * readers on this file */ 641 * readers on this file */
703 again: 642 again:
704 spin_lock(&queue_lock); 643 spin_lock(&queue_lock);
@@ -711,7 +650,7 @@ cache_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos)
711 } 650 }
712 if (rp->q.list.next == &cd->queue) { 651 if (rp->q.list.next == &cd->queue) {
713 spin_unlock(&queue_lock); 652 spin_unlock(&queue_lock);
714 mutex_unlock(&queue_io_mutex); 653 mutex_unlock(&inode->i_mutex);
715 BUG_ON(rp->offset); 654 BUG_ON(rp->offset);
716 return 0; 655 return 0;
717 } 656 }
@@ -758,49 +697,90 @@ cache_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos)
758 } 697 }
759 if (err == -EAGAIN) 698 if (err == -EAGAIN)
760 goto again; 699 goto again;
761 mutex_unlock(&queue_io_mutex); 700 mutex_unlock(&inode->i_mutex);
762 return err ? err : count; 701 return err ? err : count;
763} 702}
764 703
765static char write_buf[8192]; /* protected by queue_io_mutex */ 704static ssize_t cache_do_downcall(char *kaddr, const char __user *buf,
705 size_t count, struct cache_detail *cd)
706{
707 ssize_t ret;
708
709 if (copy_from_user(kaddr, buf, count))
710 return -EFAULT;
711 kaddr[count] = '\0';
712 ret = cd->cache_parse(cd, kaddr, count);
713 if (!ret)
714 ret = count;
715 return ret;
716}
766 717
767static ssize_t 718static ssize_t cache_slow_downcall(const char __user *buf,
768cache_write(struct file *filp, const char __user *buf, size_t count, 719 size_t count, struct cache_detail *cd)
769 loff_t *ppos)
770{ 720{
771 int err; 721 static char write_buf[8192]; /* protected by queue_io_mutex */
772 struct cache_detail *cd = PDE(filp->f_path.dentry->d_inode)->data; 722 ssize_t ret = -EINVAL;
773 723
774 if (count == 0)
775 return 0;
776 if (count >= sizeof(write_buf)) 724 if (count >= sizeof(write_buf))
777 return -EINVAL; 725 goto out;
778
779 mutex_lock(&queue_io_mutex); 726 mutex_lock(&queue_io_mutex);
727 ret = cache_do_downcall(write_buf, buf, count, cd);
728 mutex_unlock(&queue_io_mutex);
729out:
730 return ret;
731}
780 732
781 if (copy_from_user(write_buf, buf, count)) { 733static ssize_t cache_downcall(struct address_space *mapping,
782 mutex_unlock(&queue_io_mutex); 734 const char __user *buf,
783 return -EFAULT; 735 size_t count, struct cache_detail *cd)
784 } 736{
785 write_buf[count] = '\0'; 737 struct page *page;
786 if (cd->cache_parse) 738 char *kaddr;
787 err = cd->cache_parse(cd, write_buf, count); 739 ssize_t ret = -ENOMEM;
788 else 740
789 err = -EINVAL; 741 if (count >= PAGE_CACHE_SIZE)
742 goto out_slow;
743
744 page = find_or_create_page(mapping, 0, GFP_KERNEL);
745 if (!page)
746 goto out_slow;
747
748 kaddr = kmap(page);
749 ret = cache_do_downcall(kaddr, buf, count, cd);
750 kunmap(page);
751 unlock_page(page);
752 page_cache_release(page);
753 return ret;
754out_slow:
755 return cache_slow_downcall(buf, count, cd);
756}
790 757
791 mutex_unlock(&queue_io_mutex); 758static ssize_t cache_write(struct file *filp, const char __user *buf,
792 return err ? err : count; 759 size_t count, loff_t *ppos,
760 struct cache_detail *cd)
761{
762 struct address_space *mapping = filp->f_mapping;
763 struct inode *inode = filp->f_path.dentry->d_inode;
764 ssize_t ret = -EINVAL;
765
766 if (!cd->cache_parse)
767 goto out;
768
769 mutex_lock(&inode->i_mutex);
770 ret = cache_downcall(mapping, buf, count, cd);
771 mutex_unlock(&inode->i_mutex);
772out:
773 return ret;
793} 774}
794 775
795static DECLARE_WAIT_QUEUE_HEAD(queue_wait); 776static DECLARE_WAIT_QUEUE_HEAD(queue_wait);
796 777
797static unsigned int 778static unsigned int cache_poll(struct file *filp, poll_table *wait,
798cache_poll(struct file *filp, poll_table *wait) 779 struct cache_detail *cd)
799{ 780{
800 unsigned int mask; 781 unsigned int mask;
801 struct cache_reader *rp = filp->private_data; 782 struct cache_reader *rp = filp->private_data;
802 struct cache_queue *cq; 783 struct cache_queue *cq;
803 struct cache_detail *cd = PDE(filp->f_path.dentry->d_inode)->data;
804 784
805 poll_wait(filp, &queue_wait, wait); 785 poll_wait(filp, &queue_wait, wait);
806 786
@@ -822,14 +802,13 @@ cache_poll(struct file *filp, poll_table *wait)
822 return mask; 802 return mask;
823} 803}
824 804
825static int 805static int cache_ioctl(struct inode *ino, struct file *filp,
826cache_ioctl(struct inode *ino, struct file *filp, 806 unsigned int cmd, unsigned long arg,
827 unsigned int cmd, unsigned long arg) 807 struct cache_detail *cd)
828{ 808{
829 int len = 0; 809 int len = 0;
830 struct cache_reader *rp = filp->private_data; 810 struct cache_reader *rp = filp->private_data;
831 struct cache_queue *cq; 811 struct cache_queue *cq;
832 struct cache_detail *cd = PDE(ino)->data;
833 812
834 if (cmd != FIONREAD || !rp) 813 if (cmd != FIONREAD || !rp)
835 return -EINVAL; 814 return -EINVAL;
@@ -852,15 +831,13 @@ cache_ioctl(struct inode *ino, struct file *filp,
852 return put_user(len, (int __user *)arg); 831 return put_user(len, (int __user *)arg);
853} 832}
854 833
855static int 834static int cache_open(struct inode *inode, struct file *filp,
856cache_open(struct inode *inode, struct file *filp) 835 struct cache_detail *cd)
857{ 836{
858 struct cache_reader *rp = NULL; 837 struct cache_reader *rp = NULL;
859 838
860 nonseekable_open(inode, filp); 839 nonseekable_open(inode, filp);
861 if (filp->f_mode & FMODE_READ) { 840 if (filp->f_mode & FMODE_READ) {
862 struct cache_detail *cd = PDE(inode)->data;
863
864 rp = kmalloc(sizeof(*rp), GFP_KERNEL); 841 rp = kmalloc(sizeof(*rp), GFP_KERNEL);
865 if (!rp) 842 if (!rp)
866 return -ENOMEM; 843 return -ENOMEM;
@@ -875,11 +852,10 @@ cache_open(struct inode *inode, struct file *filp)
875 return 0; 852 return 0;
876} 853}
877 854
878static int 855static int cache_release(struct inode *inode, struct file *filp,
879cache_release(struct inode *inode, struct file *filp) 856 struct cache_detail *cd)
880{ 857{
881 struct cache_reader *rp = filp->private_data; 858 struct cache_reader *rp = filp->private_data;
882 struct cache_detail *cd = PDE(inode)->data;
883 859
884 if (rp) { 860 if (rp) {
885 spin_lock(&queue_lock); 861 spin_lock(&queue_lock);
@@ -908,18 +884,6 @@ cache_release(struct inode *inode, struct file *filp)
908 884
909 885
910 886
911static const struct file_operations cache_file_operations = {
912 .owner = THIS_MODULE,
913 .llseek = no_llseek,
914 .read = cache_read,
915 .write = cache_write,
916 .poll = cache_poll,
917 .ioctl = cache_ioctl, /* for FIONREAD */
918 .open = cache_open,
919 .release = cache_release,
920};
921
922
923static void queue_loose(struct cache_detail *detail, struct cache_head *ch) 887static void queue_loose(struct cache_detail *detail, struct cache_head *ch)
924{ 888{
925 struct cache_queue *cq; 889 struct cache_queue *cq;
@@ -1020,15 +984,21 @@ static void warn_no_listener(struct cache_detail *detail)
1020 if (detail->last_warn != detail->last_close) { 984 if (detail->last_warn != detail->last_close) {
1021 detail->last_warn = detail->last_close; 985 detail->last_warn = detail->last_close;
1022 if (detail->warn_no_listener) 986 if (detail->warn_no_listener)
1023 detail->warn_no_listener(detail); 987 detail->warn_no_listener(detail, detail->last_close != 0);
1024 } 988 }
1025} 989}
1026 990
1027/* 991/*
1028 * register an upcall request to user-space. 992 * register an upcall request to user-space and queue it up for read() by the
993 * upcall daemon.
994 *
1029 * Each request is at most one page long. 995 * Each request is at most one page long.
1030 */ 996 */
1031static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h) 997int sunrpc_cache_pipe_upcall(struct cache_detail *detail, struct cache_head *h,
998 void (*cache_request)(struct cache_detail *,
999 struct cache_head *,
1000 char **,
1001 int *))
1032{ 1002{
1033 1003
1034 char *buf; 1004 char *buf;
@@ -1036,9 +1006,6 @@ static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h)
1036 char *bp; 1006 char *bp;
1037 int len; 1007 int len;
1038 1008
1039 if (detail->cache_request == NULL)
1040 return -EINVAL;
1041
1042 if (atomic_read(&detail->readers) == 0 && 1009 if (atomic_read(&detail->readers) == 0 &&
1043 detail->last_close < get_seconds() - 30) { 1010 detail->last_close < get_seconds() - 30) {
1044 warn_no_listener(detail); 1011 warn_no_listener(detail);
@@ -1057,7 +1024,7 @@ static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h)
1057 1024
1058 bp = buf; len = PAGE_SIZE; 1025 bp = buf; len = PAGE_SIZE;
1059 1026
1060 detail->cache_request(detail, h, &bp, &len); 1027 cache_request(detail, h, &bp, &len);
1061 1028
1062 if (len < 0) { 1029 if (len < 0) {
1063 kfree(buf); 1030 kfree(buf);
@@ -1075,6 +1042,7 @@ static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h)
1075 wake_up(&queue_wait); 1042 wake_up(&queue_wait);
1076 return 0; 1043 return 0;
1077} 1044}
1045EXPORT_SYMBOL_GPL(sunrpc_cache_pipe_upcall);
1078 1046
1079/* 1047/*
1080 * parse a message from user-space and pass it 1048 * parse a message from user-space and pass it
@@ -1242,10 +1210,10 @@ static const struct seq_operations cache_content_op = {
1242 .show = c_show, 1210 .show = c_show,
1243}; 1211};
1244 1212
1245static int content_open(struct inode *inode, struct file *file) 1213static int content_open(struct inode *inode, struct file *file,
1214 struct cache_detail *cd)
1246{ 1215{
1247 struct handle *han; 1216 struct handle *han;
1248 struct cache_detail *cd = PDE(inode)->data;
1249 1217
1250 han = __seq_open_private(file, &cache_content_op, sizeof(*han)); 1218 han = __seq_open_private(file, &cache_content_op, sizeof(*han));
1251 if (han == NULL) 1219 if (han == NULL)
@@ -1255,17 +1223,10 @@ static int content_open(struct inode *inode, struct file *file)
1255 return 0; 1223 return 0;
1256} 1224}
1257 1225
1258static const struct file_operations content_file_operations = {
1259 .open = content_open,
1260 .read = seq_read,
1261 .llseek = seq_lseek,
1262 .release = seq_release_private,
1263};
1264
1265static ssize_t read_flush(struct file *file, char __user *buf, 1226static ssize_t read_flush(struct file *file, char __user *buf,
1266 size_t count, loff_t *ppos) 1227 size_t count, loff_t *ppos,
1228 struct cache_detail *cd)
1267{ 1229{
1268 struct cache_detail *cd = PDE(file->f_path.dentry->d_inode)->data;
1269 char tbuf[20]; 1230 char tbuf[20];
1270 unsigned long p = *ppos; 1231 unsigned long p = *ppos;
1271 size_t len; 1232 size_t len;
@@ -1283,10 +1244,10 @@ static ssize_t read_flush(struct file *file, char __user *buf,
1283 return len; 1244 return len;
1284} 1245}
1285 1246
1286static ssize_t write_flush(struct file * file, const char __user * buf, 1247static ssize_t write_flush(struct file *file, const char __user *buf,
1287 size_t count, loff_t *ppos) 1248 size_t count, loff_t *ppos,
1249 struct cache_detail *cd)
1288{ 1250{
1289 struct cache_detail *cd = PDE(file->f_path.dentry->d_inode)->data;
1290 char tbuf[20]; 1251 char tbuf[20];
1291 char *ep; 1252 char *ep;
1292 long flushtime; 1253 long flushtime;
@@ -1307,8 +1268,299 @@ static ssize_t write_flush(struct file * file, const char __user * buf,
1307 return count; 1268 return count;
1308} 1269}
1309 1270
1310static const struct file_operations cache_flush_operations = { 1271static ssize_t cache_read_procfs(struct file *filp, char __user *buf,
1272 size_t count, loff_t *ppos)
1273{
1274 struct cache_detail *cd = PDE(filp->f_path.dentry->d_inode)->data;
1275
1276 return cache_read(filp, buf, count, ppos, cd);
1277}
1278
1279static ssize_t cache_write_procfs(struct file *filp, const char __user *buf,
1280 size_t count, loff_t *ppos)
1281{
1282 struct cache_detail *cd = PDE(filp->f_path.dentry->d_inode)->data;
1283
1284 return cache_write(filp, buf, count, ppos, cd);
1285}
1286
1287static unsigned int cache_poll_procfs(struct file *filp, poll_table *wait)
1288{
1289 struct cache_detail *cd = PDE(filp->f_path.dentry->d_inode)->data;
1290
1291 return cache_poll(filp, wait, cd);
1292}
1293
1294static int cache_ioctl_procfs(struct inode *inode, struct file *filp,
1295 unsigned int cmd, unsigned long arg)
1296{
1297 struct cache_detail *cd = PDE(inode)->data;
1298
1299 return cache_ioctl(inode, filp, cmd, arg, cd);
1300}
1301
1302static int cache_open_procfs(struct inode *inode, struct file *filp)
1303{
1304 struct cache_detail *cd = PDE(inode)->data;
1305
1306 return cache_open(inode, filp, cd);
1307}
1308
1309static int cache_release_procfs(struct inode *inode, struct file *filp)
1310{
1311 struct cache_detail *cd = PDE(inode)->data;
1312
1313 return cache_release(inode, filp, cd);
1314}
1315
1316static const struct file_operations cache_file_operations_procfs = {
1317 .owner = THIS_MODULE,
1318 .llseek = no_llseek,
1319 .read = cache_read_procfs,
1320 .write = cache_write_procfs,
1321 .poll = cache_poll_procfs,
1322 .ioctl = cache_ioctl_procfs, /* for FIONREAD */
1323 .open = cache_open_procfs,
1324 .release = cache_release_procfs,
1325};
1326
1327static int content_open_procfs(struct inode *inode, struct file *filp)
1328{
1329 struct cache_detail *cd = PDE(inode)->data;
1330
1331 return content_open(inode, filp, cd);
1332}
1333
1334static const struct file_operations content_file_operations_procfs = {
1335 .open = content_open_procfs,
1336 .read = seq_read,
1337 .llseek = seq_lseek,
1338 .release = seq_release_private,
1339};
1340
1341static ssize_t read_flush_procfs(struct file *filp, char __user *buf,
1342 size_t count, loff_t *ppos)
1343{
1344 struct cache_detail *cd = PDE(filp->f_path.dentry->d_inode)->data;
1345
1346 return read_flush(filp, buf, count, ppos, cd);
1347}
1348
1349static ssize_t write_flush_procfs(struct file *filp,
1350 const char __user *buf,
1351 size_t count, loff_t *ppos)
1352{
1353 struct cache_detail *cd = PDE(filp->f_path.dentry->d_inode)->data;
1354
1355 return write_flush(filp, buf, count, ppos, cd);
1356}
1357
1358static const struct file_operations cache_flush_operations_procfs = {
1359 .open = nonseekable_open,
1360 .read = read_flush_procfs,
1361 .write = write_flush_procfs,
1362};
1363
1364static void remove_cache_proc_entries(struct cache_detail *cd)
1365{
1366 if (cd->u.procfs.proc_ent == NULL)
1367 return;
1368 if (cd->u.procfs.flush_ent)
1369 remove_proc_entry("flush", cd->u.procfs.proc_ent);
1370 if (cd->u.procfs.channel_ent)
1371 remove_proc_entry("channel", cd->u.procfs.proc_ent);
1372 if (cd->u.procfs.content_ent)
1373 remove_proc_entry("content", cd->u.procfs.proc_ent);
1374 cd->u.procfs.proc_ent = NULL;
1375 remove_proc_entry(cd->name, proc_net_rpc);
1376}
1377
1378#ifdef CONFIG_PROC_FS
1379static int create_cache_proc_entries(struct cache_detail *cd)
1380{
1381 struct proc_dir_entry *p;
1382
1383 cd->u.procfs.proc_ent = proc_mkdir(cd->name, proc_net_rpc);
1384 if (cd->u.procfs.proc_ent == NULL)
1385 goto out_nomem;
1386 cd->u.procfs.channel_ent = NULL;
1387 cd->u.procfs.content_ent = NULL;
1388
1389 p = proc_create_data("flush", S_IFREG|S_IRUSR|S_IWUSR,
1390 cd->u.procfs.proc_ent,
1391 &cache_flush_operations_procfs, cd);
1392 cd->u.procfs.flush_ent = p;
1393 if (p == NULL)
1394 goto out_nomem;
1395
1396 if (cd->cache_upcall || cd->cache_parse) {
1397 p = proc_create_data("channel", S_IFREG|S_IRUSR|S_IWUSR,
1398 cd->u.procfs.proc_ent,
1399 &cache_file_operations_procfs, cd);
1400 cd->u.procfs.channel_ent = p;
1401 if (p == NULL)
1402 goto out_nomem;
1403 }
1404 if (cd->cache_show) {
1405 p = proc_create_data("content", S_IFREG|S_IRUSR|S_IWUSR,
1406 cd->u.procfs.proc_ent,
1407 &content_file_operations_procfs, cd);
1408 cd->u.procfs.content_ent = p;
1409 if (p == NULL)
1410 goto out_nomem;
1411 }
1412 return 0;
1413out_nomem:
1414 remove_cache_proc_entries(cd);
1415 return -ENOMEM;
1416}
1417#else /* CONFIG_PROC_FS */
1418static int create_cache_proc_entries(struct cache_detail *cd)
1419{
1420 return 0;
1421}
1422#endif
1423
1424int cache_register(struct cache_detail *cd)
1425{
1426 int ret;
1427
1428 sunrpc_init_cache_detail(cd);
1429 ret = create_cache_proc_entries(cd);
1430 if (ret)
1431 sunrpc_destroy_cache_detail(cd);
1432 return ret;
1433}
1434EXPORT_SYMBOL_GPL(cache_register);
1435
1436void cache_unregister(struct cache_detail *cd)
1437{
1438 remove_cache_proc_entries(cd);
1439 sunrpc_destroy_cache_detail(cd);
1440}
1441EXPORT_SYMBOL_GPL(cache_unregister);
1442
1443static ssize_t cache_read_pipefs(struct file *filp, char __user *buf,
1444 size_t count, loff_t *ppos)
1445{
1446 struct cache_detail *cd = RPC_I(filp->f_path.dentry->d_inode)->private;
1447
1448 return cache_read(filp, buf, count, ppos, cd);
1449}
1450
1451static ssize_t cache_write_pipefs(struct file *filp, const char __user *buf,
1452 size_t count, loff_t *ppos)
1453{
1454 struct cache_detail *cd = RPC_I(filp->f_path.dentry->d_inode)->private;
1455
1456 return cache_write(filp, buf, count, ppos, cd);
1457}
1458
1459static unsigned int cache_poll_pipefs(struct file *filp, poll_table *wait)
1460{
1461 struct cache_detail *cd = RPC_I(filp->f_path.dentry->d_inode)->private;
1462
1463 return cache_poll(filp, wait, cd);
1464}
1465
1466static int cache_ioctl_pipefs(struct inode *inode, struct file *filp,
1467 unsigned int cmd, unsigned long arg)
1468{
1469 struct cache_detail *cd = RPC_I(inode)->private;
1470
1471 return cache_ioctl(inode, filp, cmd, arg, cd);
1472}
1473
1474static int cache_open_pipefs(struct inode *inode, struct file *filp)
1475{
1476 struct cache_detail *cd = RPC_I(inode)->private;
1477
1478 return cache_open(inode, filp, cd);
1479}
1480
1481static int cache_release_pipefs(struct inode *inode, struct file *filp)
1482{
1483 struct cache_detail *cd = RPC_I(inode)->private;
1484
1485 return cache_release(inode, filp, cd);
1486}
1487
1488const struct file_operations cache_file_operations_pipefs = {
1489 .owner = THIS_MODULE,
1490 .llseek = no_llseek,
1491 .read = cache_read_pipefs,
1492 .write = cache_write_pipefs,
1493 .poll = cache_poll_pipefs,
1494 .ioctl = cache_ioctl_pipefs, /* for FIONREAD */
1495 .open = cache_open_pipefs,
1496 .release = cache_release_pipefs,
1497};
1498
1499static int content_open_pipefs(struct inode *inode, struct file *filp)
1500{
1501 struct cache_detail *cd = RPC_I(inode)->private;
1502
1503 return content_open(inode, filp, cd);
1504}
1505
1506const struct file_operations content_file_operations_pipefs = {
1507 .open = content_open_pipefs,
1508 .read = seq_read,
1509 .llseek = seq_lseek,
1510 .release = seq_release_private,
1511};
1512
1513static ssize_t read_flush_pipefs(struct file *filp, char __user *buf,
1514 size_t count, loff_t *ppos)
1515{
1516 struct cache_detail *cd = RPC_I(filp->f_path.dentry->d_inode)->private;
1517
1518 return read_flush(filp, buf, count, ppos, cd);
1519}
1520
1521static ssize_t write_flush_pipefs(struct file *filp,
1522 const char __user *buf,
1523 size_t count, loff_t *ppos)
1524{
1525 struct cache_detail *cd = RPC_I(filp->f_path.dentry->d_inode)->private;
1526
1527 return write_flush(filp, buf, count, ppos, cd);
1528}
1529
1530const struct file_operations cache_flush_operations_pipefs = {
1311 .open = nonseekable_open, 1531 .open = nonseekable_open,
1312 .read = read_flush, 1532 .read = read_flush_pipefs,
1313 .write = write_flush, 1533 .write = write_flush_pipefs,
1314}; 1534};
1535
1536int sunrpc_cache_register_pipefs(struct dentry *parent,
1537 const char *name, mode_t umode,
1538 struct cache_detail *cd)
1539{
1540 struct qstr q;
1541 struct dentry *dir;
1542 int ret = 0;
1543
1544 sunrpc_init_cache_detail(cd);
1545 q.name = name;
1546 q.len = strlen(name);
1547 q.hash = full_name_hash(q.name, q.len);
1548 dir = rpc_create_cache_dir(parent, &q, umode, cd);
1549 if (!IS_ERR(dir))
1550 cd->u.pipefs.dir = dir;
1551 else {
1552 sunrpc_destroy_cache_detail(cd);
1553 ret = PTR_ERR(dir);
1554 }
1555 return ret;
1556}
1557EXPORT_SYMBOL_GPL(sunrpc_cache_register_pipefs);
1558
1559void sunrpc_cache_unregister_pipefs(struct cache_detail *cd)
1560{
1561 rpc_remove_cache_dir(cd->u.pipefs.dir);
1562 cd->u.pipefs.dir = NULL;
1563 sunrpc_destroy_cache_detail(cd);
1564}
1565EXPORT_SYMBOL_GPL(sunrpc_cache_unregister_pipefs);
1566
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index ebfcf9b89909..c1e467e1b07d 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -27,6 +27,8 @@
27#include <linux/types.h> 27#include <linux/types.h>
28#include <linux/kallsyms.h> 28#include <linux/kallsyms.h>
29#include <linux/mm.h> 29#include <linux/mm.h>
30#include <linux/namei.h>
31#include <linux/mount.h>
30#include <linux/slab.h> 32#include <linux/slab.h>
31#include <linux/utsname.h> 33#include <linux/utsname.h>
32#include <linux/workqueue.h> 34#include <linux/workqueue.h>
@@ -97,33 +99,49 @@ static int
97rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name) 99rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name)
98{ 100{
99 static uint32_t clntid; 101 static uint32_t clntid;
102 struct nameidata nd;
103 struct path path;
104 char name[15];
105 struct qstr q = {
106 .name = name,
107 };
100 int error; 108 int error;
101 109
102 clnt->cl_vfsmnt = ERR_PTR(-ENOENT); 110 clnt->cl_path.mnt = ERR_PTR(-ENOENT);
103 clnt->cl_dentry = ERR_PTR(-ENOENT); 111 clnt->cl_path.dentry = ERR_PTR(-ENOENT);
104 if (dir_name == NULL) 112 if (dir_name == NULL)
105 return 0; 113 return 0;
106 114
107 clnt->cl_vfsmnt = rpc_get_mount(); 115 path.mnt = rpc_get_mount();
108 if (IS_ERR(clnt->cl_vfsmnt)) 116 if (IS_ERR(path.mnt))
109 return PTR_ERR(clnt->cl_vfsmnt); 117 return PTR_ERR(path.mnt);
118 error = vfs_path_lookup(path.mnt->mnt_root, path.mnt, dir_name, 0, &nd);
119 if (error)
120 goto err;
110 121
111 for (;;) { 122 for (;;) {
112 snprintf(clnt->cl_pathname, sizeof(clnt->cl_pathname), 123 q.len = snprintf(name, sizeof(name), "clnt%x", (unsigned int)clntid++);
113 "%s/clnt%x", dir_name, 124 name[sizeof(name) - 1] = '\0';
114 (unsigned int)clntid++); 125 q.hash = full_name_hash(q.name, q.len);
115 clnt->cl_pathname[sizeof(clnt->cl_pathname) - 1] = '\0'; 126 path.dentry = rpc_create_client_dir(nd.path.dentry, &q, clnt);
116 clnt->cl_dentry = rpc_mkdir(clnt->cl_pathname, clnt); 127 if (!IS_ERR(path.dentry))
117 if (!IS_ERR(clnt->cl_dentry)) 128 break;
118 return 0; 129 error = PTR_ERR(path.dentry);
119 error = PTR_ERR(clnt->cl_dentry);
120 if (error != -EEXIST) { 130 if (error != -EEXIST) {
121 printk(KERN_INFO "RPC: Couldn't create pipefs entry %s, error %d\n", 131 printk(KERN_INFO "RPC: Couldn't create pipefs entry"
122 clnt->cl_pathname, error); 132 " %s/%s, error %d\n",
123 rpc_put_mount(); 133 dir_name, name, error);
124 return error; 134 goto err_path_put;
125 } 135 }
126 } 136 }
137 path_put(&nd.path);
138 clnt->cl_path = path;
139 return 0;
140err_path_put:
141 path_put(&nd.path);
142err:
143 rpc_put_mount();
144 return error;
127} 145}
128 146
129static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, struct rpc_xprt *xprt) 147static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, struct rpc_xprt *xprt)
@@ -231,8 +249,8 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru
231 return clnt; 249 return clnt;
232 250
233out_no_auth: 251out_no_auth:
234 if (!IS_ERR(clnt->cl_dentry)) { 252 if (!IS_ERR(clnt->cl_path.dentry)) {
235 rpc_rmdir(clnt->cl_dentry); 253 rpc_remove_client_dir(clnt->cl_path.dentry);
236 rpc_put_mount(); 254 rpc_put_mount();
237 } 255 }
238out_no_path: 256out_no_path:
@@ -423,8 +441,8 @@ rpc_free_client(struct kref *kref)
423 441
424 dprintk("RPC: destroying %s client for %s\n", 442 dprintk("RPC: destroying %s client for %s\n",
425 clnt->cl_protname, clnt->cl_server); 443 clnt->cl_protname, clnt->cl_server);
426 if (!IS_ERR(clnt->cl_dentry)) { 444 if (!IS_ERR(clnt->cl_path.dentry)) {
427 rpc_rmdir(clnt->cl_dentry); 445 rpc_remove_client_dir(clnt->cl_path.dentry);
428 rpc_put_mount(); 446 rpc_put_mount();
429 } 447 }
430 if (clnt->cl_parent != clnt) { 448 if (clnt->cl_parent != clnt) {
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 9ced0628d69c..8dd81535e08f 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -26,6 +26,7 @@
26#include <linux/sunrpc/clnt.h> 26#include <linux/sunrpc/clnt.h>
27#include <linux/workqueue.h> 27#include <linux/workqueue.h>
28#include <linux/sunrpc/rpc_pipe_fs.h> 28#include <linux/sunrpc/rpc_pipe_fs.h>
29#include <linux/sunrpc/cache.h>
29 30
30static struct vfsmount *rpc_mount __read_mostly; 31static struct vfsmount *rpc_mount __read_mostly;
31static int rpc_mount_count; 32static int rpc_mount_count;
@@ -125,7 +126,7 @@ static void
125rpc_close_pipes(struct inode *inode) 126rpc_close_pipes(struct inode *inode)
126{ 127{
127 struct rpc_inode *rpci = RPC_I(inode); 128 struct rpc_inode *rpci = RPC_I(inode);
128 struct rpc_pipe_ops *ops; 129 const struct rpc_pipe_ops *ops;
129 int need_release; 130 int need_release;
130 131
131 mutex_lock(&inode->i_mutex); 132 mutex_lock(&inode->i_mutex);
@@ -398,66 +399,12 @@ static const struct file_operations rpc_info_operations = {
398 399
399 400
400/* 401/*
401 * We have a single directory with 1 node in it.
402 */
403enum {
404 RPCAUTH_Root = 1,
405 RPCAUTH_lockd,
406 RPCAUTH_mount,
407 RPCAUTH_nfs,
408 RPCAUTH_portmap,
409 RPCAUTH_statd,
410 RPCAUTH_nfsd4_cb,
411 RPCAUTH_RootEOF
412};
413
414/*
415 * Description of fs contents. 402 * Description of fs contents.
416 */ 403 */
417struct rpc_filelist { 404struct rpc_filelist {
418 char *name; 405 const char *name;
419 const struct file_operations *i_fop; 406 const struct file_operations *i_fop;
420 int mode; 407 umode_t mode;
421};
422
423static struct rpc_filelist files[] = {
424 [RPCAUTH_lockd] = {
425 .name = "lockd",
426 .mode = S_IFDIR | S_IRUGO | S_IXUGO,
427 },
428 [RPCAUTH_mount] = {
429 .name = "mount",
430 .mode = S_IFDIR | S_IRUGO | S_IXUGO,
431 },
432 [RPCAUTH_nfs] = {
433 .name = "nfs",
434 .mode = S_IFDIR | S_IRUGO | S_IXUGO,
435 },
436 [RPCAUTH_portmap] = {
437 .name = "portmap",
438 .mode = S_IFDIR | S_IRUGO | S_IXUGO,
439 },
440 [RPCAUTH_statd] = {
441 .name = "statd",
442 .mode = S_IFDIR | S_IRUGO | S_IXUGO,
443 },
444 [RPCAUTH_nfsd4_cb] = {
445 .name = "nfsd4_cb",
446 .mode = S_IFDIR | S_IRUGO | S_IXUGO,
447 },
448};
449
450enum {
451 RPCAUTH_info = 2,
452 RPCAUTH_EOF
453};
454
455static struct rpc_filelist authfiles[] = {
456 [RPCAUTH_info] = {
457 .name = "info",
458 .i_fop = &rpc_info_operations,
459 .mode = S_IFREG | S_IRUSR,
460 },
461}; 408};
462 409
463struct vfsmount *rpc_get_mount(void) 410struct vfsmount *rpc_get_mount(void)
@@ -484,39 +431,8 @@ static const struct dentry_operations rpc_dentry_operations = {
484 .d_delete = rpc_delete_dentry, 431 .d_delete = rpc_delete_dentry,
485}; 432};
486 433
487static int
488rpc_lookup_parent(char *path, struct nameidata *nd)
489{
490 struct vfsmount *mnt;
491
492 if (path[0] == '\0')
493 return -ENOENT;
494
495 mnt = rpc_get_mount();
496 if (IS_ERR(mnt)) {
497 printk(KERN_WARNING "%s: %s failed to mount "
498 "pseudofilesystem \n", __FILE__, __func__);
499 return PTR_ERR(mnt);
500 }
501
502 if (vfs_path_lookup(mnt->mnt_root, mnt, path, LOOKUP_PARENT, nd)) {
503 printk(KERN_WARNING "%s: %s failed to find path %s\n",
504 __FILE__, __func__, path);
505 rpc_put_mount();
506 return -ENOENT;
507 }
508 return 0;
509}
510
511static void
512rpc_release_path(struct nameidata *nd)
513{
514 path_put(&nd->path);
515 rpc_put_mount();
516}
517
518static struct inode * 434static struct inode *
519rpc_get_inode(struct super_block *sb, int mode) 435rpc_get_inode(struct super_block *sb, umode_t mode)
520{ 436{
521 struct inode *inode = new_inode(sb); 437 struct inode *inode = new_inode(sb);
522 if (!inode) 438 if (!inode)
@@ -534,212 +450,274 @@ rpc_get_inode(struct super_block *sb, int mode)
534 return inode; 450 return inode;
535} 451}
536 452
537/* 453static int __rpc_create_common(struct inode *dir, struct dentry *dentry,
538 * FIXME: This probably has races. 454 umode_t mode,
539 */ 455 const struct file_operations *i_fop,
540static void rpc_depopulate(struct dentry *parent, 456 void *private)
541 unsigned long start, unsigned long eof)
542{ 457{
543 struct inode *dir = parent->d_inode; 458 struct inode *inode;
544 struct list_head *pos, *next;
545 struct dentry *dentry, *dvec[10];
546 int n = 0;
547 459
548 mutex_lock_nested(&dir->i_mutex, I_MUTEX_CHILD); 460 BUG_ON(!d_unhashed(dentry));
549repeat: 461 inode = rpc_get_inode(dir->i_sb, mode);
550 spin_lock(&dcache_lock); 462 if (!inode)
551 list_for_each_safe(pos, next, &parent->d_subdirs) { 463 goto out_err;
552 dentry = list_entry(pos, struct dentry, d_u.d_child); 464 inode->i_ino = iunique(dir->i_sb, 100);
553 if (!dentry->d_inode || 465 if (i_fop)
554 dentry->d_inode->i_ino < start || 466 inode->i_fop = i_fop;
555 dentry->d_inode->i_ino >= eof) 467 if (private)
556 continue; 468 rpc_inode_setowner(inode, private);
557 spin_lock(&dentry->d_lock); 469 d_add(dentry, inode);
558 if (!d_unhashed(dentry)) { 470 return 0;
559 dget_locked(dentry); 471out_err:
560 __d_drop(dentry); 472 printk(KERN_WARNING "%s: %s failed to allocate inode for dentry %s\n",
561 spin_unlock(&dentry->d_lock); 473 __FILE__, __func__, dentry->d_name.name);
562 dvec[n++] = dentry; 474 dput(dentry);
563 if (n == ARRAY_SIZE(dvec)) 475 return -ENOMEM;
564 break;
565 } else
566 spin_unlock(&dentry->d_lock);
567 }
568 spin_unlock(&dcache_lock);
569 if (n) {
570 do {
571 dentry = dvec[--n];
572 if (S_ISREG(dentry->d_inode->i_mode))
573 simple_unlink(dir, dentry);
574 else if (S_ISDIR(dentry->d_inode->i_mode))
575 simple_rmdir(dir, dentry);
576 d_delete(dentry);
577 dput(dentry);
578 } while (n);
579 goto repeat;
580 }
581 mutex_unlock(&dir->i_mutex);
582} 476}
583 477
584static int 478static int __rpc_create(struct inode *dir, struct dentry *dentry,
585rpc_populate(struct dentry *parent, 479 umode_t mode,
586 struct rpc_filelist *files, 480 const struct file_operations *i_fop,
587 int start, int eof) 481 void *private)
588{ 482{
589 struct inode *inode, *dir = parent->d_inode; 483 int err;
590 void *private = RPC_I(dir)->private;
591 struct dentry *dentry;
592 int mode, i;
593 484
594 mutex_lock(&dir->i_mutex); 485 err = __rpc_create_common(dir, dentry, S_IFREG | mode, i_fop, private);
595 for (i = start; i < eof; i++) { 486 if (err)
596 dentry = d_alloc_name(parent, files[i].name); 487 return err;
597 if (!dentry) 488 fsnotify_create(dir, dentry);
598 goto out_bad;
599 dentry->d_op = &rpc_dentry_operations;
600 mode = files[i].mode;
601 inode = rpc_get_inode(dir->i_sb, mode);
602 if (!inode) {
603 dput(dentry);
604 goto out_bad;
605 }
606 inode->i_ino = i;
607 if (files[i].i_fop)
608 inode->i_fop = files[i].i_fop;
609 if (private)
610 rpc_inode_setowner(inode, private);
611 if (S_ISDIR(mode))
612 inc_nlink(dir);
613 d_add(dentry, inode);
614 fsnotify_create(dir, dentry);
615 }
616 mutex_unlock(&dir->i_mutex);
617 return 0; 489 return 0;
618out_bad:
619 mutex_unlock(&dir->i_mutex);
620 printk(KERN_WARNING "%s: %s failed to populate directory %s\n",
621 __FILE__, __func__, parent->d_name.name);
622 return -ENOMEM;
623} 490}
624 491
625static int 492static int __rpc_mkdir(struct inode *dir, struct dentry *dentry,
626__rpc_mkdir(struct inode *dir, struct dentry *dentry) 493 umode_t mode,
494 const struct file_operations *i_fop,
495 void *private)
627{ 496{
628 struct inode *inode; 497 int err;
629 498
630 inode = rpc_get_inode(dir->i_sb, S_IFDIR | S_IRUGO | S_IXUGO); 499 err = __rpc_create_common(dir, dentry, S_IFDIR | mode, i_fop, private);
631 if (!inode) 500 if (err)
632 goto out_err; 501 return err;
633 inode->i_ino = iunique(dir->i_sb, 100);
634 d_instantiate(dentry, inode);
635 inc_nlink(dir); 502 inc_nlink(dir);
636 fsnotify_mkdir(dir, dentry); 503 fsnotify_mkdir(dir, dentry);
637 return 0; 504 return 0;
638out_err:
639 printk(KERN_WARNING "%s: %s failed to allocate inode for dentry %s\n",
640 __FILE__, __func__, dentry->d_name.name);
641 return -ENOMEM;
642} 505}
643 506
644static int 507static int __rpc_mkpipe(struct inode *dir, struct dentry *dentry,
645__rpc_rmdir(struct inode *dir, struct dentry *dentry) 508 umode_t mode,
509 const struct file_operations *i_fop,
510 void *private,
511 const struct rpc_pipe_ops *ops,
512 int flags)
646{ 513{
647 int error; 514 struct rpc_inode *rpci;
648 error = simple_rmdir(dir, dentry); 515 int err;
649 if (!error) 516
650 d_delete(dentry); 517 err = __rpc_create_common(dir, dentry, S_IFIFO | mode, i_fop, private);
651 return error; 518 if (err)
519 return err;
520 rpci = RPC_I(dentry->d_inode);
521 rpci->nkern_readwriters = 1;
522 rpci->private = private;
523 rpci->flags = flags;
524 rpci->ops = ops;
525 fsnotify_create(dir, dentry);
526 return 0;
652} 527}
653 528
654static struct dentry * 529static int __rpc_rmdir(struct inode *dir, struct dentry *dentry)
655rpc_lookup_create(struct dentry *parent, const char *name, int len, int exclusive) 530{
531 int ret;
532
533 dget(dentry);
534 ret = simple_rmdir(dir, dentry);
535 d_delete(dentry);
536 dput(dentry);
537 return ret;
538}
539
540static int __rpc_unlink(struct inode *dir, struct dentry *dentry)
541{
542 int ret;
543
544 dget(dentry);
545 ret = simple_unlink(dir, dentry);
546 d_delete(dentry);
547 dput(dentry);
548 return ret;
549}
550
551static int __rpc_rmpipe(struct inode *dir, struct dentry *dentry)
552{
553 struct inode *inode = dentry->d_inode;
554 struct rpc_inode *rpci = RPC_I(inode);
555
556 rpci->nkern_readwriters--;
557 if (rpci->nkern_readwriters != 0)
558 return 0;
559 rpc_close_pipes(inode);
560 return __rpc_unlink(dir, dentry);
561}
562
563static struct dentry *__rpc_lookup_create(struct dentry *parent,
564 struct qstr *name)
656{ 565{
657 struct inode *dir = parent->d_inode;
658 struct dentry *dentry; 566 struct dentry *dentry;
659 567
660 mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); 568 dentry = d_lookup(parent, name);
661 dentry = lookup_one_len(name, parent, len); 569 if (!dentry) {
662 if (IS_ERR(dentry)) 570 dentry = d_alloc(parent, name);
663 goto out_err; 571 if (!dentry) {
572 dentry = ERR_PTR(-ENOMEM);
573 goto out_err;
574 }
575 }
664 if (!dentry->d_inode) 576 if (!dentry->d_inode)
665 dentry->d_op = &rpc_dentry_operations; 577 dentry->d_op = &rpc_dentry_operations;
666 else if (exclusive) {
667 dput(dentry);
668 dentry = ERR_PTR(-EEXIST);
669 goto out_err;
670 }
671 return dentry;
672out_err: 578out_err:
673 mutex_unlock(&dir->i_mutex);
674 return dentry; 579 return dentry;
675} 580}
676 581
677static struct dentry * 582static struct dentry *__rpc_lookup_create_exclusive(struct dentry *parent,
678rpc_lookup_negative(char *path, struct nameidata *nd) 583 struct qstr *name)
679{ 584{
680 struct dentry *dentry; 585 struct dentry *dentry;
681 int error;
682 586
683 if ((error = rpc_lookup_parent(path, nd)) != 0) 587 dentry = __rpc_lookup_create(parent, name);
684 return ERR_PTR(error); 588 if (dentry->d_inode == NULL)
685 dentry = rpc_lookup_create(nd->path.dentry, nd->last.name, nd->last.len, 589 return dentry;
686 1); 590 dput(dentry);
687 if (IS_ERR(dentry)) 591 return ERR_PTR(-EEXIST);
688 rpc_release_path(nd);
689 return dentry;
690} 592}
691 593
692/** 594/*
693 * rpc_mkdir - Create a new directory in rpc_pipefs 595 * FIXME: This probably has races.
694 * @path: path from the rpc_pipefs root to the new directory
695 * @rpc_client: rpc client to associate with this directory
696 *
697 * This creates a directory at the given @path associated with
698 * @rpc_clnt, which will contain a file named "info" with some basic
699 * information about the client, together with any "pipes" that may
700 * later be created using rpc_mkpipe().
701 */ 596 */
702struct dentry * 597static void __rpc_depopulate(struct dentry *parent,
703rpc_mkdir(char *path, struct rpc_clnt *rpc_client) 598 const struct rpc_filelist *files,
599 int start, int eof)
704{ 600{
705 struct nameidata nd; 601 struct inode *dir = parent->d_inode;
706 struct dentry *dentry; 602 struct dentry *dentry;
707 struct inode *dir; 603 struct qstr name;
604 int i;
605
606 for (i = start; i < eof; i++) {
607 name.name = files[i].name;
608 name.len = strlen(files[i].name);
609 name.hash = full_name_hash(name.name, name.len);
610 dentry = d_lookup(parent, &name);
611
612 if (dentry == NULL)
613 continue;
614 if (dentry->d_inode == NULL)
615 goto next;
616 switch (dentry->d_inode->i_mode & S_IFMT) {
617 default:
618 BUG();
619 case S_IFREG:
620 __rpc_unlink(dir, dentry);
621 break;
622 case S_IFDIR:
623 __rpc_rmdir(dir, dentry);
624 }
625next:
626 dput(dentry);
627 }
628}
629
630static void rpc_depopulate(struct dentry *parent,
631 const struct rpc_filelist *files,
632 int start, int eof)
633{
634 struct inode *dir = parent->d_inode;
635
636 mutex_lock_nested(&dir->i_mutex, I_MUTEX_CHILD);
637 __rpc_depopulate(parent, files, start, eof);
638 mutex_unlock(&dir->i_mutex);
639}
640
641static int rpc_populate(struct dentry *parent,
642 const struct rpc_filelist *files,
643 int start, int eof,
644 void *private)
645{
646 struct inode *dir = parent->d_inode;
647 struct dentry *dentry;
648 int i, err;
649
650 mutex_lock(&dir->i_mutex);
651 for (i = start; i < eof; i++) {
652 struct qstr q;
653
654 q.name = files[i].name;
655 q.len = strlen(files[i].name);
656 q.hash = full_name_hash(q.name, q.len);
657 dentry = __rpc_lookup_create_exclusive(parent, &q);
658 err = PTR_ERR(dentry);
659 if (IS_ERR(dentry))
660 goto out_bad;
661 switch (files[i].mode & S_IFMT) {
662 default:
663 BUG();
664 case S_IFREG:
665 err = __rpc_create(dir, dentry,
666 files[i].mode,
667 files[i].i_fop,
668 private);
669 break;
670 case S_IFDIR:
671 err = __rpc_mkdir(dir, dentry,
672 files[i].mode,
673 NULL,
674 private);
675 }
676 if (err != 0)
677 goto out_bad;
678 }
679 mutex_unlock(&dir->i_mutex);
680 return 0;
681out_bad:
682 __rpc_depopulate(parent, files, start, eof);
683 mutex_unlock(&dir->i_mutex);
684 printk(KERN_WARNING "%s: %s failed to populate directory %s\n",
685 __FILE__, __func__, parent->d_name.name);
686 return err;
687}
688
689static struct dentry *rpc_mkdir_populate(struct dentry *parent,
690 struct qstr *name, umode_t mode, void *private,
691 int (*populate)(struct dentry *, void *), void *args_populate)
692{
693 struct dentry *dentry;
694 struct inode *dir = parent->d_inode;
708 int error; 695 int error;
709 696
710 dentry = rpc_lookup_negative(path, &nd); 697 mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
698 dentry = __rpc_lookup_create_exclusive(parent, name);
711 if (IS_ERR(dentry)) 699 if (IS_ERR(dentry))
712 return dentry; 700 goto out;
713 dir = nd.path.dentry->d_inode; 701 error = __rpc_mkdir(dir, dentry, mode, NULL, private);
714 if ((error = __rpc_mkdir(dir, dentry)) != 0) 702 if (error != 0)
715 goto err_dput; 703 goto out_err;
716 RPC_I(dentry->d_inode)->private = rpc_client; 704 if (populate != NULL) {
717 error = rpc_populate(dentry, authfiles, 705 error = populate(dentry, args_populate);
718 RPCAUTH_info, RPCAUTH_EOF); 706 if (error)
719 if (error) 707 goto err_rmdir;
720 goto err_depopulate; 708 }
721 dget(dentry);
722out: 709out:
723 mutex_unlock(&dir->i_mutex); 710 mutex_unlock(&dir->i_mutex);
724 rpc_release_path(&nd);
725 return dentry; 711 return dentry;
726err_depopulate: 712err_rmdir:
727 rpc_depopulate(dentry, RPCAUTH_info, RPCAUTH_EOF);
728 __rpc_rmdir(dir, dentry); 713 __rpc_rmdir(dir, dentry);
729err_dput: 714out_err:
730 dput(dentry);
731 printk(KERN_WARNING "%s: %s() failed to create directory %s (errno = %d)\n",
732 __FILE__, __func__, path, error);
733 dentry = ERR_PTR(error); 715 dentry = ERR_PTR(error);
734 goto out; 716 goto out;
735} 717}
736 718
737/** 719static int rpc_rmdir_depopulate(struct dentry *dentry,
738 * rpc_rmdir - Remove a directory created with rpc_mkdir() 720 void (*depopulate)(struct dentry *))
739 * @dentry: directory to remove
740 */
741int
742rpc_rmdir(struct dentry *dentry)
743{ 721{
744 struct dentry *parent; 722 struct dentry *parent;
745 struct inode *dir; 723 struct inode *dir;
@@ -748,9 +726,9 @@ rpc_rmdir(struct dentry *dentry)
748 parent = dget_parent(dentry); 726 parent = dget_parent(dentry);
749 dir = parent->d_inode; 727 dir = parent->d_inode;
750 mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); 728 mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
751 rpc_depopulate(dentry, RPCAUTH_info, RPCAUTH_EOF); 729 if (depopulate != NULL)
730 depopulate(dentry);
752 error = __rpc_rmdir(dir, dentry); 731 error = __rpc_rmdir(dir, dentry);
753 dput(dentry);
754 mutex_unlock(&dir->i_mutex); 732 mutex_unlock(&dir->i_mutex);
755 dput(parent); 733 dput(parent);
756 return error; 734 return error;
@@ -776,50 +754,54 @@ rpc_rmdir(struct dentry *dentry)
776 * The @private argument passed here will be available to all these methods 754 * The @private argument passed here will be available to all these methods
777 * from the file pointer, via RPC_I(file->f_dentry->d_inode)->private. 755 * from the file pointer, via RPC_I(file->f_dentry->d_inode)->private.
778 */ 756 */
779struct dentry * 757struct dentry *rpc_mkpipe(struct dentry *parent, const char *name,
780rpc_mkpipe(struct dentry *parent, const char *name, void *private, struct rpc_pipe_ops *ops, int flags) 758 void *private, const struct rpc_pipe_ops *ops,
759 int flags)
781{ 760{
782 struct dentry *dentry; 761 struct dentry *dentry;
783 struct inode *dir, *inode; 762 struct inode *dir = parent->d_inode;
784 struct rpc_inode *rpci; 763 umode_t umode = S_IFIFO | S_IRUSR | S_IWUSR;
764 struct qstr q;
765 int err;
785 766
786 dentry = rpc_lookup_create(parent, name, strlen(name), 0); 767 if (ops->upcall == NULL)
768 umode &= ~S_IRUGO;
769 if (ops->downcall == NULL)
770 umode &= ~S_IWUGO;
771
772 q.name = name;
773 q.len = strlen(name);
774 q.hash = full_name_hash(q.name, q.len),
775
776 mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
777 dentry = __rpc_lookup_create(parent, &q);
787 if (IS_ERR(dentry)) 778 if (IS_ERR(dentry))
788 return dentry; 779 goto out;
789 dir = parent->d_inode;
790 if (dentry->d_inode) { 780 if (dentry->d_inode) {
791 rpci = RPC_I(dentry->d_inode); 781 struct rpc_inode *rpci = RPC_I(dentry->d_inode);
792 if (rpci->private != private || 782 if (rpci->private != private ||
793 rpci->ops != ops || 783 rpci->ops != ops ||
794 rpci->flags != flags) { 784 rpci->flags != flags) {
795 dput (dentry); 785 dput (dentry);
796 dentry = ERR_PTR(-EBUSY); 786 err = -EBUSY;
787 goto out_err;
797 } 788 }
798 rpci->nkern_readwriters++; 789 rpci->nkern_readwriters++;
799 goto out; 790 goto out;
800 } 791 }
801 inode = rpc_get_inode(dir->i_sb, S_IFIFO | S_IRUSR | S_IWUSR); 792
802 if (!inode) 793 err = __rpc_mkpipe(dir, dentry, umode, &rpc_pipe_fops,
803 goto err_dput; 794 private, ops, flags);
804 inode->i_ino = iunique(dir->i_sb, 100); 795 if (err)
805 inode->i_fop = &rpc_pipe_fops; 796 goto out_err;
806 d_instantiate(dentry, inode);
807 rpci = RPC_I(inode);
808 rpci->private = private;
809 rpci->flags = flags;
810 rpci->ops = ops;
811 rpci->nkern_readwriters = 1;
812 fsnotify_create(dir, dentry);
813 dget(dentry);
814out: 797out:
815 mutex_unlock(&dir->i_mutex); 798 mutex_unlock(&dir->i_mutex);
816 return dentry; 799 return dentry;
817err_dput: 800out_err:
818 dput(dentry); 801 dentry = ERR_PTR(err);
819 dentry = ERR_PTR(-ENOMEM);
820 printk(KERN_WARNING "%s: %s() failed to create pipe %s/%s (errno = %d)\n", 802 printk(KERN_WARNING "%s: %s() failed to create pipe %s/%s (errno = %d)\n",
821 __FILE__, __func__, parent->d_name.name, name, 803 __FILE__, __func__, parent->d_name.name, name,
822 -ENOMEM); 804 err);
823 goto out; 805 goto out;
824} 806}
825EXPORT_SYMBOL_GPL(rpc_mkpipe); 807EXPORT_SYMBOL_GPL(rpc_mkpipe);
@@ -842,19 +824,107 @@ rpc_unlink(struct dentry *dentry)
842 parent = dget_parent(dentry); 824 parent = dget_parent(dentry);
843 dir = parent->d_inode; 825 dir = parent->d_inode;
844 mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); 826 mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
845 if (--RPC_I(dentry->d_inode)->nkern_readwriters == 0) { 827 error = __rpc_rmpipe(dir, dentry);
846 rpc_close_pipes(dentry->d_inode);
847 error = simple_unlink(dir, dentry);
848 if (!error)
849 d_delete(dentry);
850 }
851 dput(dentry);
852 mutex_unlock(&dir->i_mutex); 828 mutex_unlock(&dir->i_mutex);
853 dput(parent); 829 dput(parent);
854 return error; 830 return error;
855} 831}
856EXPORT_SYMBOL_GPL(rpc_unlink); 832EXPORT_SYMBOL_GPL(rpc_unlink);
857 833
834enum {
835 RPCAUTH_info,
836 RPCAUTH_EOF
837};
838
839static const struct rpc_filelist authfiles[] = {
840 [RPCAUTH_info] = {
841 .name = "info",
842 .i_fop = &rpc_info_operations,
843 .mode = S_IFREG | S_IRUSR,
844 },
845};
846
847static int rpc_clntdir_populate(struct dentry *dentry, void *private)
848{
849 return rpc_populate(dentry,
850 authfiles, RPCAUTH_info, RPCAUTH_EOF,
851 private);
852}
853
854static void rpc_clntdir_depopulate(struct dentry *dentry)
855{
856 rpc_depopulate(dentry, authfiles, RPCAUTH_info, RPCAUTH_EOF);
857}
858
859/**
860 * rpc_create_client_dir - Create a new rpc_client directory in rpc_pipefs
861 * @path: path from the rpc_pipefs root to the new directory
862 * @rpc_client: rpc client to associate with this directory
863 *
864 * This creates a directory at the given @path associated with
865 * @rpc_clnt, which will contain a file named "info" with some basic
866 * information about the client, together with any "pipes" that may
867 * later be created using rpc_mkpipe().
868 */
869struct dentry *rpc_create_client_dir(struct dentry *dentry,
870 struct qstr *name,
871 struct rpc_clnt *rpc_client)
872{
873 return rpc_mkdir_populate(dentry, name, S_IRUGO | S_IXUGO, NULL,
874 rpc_clntdir_populate, rpc_client);
875}
876
877/**
878 * rpc_remove_client_dir - Remove a directory created with rpc_create_client_dir()
879 * @dentry: directory to remove
880 */
881int rpc_remove_client_dir(struct dentry *dentry)
882{
883 return rpc_rmdir_depopulate(dentry, rpc_clntdir_depopulate);
884}
885
886static const struct rpc_filelist cache_pipefs_files[3] = {
887 [0] = {
888 .name = "channel",
889 .i_fop = &cache_file_operations_pipefs,
890 .mode = S_IFIFO|S_IRUSR|S_IWUSR,
891 },
892 [1] = {
893 .name = "content",
894 .i_fop = &content_file_operations_pipefs,
895 .mode = S_IFREG|S_IRUSR,
896 },
897 [2] = {
898 .name = "flush",
899 .i_fop = &cache_flush_operations_pipefs,
900 .mode = S_IFREG|S_IRUSR|S_IWUSR,
901 },
902};
903
904static int rpc_cachedir_populate(struct dentry *dentry, void *private)
905{
906 return rpc_populate(dentry,
907 cache_pipefs_files, 0, 3,
908 private);
909}
910
911static void rpc_cachedir_depopulate(struct dentry *dentry)
912{
913 rpc_depopulate(dentry, cache_pipefs_files, 0, 3);
914}
915
916struct dentry *rpc_create_cache_dir(struct dentry *parent, struct qstr *name,
917 mode_t umode, struct cache_detail *cd)
918{
919 return rpc_mkdir_populate(parent, name, umode, NULL,
920 rpc_cachedir_populate, cd);
921}
922
923void rpc_remove_cache_dir(struct dentry *dentry)
924{
925 rpc_rmdir_depopulate(dentry, rpc_cachedir_depopulate);
926}
927
858/* 928/*
859 * populate the filesystem 929 * populate the filesystem
860 */ 930 */
@@ -866,6 +936,46 @@ static struct super_operations s_ops = {
866 936
867#define RPCAUTH_GSSMAGIC 0x67596969 937#define RPCAUTH_GSSMAGIC 0x67596969
868 938
939/*
940 * We have a single directory with 1 node in it.
941 */
942enum {
943 RPCAUTH_lockd,
944 RPCAUTH_mount,
945 RPCAUTH_nfs,
946 RPCAUTH_portmap,
947 RPCAUTH_statd,
948 RPCAUTH_nfsd4_cb,
949 RPCAUTH_RootEOF
950};
951
952static const struct rpc_filelist files[] = {
953 [RPCAUTH_lockd] = {
954 .name = "lockd",
955 .mode = S_IFDIR | S_IRUGO | S_IXUGO,
956 },
957 [RPCAUTH_mount] = {
958 .name = "mount",
959 .mode = S_IFDIR | S_IRUGO | S_IXUGO,
960 },
961 [RPCAUTH_nfs] = {
962 .name = "nfs",
963 .mode = S_IFDIR | S_IRUGO | S_IXUGO,
964 },
965 [RPCAUTH_portmap] = {
966 .name = "portmap",
967 .mode = S_IFDIR | S_IRUGO | S_IXUGO,
968 },
969 [RPCAUTH_statd] = {
970 .name = "statd",
971 .mode = S_IFDIR | S_IRUGO | S_IXUGO,
972 },
973 [RPCAUTH_nfsd4_cb] = {
974 .name = "nfsd4_cb",
975 .mode = S_IFDIR | S_IRUGO | S_IXUGO,
976 },
977};
978
869static int 979static int
870rpc_fill_super(struct super_block *sb, void *data, int silent) 980rpc_fill_super(struct super_block *sb, void *data, int silent)
871{ 981{
@@ -886,7 +996,7 @@ rpc_fill_super(struct super_block *sb, void *data, int silent)
886 iput(inode); 996 iput(inode);
887 return -ENOMEM; 997 return -ENOMEM;
888 } 998 }
889 if (rpc_populate(root, files, RPCAUTH_Root + 1, RPCAUTH_RootEOF)) 999 if (rpc_populate(root, files, RPCAUTH_lockd, RPCAUTH_RootEOF, NULL))
890 goto out; 1000 goto out;
891 sb->s_root = root; 1001 sb->s_root = root;
892 return 0; 1002 return 0;
diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
index 5c865e2d299e..6caffa34ac01 100644
--- a/net/sunrpc/svcauth_unix.c
+++ b/net/sunrpc/svcauth_unix.c
@@ -171,6 +171,11 @@ static void ip_map_request(struct cache_detail *cd,
171 (*bpp)[-1] = '\n'; 171 (*bpp)[-1] = '\n';
172} 172}
173 173
174static int ip_map_upcall(struct cache_detail *cd, struct cache_head *h)
175{
176 return sunrpc_cache_pipe_upcall(cd, h, ip_map_request);
177}
178
174static struct ip_map *ip_map_lookup(char *class, struct in6_addr *addr); 179static struct ip_map *ip_map_lookup(char *class, struct in6_addr *addr);
175static int ip_map_update(struct ip_map *ipm, struct unix_domain *udom, time_t expiry); 180static int ip_map_update(struct ip_map *ipm, struct unix_domain *udom, time_t expiry);
176 181
@@ -289,7 +294,7 @@ struct cache_detail ip_map_cache = {
289 .hash_table = ip_table, 294 .hash_table = ip_table,
290 .name = "auth.unix.ip", 295 .name = "auth.unix.ip",
291 .cache_put = ip_map_put, 296 .cache_put = ip_map_put,
292 .cache_request = ip_map_request, 297 .cache_upcall = ip_map_upcall,
293 .cache_parse = ip_map_parse, 298 .cache_parse = ip_map_parse,
294 .cache_show = ip_map_show, 299 .cache_show = ip_map_show,
295 .match = ip_map_match, 300 .match = ip_map_match,
@@ -523,6 +528,11 @@ static void unix_gid_request(struct cache_detail *cd,
523 (*bpp)[-1] = '\n'; 528 (*bpp)[-1] = '\n';
524} 529}
525 530
531static int unix_gid_upcall(struct cache_detail *cd, struct cache_head *h)
532{
533 return sunrpc_cache_pipe_upcall(cd, h, unix_gid_request);
534}
535
526static struct unix_gid *unix_gid_lookup(uid_t uid); 536static struct unix_gid *unix_gid_lookup(uid_t uid);
527extern struct cache_detail unix_gid_cache; 537extern struct cache_detail unix_gid_cache;
528 538
@@ -622,7 +632,7 @@ struct cache_detail unix_gid_cache = {
622 .hash_table = gid_table, 632 .hash_table = gid_table,
623 .name = "auth.unix.gid", 633 .name = "auth.unix.gid",
624 .cache_put = unix_gid_put, 634 .cache_put = unix_gid_put,
625 .cache_request = unix_gid_request, 635 .cache_upcall = unix_gid_upcall,
626 .cache_parse = unix_gid_parse, 636 .cache_parse = unix_gid_parse,
627 .cache_show = unix_gid_show, 637 .cache_show = unix_gid_show,
628 .match = unix_gid_match, 638 .match = unix_gid_match,