[PATCH] broken cast in parport_pc
[linux-2.6/cjktty.git] / net / sunrpc / rpc_pipe.c
blobc76ea221798caf96666ef99ac3ce5c1694c832b7
1 /*
2 * net/sunrpc/rpc_pipe.c
4 * Userland/kernel interface for rpcauth_gss.
5 * Code shamelessly plagiarized from fs/nfsd/nfsctl.c
6 * and fs/sysfs/inode.c
8 * Copyright (c) 2002, Trond Myklebust <trond.myklebust@fys.uio.no>
11 #include <linux/config.h>
12 #include <linux/module.h>
13 #include <linux/slab.h>
14 #include <linux/string.h>
15 #include <linux/pagemap.h>
16 #include <linux/mount.h>
17 #include <linux/namei.h>
18 #include <linux/dnotify.h>
19 #include <linux/kernel.h>
21 #include <asm/ioctls.h>
22 #include <linux/fs.h>
23 #include <linux/poll.h>
24 #include <linux/wait.h>
25 #include <linux/seq_file.h>
27 #include <linux/sunrpc/clnt.h>
28 #include <linux/workqueue.h>
29 #include <linux/sunrpc/rpc_pipe_fs.h>
31 static struct vfsmount *rpc_mount __read_mostly;
32 static int rpc_mount_count;
34 static struct file_system_type rpc_pipe_fs_type;
37 static kmem_cache_t *rpc_inode_cachep __read_mostly;
39 #define RPC_UPCALL_TIMEOUT (30*HZ)
41 static void
42 __rpc_purge_list(struct rpc_inode *rpci, struct list_head *head, int err)
44 struct rpc_pipe_msg *msg;
45 void (*destroy_msg)(struct rpc_pipe_msg *);
47 destroy_msg = rpci->ops->destroy_msg;
48 while (!list_empty(head)) {
49 msg = list_entry(head->next, struct rpc_pipe_msg, list);
50 list_del_init(&msg->list);
51 msg->errno = err;
52 destroy_msg(msg);
56 static void
57 __rpc_purge_upcall(struct inode *inode, int err)
59 struct rpc_inode *rpci = RPC_I(inode);
61 __rpc_purge_list(rpci, &rpci->pipe, err);
62 rpci->pipelen = 0;
63 wake_up(&rpci->waitq);
66 static void
67 rpc_timeout_upcall_queue(void *data)
69 struct rpc_inode *rpci = (struct rpc_inode *)data;
70 struct inode *inode = &rpci->vfs_inode;
72 down(&inode->i_sem);
73 if (rpci->nreaders == 0 && !list_empty(&rpci->pipe))
74 __rpc_purge_upcall(inode, -ETIMEDOUT);
75 up(&inode->i_sem);
78 int
79 rpc_queue_upcall(struct inode *inode, struct rpc_pipe_msg *msg)
81 struct rpc_inode *rpci = RPC_I(inode);
82 int res = -EPIPE;
84 down(&inode->i_sem);
85 if (rpci->ops == NULL)
86 goto out;
87 if (rpci->nreaders) {
88 list_add_tail(&msg->list, &rpci->pipe);
89 rpci->pipelen += msg->len;
90 res = 0;
91 } else if (rpci->flags & RPC_PIPE_WAIT_FOR_OPEN) {
92 if (list_empty(&rpci->pipe))
93 schedule_delayed_work(&rpci->queue_timeout,
94 RPC_UPCALL_TIMEOUT);
95 list_add_tail(&msg->list, &rpci->pipe);
96 rpci->pipelen += msg->len;
97 res = 0;
99 out:
100 up(&inode->i_sem);
101 wake_up(&rpci->waitq);
102 return res;
105 static inline void
106 rpc_inode_setowner(struct inode *inode, void *private)
108 RPC_I(inode)->private = private;
111 static void
112 rpc_close_pipes(struct inode *inode)
114 struct rpc_inode *rpci = RPC_I(inode);
116 cancel_delayed_work(&rpci->queue_timeout);
117 flush_scheduled_work();
118 down(&inode->i_sem);
119 if (rpci->ops != NULL) {
120 rpci->nreaders = 0;
121 __rpc_purge_list(rpci, &rpci->in_upcall, -EPIPE);
122 __rpc_purge_upcall(inode, -EPIPE);
123 rpci->nwriters = 0;
124 if (rpci->ops->release_pipe)
125 rpci->ops->release_pipe(inode);
126 rpci->ops = NULL;
128 rpc_inode_setowner(inode, NULL);
129 up(&inode->i_sem);
132 static struct inode *
133 rpc_alloc_inode(struct super_block *sb)
135 struct rpc_inode *rpci;
136 rpci = (struct rpc_inode *)kmem_cache_alloc(rpc_inode_cachep, SLAB_KERNEL);
137 if (!rpci)
138 return NULL;
139 return &rpci->vfs_inode;
142 static void
143 rpc_destroy_inode(struct inode *inode)
145 kmem_cache_free(rpc_inode_cachep, RPC_I(inode));
148 static int
149 rpc_pipe_open(struct inode *inode, struct file *filp)
151 struct rpc_inode *rpci = RPC_I(inode);
152 int res = -ENXIO;
154 down(&inode->i_sem);
155 if (rpci->ops != NULL) {
156 if (filp->f_mode & FMODE_READ)
157 rpci->nreaders ++;
158 if (filp->f_mode & FMODE_WRITE)
159 rpci->nwriters ++;
160 res = 0;
162 up(&inode->i_sem);
163 return res;
166 static int
167 rpc_pipe_release(struct inode *inode, struct file *filp)
169 struct rpc_inode *rpci = RPC_I(filp->f_dentry->d_inode);
170 struct rpc_pipe_msg *msg;
172 down(&inode->i_sem);
173 if (rpci->ops == NULL)
174 goto out;
175 msg = (struct rpc_pipe_msg *)filp->private_data;
176 if (msg != NULL) {
177 msg->errno = -EPIPE;
178 list_del_init(&msg->list);
179 rpci->ops->destroy_msg(msg);
181 if (filp->f_mode & FMODE_WRITE)
182 rpci->nwriters --;
183 if (filp->f_mode & FMODE_READ)
184 rpci->nreaders --;
185 if (!rpci->nreaders)
186 __rpc_purge_upcall(inode, -EPIPE);
187 if (rpci->ops->release_pipe)
188 rpci->ops->release_pipe(inode);
189 out:
190 up(&inode->i_sem);
191 return 0;
194 static ssize_t
195 rpc_pipe_read(struct file *filp, char __user *buf, size_t len, loff_t *offset)
197 struct inode *inode = filp->f_dentry->d_inode;
198 struct rpc_inode *rpci = RPC_I(inode);
199 struct rpc_pipe_msg *msg;
200 int res = 0;
202 down(&inode->i_sem);
203 if (rpci->ops == NULL) {
204 res = -EPIPE;
205 goto out_unlock;
207 msg = filp->private_data;
208 if (msg == NULL) {
209 if (!list_empty(&rpci->pipe)) {
210 msg = list_entry(rpci->pipe.next,
211 struct rpc_pipe_msg,
212 list);
213 list_move(&msg->list, &rpci->in_upcall);
214 rpci->pipelen -= msg->len;
215 filp->private_data = msg;
216 msg->copied = 0;
218 if (msg == NULL)
219 goto out_unlock;
221 /* NOTE: it is up to the callback to update msg->copied */
222 res = rpci->ops->upcall(filp, msg, buf, len);
223 if (res < 0 || msg->len == msg->copied) {
224 filp->private_data = NULL;
225 list_del_init(&msg->list);
226 rpci->ops->destroy_msg(msg);
228 out_unlock:
229 up(&inode->i_sem);
230 return res;
233 static ssize_t
234 rpc_pipe_write(struct file *filp, const char __user *buf, size_t len, loff_t *offset)
236 struct inode *inode = filp->f_dentry->d_inode;
237 struct rpc_inode *rpci = RPC_I(inode);
238 int res;
240 down(&inode->i_sem);
241 res = -EPIPE;
242 if (rpci->ops != NULL)
243 res = rpci->ops->downcall(filp, buf, len);
244 up(&inode->i_sem);
245 return res;
248 static unsigned int
249 rpc_pipe_poll(struct file *filp, struct poll_table_struct *wait)
251 struct rpc_inode *rpci;
252 unsigned int mask = 0;
254 rpci = RPC_I(filp->f_dentry->d_inode);
255 poll_wait(filp, &rpci->waitq, wait);
257 mask = POLLOUT | POLLWRNORM;
258 if (rpci->ops == NULL)
259 mask |= POLLERR | POLLHUP;
260 if (!list_empty(&rpci->pipe))
261 mask |= POLLIN | POLLRDNORM;
262 return mask;
265 static int
266 rpc_pipe_ioctl(struct inode *ino, struct file *filp,
267 unsigned int cmd, unsigned long arg)
269 struct rpc_inode *rpci = RPC_I(filp->f_dentry->d_inode);
270 int len;
272 switch (cmd) {
273 case FIONREAD:
274 if (rpci->ops == NULL)
275 return -EPIPE;
276 len = rpci->pipelen;
277 if (filp->private_data) {
278 struct rpc_pipe_msg *msg;
279 msg = (struct rpc_pipe_msg *)filp->private_data;
280 len += msg->len - msg->copied;
282 return put_user(len, (int __user *)arg);
283 default:
284 return -EINVAL;
288 static struct file_operations rpc_pipe_fops = {
289 .owner = THIS_MODULE,
290 .llseek = no_llseek,
291 .read = rpc_pipe_read,
292 .write = rpc_pipe_write,
293 .poll = rpc_pipe_poll,
294 .ioctl = rpc_pipe_ioctl,
295 .open = rpc_pipe_open,
296 .release = rpc_pipe_release,
299 static int
300 rpc_show_info(struct seq_file *m, void *v)
302 struct rpc_clnt *clnt = m->private;
304 seq_printf(m, "RPC server: %s\n", clnt->cl_server);
305 seq_printf(m, "service: %s (%d) version %d\n", clnt->cl_protname,
306 clnt->cl_prog, clnt->cl_vers);
307 seq_printf(m, "address: %u.%u.%u.%u\n",
308 NIPQUAD(clnt->cl_xprt->addr.sin_addr.s_addr));
309 seq_printf(m, "protocol: %s\n",
310 clnt->cl_xprt->prot == IPPROTO_UDP ? "udp" : "tcp");
311 return 0;
314 static int
315 rpc_info_open(struct inode *inode, struct file *file)
317 struct rpc_clnt *clnt;
318 int ret = single_open(file, rpc_show_info, NULL);
320 if (!ret) {
321 struct seq_file *m = file->private_data;
322 down(&inode->i_sem);
323 clnt = RPC_I(inode)->private;
324 if (clnt) {
325 atomic_inc(&clnt->cl_users);
326 m->private = clnt;
327 } else {
328 single_release(inode, file);
329 ret = -EINVAL;
331 up(&inode->i_sem);
333 return ret;
336 static int
337 rpc_info_release(struct inode *inode, struct file *file)
339 struct seq_file *m = file->private_data;
340 struct rpc_clnt *clnt = (struct rpc_clnt *)m->private;
342 if (clnt)
343 rpc_release_client(clnt);
344 return single_release(inode, file);
347 static struct file_operations rpc_info_operations = {
348 .owner = THIS_MODULE,
349 .open = rpc_info_open,
350 .read = seq_read,
351 .llseek = seq_lseek,
352 .release = rpc_info_release,
357 * We have a single directory with 1 node in it.
359 enum {
360 RPCAUTH_Root = 1,
361 RPCAUTH_lockd,
362 RPCAUTH_mount,
363 RPCAUTH_nfs,
364 RPCAUTH_portmap,
365 RPCAUTH_statd,
366 RPCAUTH_RootEOF
370 * Description of fs contents.
372 struct rpc_filelist {
373 char *name;
374 struct file_operations *i_fop;
375 int mode;
378 static struct rpc_filelist files[] = {
379 [RPCAUTH_lockd] = {
380 .name = "lockd",
381 .mode = S_IFDIR | S_IRUGO | S_IXUGO,
383 [RPCAUTH_mount] = {
384 .name = "mount",
385 .mode = S_IFDIR | S_IRUGO | S_IXUGO,
387 [RPCAUTH_nfs] = {
388 .name = "nfs",
389 .mode = S_IFDIR | S_IRUGO | S_IXUGO,
391 [RPCAUTH_portmap] = {
392 .name = "portmap",
393 .mode = S_IFDIR | S_IRUGO | S_IXUGO,
395 [RPCAUTH_statd] = {
396 .name = "statd",
397 .mode = S_IFDIR | S_IRUGO | S_IXUGO,
401 enum {
402 RPCAUTH_info = 2,
403 RPCAUTH_EOF
406 static struct rpc_filelist authfiles[] = {
407 [RPCAUTH_info] = {
408 .name = "info",
409 .i_fop = &rpc_info_operations,
410 .mode = S_IFREG | S_IRUSR,
414 static int
415 rpc_get_mount(void)
417 return simple_pin_fs("rpc_pipefs", &rpc_mount, &rpc_mount_count);
420 static void
421 rpc_put_mount(void)
423 simple_release_fs(&rpc_mount, &rpc_mount_count);
426 static int
427 rpc_lookup_parent(char *path, struct nameidata *nd)
429 if (path[0] == '\0')
430 return -ENOENT;
431 if (rpc_get_mount()) {
432 printk(KERN_WARNING "%s: %s failed to mount "
433 "pseudofilesystem \n", __FILE__, __FUNCTION__);
434 return -ENODEV;
436 nd->mnt = mntget(rpc_mount);
437 nd->dentry = dget(rpc_mount->mnt_root);
438 nd->last_type = LAST_ROOT;
439 nd->flags = LOOKUP_PARENT;
440 nd->depth = 0;
442 if (path_walk(path, nd)) {
443 printk(KERN_WARNING "%s: %s failed to find path %s\n",
444 __FILE__, __FUNCTION__, path);
445 rpc_put_mount();
446 return -ENOENT;
448 return 0;
451 static void
452 rpc_release_path(struct nameidata *nd)
454 path_release(nd);
455 rpc_put_mount();
458 static struct inode *
459 rpc_get_inode(struct super_block *sb, int mode)
461 struct inode *inode = new_inode(sb);
462 if (!inode)
463 return NULL;
464 inode->i_mode = mode;
465 inode->i_uid = inode->i_gid = 0;
466 inode->i_blksize = PAGE_CACHE_SIZE;
467 inode->i_blocks = 0;
468 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
469 switch(mode & S_IFMT) {
470 case S_IFDIR:
471 inode->i_fop = &simple_dir_operations;
472 inode->i_op = &simple_dir_inode_operations;
473 inode->i_nlink++;
474 default:
475 break;
477 return inode;
481 * FIXME: This probably has races.
483 static void
484 rpc_depopulate(struct dentry *parent)
486 struct inode *dir = parent->d_inode;
487 struct list_head *pos, *next;
488 struct dentry *dentry, *dvec[10];
489 int n = 0;
491 down(&dir->i_sem);
492 repeat:
493 spin_lock(&dcache_lock);
494 list_for_each_safe(pos, next, &parent->d_subdirs) {
495 dentry = list_entry(pos, struct dentry, d_child);
496 spin_lock(&dentry->d_lock);
497 if (!d_unhashed(dentry)) {
498 dget_locked(dentry);
499 __d_drop(dentry);
500 spin_unlock(&dentry->d_lock);
501 dvec[n++] = dentry;
502 if (n == ARRAY_SIZE(dvec))
503 break;
504 } else
505 spin_unlock(&dentry->d_lock);
507 spin_unlock(&dcache_lock);
508 if (n) {
509 do {
510 dentry = dvec[--n];
511 if (dentry->d_inode) {
512 rpc_close_pipes(dentry->d_inode);
513 simple_unlink(dir, dentry);
515 dput(dentry);
516 } while (n);
517 goto repeat;
519 up(&dir->i_sem);
522 static int
523 rpc_populate(struct dentry *parent,
524 struct rpc_filelist *files,
525 int start, int eof)
527 struct inode *inode, *dir = parent->d_inode;
528 void *private = RPC_I(dir)->private;
529 struct dentry *dentry;
530 int mode, i;
532 down(&dir->i_sem);
533 for (i = start; i < eof; i++) {
534 dentry = d_alloc_name(parent, files[i].name);
535 if (!dentry)
536 goto out_bad;
537 mode = files[i].mode;
538 inode = rpc_get_inode(dir->i_sb, mode);
539 if (!inode) {
540 dput(dentry);
541 goto out_bad;
543 inode->i_ino = i;
544 if (files[i].i_fop)
545 inode->i_fop = files[i].i_fop;
546 if (private)
547 rpc_inode_setowner(inode, private);
548 if (S_ISDIR(mode))
549 dir->i_nlink++;
550 d_add(dentry, inode);
552 up(&dir->i_sem);
553 return 0;
554 out_bad:
555 up(&dir->i_sem);
556 printk(KERN_WARNING "%s: %s failed to populate directory %s\n",
557 __FILE__, __FUNCTION__, parent->d_name.name);
558 return -ENOMEM;
561 static int
562 __rpc_mkdir(struct inode *dir, struct dentry *dentry)
564 struct inode *inode;
566 inode = rpc_get_inode(dir->i_sb, S_IFDIR | S_IRUSR | S_IXUSR);
567 if (!inode)
568 goto out_err;
569 inode->i_ino = iunique(dir->i_sb, 100);
570 d_instantiate(dentry, inode);
571 dir->i_nlink++;
572 inode_dir_notify(dir, DN_CREATE);
573 rpc_get_mount();
574 return 0;
575 out_err:
576 printk(KERN_WARNING "%s: %s failed to allocate inode for dentry %s\n",
577 __FILE__, __FUNCTION__, dentry->d_name.name);
578 return -ENOMEM;
581 static int
582 __rpc_rmdir(struct inode *dir, struct dentry *dentry)
584 int error;
586 shrink_dcache_parent(dentry);
587 if (dentry->d_inode)
588 rpc_close_pipes(dentry->d_inode);
589 if ((error = simple_rmdir(dir, dentry)) != 0)
590 return error;
591 if (!error) {
592 inode_dir_notify(dir, DN_DELETE);
593 d_drop(dentry);
594 rpc_put_mount();
596 return 0;
599 static struct dentry *
600 rpc_lookup_negative(char *path, struct nameidata *nd)
602 struct dentry *dentry;
603 struct inode *dir;
604 int error;
606 if ((error = rpc_lookup_parent(path, nd)) != 0)
607 return ERR_PTR(error);
608 dir = nd->dentry->d_inode;
609 down(&dir->i_sem);
610 dentry = lookup_hash(nd);
611 if (IS_ERR(dentry))
612 goto out_err;
613 if (dentry->d_inode) {
614 dput(dentry);
615 dentry = ERR_PTR(-EEXIST);
616 goto out_err;
618 return dentry;
619 out_err:
620 up(&dir->i_sem);
621 rpc_release_path(nd);
622 return dentry;
626 struct dentry *
627 rpc_mkdir(char *path, struct rpc_clnt *rpc_client)
629 struct nameidata nd;
630 struct dentry *dentry;
631 struct inode *dir;
632 int error;
634 dentry = rpc_lookup_negative(path, &nd);
635 if (IS_ERR(dentry))
636 return dentry;
637 dir = nd.dentry->d_inode;
638 if ((error = __rpc_mkdir(dir, dentry)) != 0)
639 goto err_dput;
640 RPC_I(dentry->d_inode)->private = rpc_client;
641 error = rpc_populate(dentry, authfiles,
642 RPCAUTH_info, RPCAUTH_EOF);
643 if (error)
644 goto err_depopulate;
645 out:
646 up(&dir->i_sem);
647 rpc_release_path(&nd);
648 return dentry;
649 err_depopulate:
650 rpc_depopulate(dentry);
651 __rpc_rmdir(dir, dentry);
652 err_dput:
653 dput(dentry);
654 printk(KERN_WARNING "%s: %s() failed to create directory %s (errno = %d)\n",
655 __FILE__, __FUNCTION__, path, error);
656 dentry = ERR_PTR(error);
657 goto out;
661 rpc_rmdir(char *path)
663 struct nameidata nd;
664 struct dentry *dentry;
665 struct inode *dir;
666 int error;
668 if ((error = rpc_lookup_parent(path, &nd)) != 0)
669 return error;
670 dir = nd.dentry->d_inode;
671 down(&dir->i_sem);
672 dentry = lookup_hash(&nd);
673 if (IS_ERR(dentry)) {
674 error = PTR_ERR(dentry);
675 goto out_release;
677 rpc_depopulate(dentry);
678 error = __rpc_rmdir(dir, dentry);
679 dput(dentry);
680 out_release:
681 up(&dir->i_sem);
682 rpc_release_path(&nd);
683 return error;
686 struct dentry *
687 rpc_mkpipe(char *path, void *private, struct rpc_pipe_ops *ops, int flags)
689 struct nameidata nd;
690 struct dentry *dentry;
691 struct inode *dir, *inode;
692 struct rpc_inode *rpci;
694 dentry = rpc_lookup_negative(path, &nd);
695 if (IS_ERR(dentry))
696 return dentry;
697 dir = nd.dentry->d_inode;
698 inode = rpc_get_inode(dir->i_sb, S_IFSOCK | S_IRUSR | S_IWUSR);
699 if (!inode)
700 goto err_dput;
701 inode->i_ino = iunique(dir->i_sb, 100);
702 inode->i_fop = &rpc_pipe_fops;
703 d_instantiate(dentry, inode);
704 rpci = RPC_I(inode);
705 rpci->private = private;
706 rpci->flags = flags;
707 rpci->ops = ops;
708 inode_dir_notify(dir, DN_CREATE);
709 out:
710 up(&dir->i_sem);
711 rpc_release_path(&nd);
712 return dentry;
713 err_dput:
714 dput(dentry);
715 dentry = ERR_PTR(-ENOMEM);
716 printk(KERN_WARNING "%s: %s() failed to create pipe %s (errno = %d)\n",
717 __FILE__, __FUNCTION__, path, -ENOMEM);
718 goto out;
722 rpc_unlink(char *path)
724 struct nameidata nd;
725 struct dentry *dentry;
726 struct inode *dir;
727 int error;
729 if ((error = rpc_lookup_parent(path, &nd)) != 0)
730 return error;
731 dir = nd.dentry->d_inode;
732 down(&dir->i_sem);
733 dentry = lookup_hash(&nd);
734 if (IS_ERR(dentry)) {
735 error = PTR_ERR(dentry);
736 goto out_release;
738 d_drop(dentry);
739 if (dentry->d_inode) {
740 rpc_close_pipes(dentry->d_inode);
741 error = simple_unlink(dir, dentry);
743 dput(dentry);
744 inode_dir_notify(dir, DN_DELETE);
745 out_release:
746 up(&dir->i_sem);
747 rpc_release_path(&nd);
748 return error;
752 * populate the filesystem
754 static struct super_operations s_ops = {
755 .alloc_inode = rpc_alloc_inode,
756 .destroy_inode = rpc_destroy_inode,
757 .statfs = simple_statfs,
760 #define RPCAUTH_GSSMAGIC 0x67596969
762 static int
763 rpc_fill_super(struct super_block *sb, void *data, int silent)
765 struct inode *inode;
766 struct dentry *root;
768 sb->s_blocksize = PAGE_CACHE_SIZE;
769 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
770 sb->s_magic = RPCAUTH_GSSMAGIC;
771 sb->s_op = &s_ops;
772 sb->s_time_gran = 1;
774 inode = rpc_get_inode(sb, S_IFDIR | 0755);
775 if (!inode)
776 return -ENOMEM;
777 root = d_alloc_root(inode);
778 if (!root) {
779 iput(inode);
780 return -ENOMEM;
782 if (rpc_populate(root, files, RPCAUTH_Root + 1, RPCAUTH_RootEOF))
783 goto out;
784 sb->s_root = root;
785 return 0;
786 out:
787 d_genocide(root);
788 dput(root);
789 return -ENOMEM;
792 static struct super_block *
793 rpc_get_sb(struct file_system_type *fs_type,
794 int flags, const char *dev_name, void *data)
796 return get_sb_single(fs_type, flags, data, rpc_fill_super);
799 static struct file_system_type rpc_pipe_fs_type = {
800 .owner = THIS_MODULE,
801 .name = "rpc_pipefs",
802 .get_sb = rpc_get_sb,
803 .kill_sb = kill_litter_super,
806 static void
807 init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
809 struct rpc_inode *rpci = (struct rpc_inode *) foo;
811 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
812 SLAB_CTOR_CONSTRUCTOR) {
813 inode_init_once(&rpci->vfs_inode);
814 rpci->private = NULL;
815 rpci->nreaders = 0;
816 rpci->nwriters = 0;
817 INIT_LIST_HEAD(&rpci->in_upcall);
818 INIT_LIST_HEAD(&rpci->pipe);
819 rpci->pipelen = 0;
820 init_waitqueue_head(&rpci->waitq);
821 INIT_WORK(&rpci->queue_timeout, rpc_timeout_upcall_queue, rpci);
822 rpci->ops = NULL;
826 int register_rpc_pipefs(void)
828 rpc_inode_cachep = kmem_cache_create("rpc_inode_cache",
829 sizeof(struct rpc_inode),
830 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
831 init_once, NULL);
832 if (!rpc_inode_cachep)
833 return -ENOMEM;
834 register_filesystem(&rpc_pipe_fs_type);
835 return 0;
838 void unregister_rpc_pipefs(void)
840 if (kmem_cache_destroy(rpc_inode_cachep))
841 printk(KERN_WARNING "RPC: unable to free inode cache\n");
842 unregister_filesystem(&rpc_pipe_fs_type);