aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/rpc_pipe.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /net/sunrpc/rpc_pipe.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'net/sunrpc/rpc_pipe.c')
-rw-r--r--net/sunrpc/rpc_pipe.c65
1 files changed, 33 insertions, 32 deletions
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 8c8eef2b8f26..72bc53683965 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -27,9 +27,8 @@
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#include <linux/sunrpc/cache.h>
30#include <linux/smp_lock.h>
31 30
32static struct vfsmount *rpc_mount __read_mostly; 31static struct vfsmount *rpc_mnt __read_mostly;
33static int rpc_mount_count; 32static int rpc_mount_count;
34 33
35static struct file_system_type rpc_pipe_fs_type; 34static struct file_system_type rpc_pipe_fs_type;
@@ -163,11 +162,19 @@ rpc_alloc_inode(struct super_block *sb)
163} 162}
164 163
165static void 164static void
166rpc_destroy_inode(struct inode *inode) 165rpc_i_callback(struct rcu_head *head)
167{ 166{
167 struct inode *inode = container_of(head, struct inode, i_rcu);
168 INIT_LIST_HEAD(&inode->i_dentry);
168 kmem_cache_free(rpc_inode_cachep, RPC_I(inode)); 169 kmem_cache_free(rpc_inode_cachep, RPC_I(inode));
169} 170}
170 171
172static void
173rpc_destroy_inode(struct inode *inode)
174{
175 call_rcu(&inode->i_rcu, rpc_i_callback);
176}
177
171static int 178static int
172rpc_pipe_open(struct inode *inode, struct file *filp) 179rpc_pipe_open(struct inode *inode, struct file *filp)
173{ 180{
@@ -204,7 +211,7 @@ rpc_pipe_release(struct inode *inode, struct file *filp)
204 mutex_lock(&inode->i_mutex); 211 mutex_lock(&inode->i_mutex);
205 if (rpci->ops == NULL) 212 if (rpci->ops == NULL)
206 goto out; 213 goto out;
207 msg = (struct rpc_pipe_msg *)filp->private_data; 214 msg = filp->private_data;
208 if (msg != NULL) { 215 if (msg != NULL) {
209 spin_lock(&inode->i_lock); 216 spin_lock(&inode->i_lock);
210 msg->errno = -EAGAIN; 217 msg->errno = -EAGAIN;
@@ -309,40 +316,33 @@ rpc_pipe_poll(struct file *filp, struct poll_table_struct *wait)
309 return mask; 316 return mask;
310} 317}
311 318
312static int 319static long
313rpc_pipe_ioctl_unlocked(struct file *filp, unsigned int cmd, unsigned long arg) 320rpc_pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
314{ 321{
315 struct rpc_inode *rpci = RPC_I(filp->f_path.dentry->d_inode); 322 struct inode *inode = filp->f_path.dentry->d_inode;
323 struct rpc_inode *rpci = RPC_I(inode);
316 int len; 324 int len;
317 325
318 switch (cmd) { 326 switch (cmd) {
319 case FIONREAD: 327 case FIONREAD:
320 if (rpci->ops == NULL) 328 spin_lock(&inode->i_lock);
329 if (rpci->ops == NULL) {
330 spin_unlock(&inode->i_lock);
321 return -EPIPE; 331 return -EPIPE;
332 }
322 len = rpci->pipelen; 333 len = rpci->pipelen;
323 if (filp->private_data) { 334 if (filp->private_data) {
324 struct rpc_pipe_msg *msg; 335 struct rpc_pipe_msg *msg;
325 msg = (struct rpc_pipe_msg *)filp->private_data; 336 msg = filp->private_data;
326 len += msg->len - msg->copied; 337 len += msg->len - msg->copied;
327 } 338 }
339 spin_unlock(&inode->i_lock);
328 return put_user(len, (int __user *)arg); 340 return put_user(len, (int __user *)arg);
329 default: 341 default:
330 return -EINVAL; 342 return -EINVAL;
331 } 343 }
332} 344}
333 345
334static long
335rpc_pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
336{
337 long ret;
338
339 lock_kernel();
340 ret = rpc_pipe_ioctl_unlocked(filp, cmd, arg);
341 unlock_kernel();
342
343 return ret;
344}
345
346static const struct file_operations rpc_pipe_fops = { 346static const struct file_operations rpc_pipe_fops = {
347 .owner = THIS_MODULE, 347 .owner = THIS_MODULE,
348 .llseek = no_llseek, 348 .llseek = no_llseek,
@@ -425,20 +425,20 @@ struct vfsmount *rpc_get_mount(void)
425{ 425{
426 int err; 426 int err;
427 427
428 err = simple_pin_fs(&rpc_pipe_fs_type, &rpc_mount, &rpc_mount_count); 428 err = simple_pin_fs(&rpc_pipe_fs_type, &rpc_mnt, &rpc_mount_count);
429 if (err != 0) 429 if (err != 0)
430 return ERR_PTR(err); 430 return ERR_PTR(err);
431 return rpc_mount; 431 return rpc_mnt;
432} 432}
433EXPORT_SYMBOL_GPL(rpc_get_mount); 433EXPORT_SYMBOL_GPL(rpc_get_mount);
434 434
435void rpc_put_mount(void) 435void rpc_put_mount(void)
436{ 436{
437 simple_release_fs(&rpc_mount, &rpc_mount_count); 437 simple_release_fs(&rpc_mnt, &rpc_mount_count);
438} 438}
439EXPORT_SYMBOL_GPL(rpc_put_mount); 439EXPORT_SYMBOL_GPL(rpc_put_mount);
440 440
441static int rpc_delete_dentry(struct dentry *dentry) 441static int rpc_delete_dentry(const struct dentry *dentry)
442{ 442{
443 return 1; 443 return 1;
444} 444}
@@ -453,6 +453,7 @@ rpc_get_inode(struct super_block *sb, umode_t mode)
453 struct inode *inode = new_inode(sb); 453 struct inode *inode = new_inode(sb);
454 if (!inode) 454 if (!inode)
455 return NULL; 455 return NULL;
456 inode->i_ino = get_next_ino();
456 inode->i_mode = mode; 457 inode->i_mode = mode;
457 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 458 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
458 switch(mode & S_IFMT) { 459 switch(mode & S_IFMT) {
@@ -473,7 +474,7 @@ static int __rpc_create_common(struct inode *dir, struct dentry *dentry,
473{ 474{
474 struct inode *inode; 475 struct inode *inode;
475 476
476 BUG_ON(!d_unhashed(dentry)); 477 d_drop(dentry);
477 inode = rpc_get_inode(dir->i_sb, mode); 478 inode = rpc_get_inode(dir->i_sb, mode);
478 if (!inode) 479 if (!inode)
479 goto out_err; 480 goto out_err;
@@ -590,7 +591,7 @@ static struct dentry *__rpc_lookup_create(struct dentry *parent,
590 } 591 }
591 } 592 }
592 if (!dentry->d_inode) 593 if (!dentry->d_inode)
593 dentry->d_op = &rpc_dentry_operations; 594 d_set_d_op(dentry, &rpc_dentry_operations);
594out_err: 595out_err:
595 return dentry; 596 return dentry;
596} 597}
@@ -1025,17 +1026,17 @@ rpc_fill_super(struct super_block *sb, void *data, int silent)
1025 return 0; 1026 return 0;
1026} 1027}
1027 1028
1028static int 1029static struct dentry *
1029rpc_get_sb(struct file_system_type *fs_type, 1030rpc_mount(struct file_system_type *fs_type,
1030 int flags, const char *dev_name, void *data, struct vfsmount *mnt) 1031 int flags, const char *dev_name, void *data)
1031{ 1032{
1032 return get_sb_single(fs_type, flags, data, rpc_fill_super, mnt); 1033 return mount_single(fs_type, flags, data, rpc_fill_super);
1033} 1034}
1034 1035
1035static struct file_system_type rpc_pipe_fs_type = { 1036static struct file_system_type rpc_pipe_fs_type = {
1036 .owner = THIS_MODULE, 1037 .owner = THIS_MODULE,
1037 .name = "rpc_pipefs", 1038 .name = "rpc_pipefs",
1038 .get_sb = rpc_get_sb, 1039 .mount = rpc_mount,
1039 .kill_sb = kill_litter_super, 1040 .kill_sb = kill_litter_super,
1040}; 1041};
1041 1042