diff options
-rw-r--r-- | arch/alpha/include/uapi/asm/fcntl.h | 2 | ||||
-rw-r--r-- | arch/parisc/include/uapi/asm/fcntl.h | 2 | ||||
-rw-r--r-- | arch/sparc/include/uapi/asm/fcntl.h | 2 | ||||
-rw-r--r-- | fs/configfs/dir.c | 13 | ||||
-rw-r--r-- | fs/efivarfs/inode.c | 14 | ||||
-rw-r--r-- | fs/file_table.c | 31 | ||||
-rw-r--r-- | fs/libfs.c | 3 | ||||
-rw-r--r-- | fs/namei.c | 2 | ||||
-rw-r--r-- | fs/open.c | 4 | ||||
-rw-r--r-- | include/linux/fs.h | 2 | ||||
-rw-r--r-- | include/linux/llist.h | 19 | ||||
-rw-r--r-- | include/linux/sunrpc/rpc_pipe_fs.h | 4 | ||||
-rw-r--r-- | include/uapi/asm-generic/fcntl.h | 8 | ||||
-rw-r--r-- | kernel/cgroup.c | 11 | ||||
-rw-r--r-- | lib/llist.c | 15 | ||||
-rw-r--r-- | net/sunrpc/cache.c | 18 | ||||
-rw-r--r-- | net/sunrpc/clnt.c | 20 | ||||
-rw-r--r-- | net/sunrpc/rpc_pipe.c | 40 |
18 files changed, 73 insertions, 137 deletions
diff --git a/arch/alpha/include/uapi/asm/fcntl.h b/arch/alpha/include/uapi/asm/fcntl.h index dfdadb0b4bef..09f49a6b87d1 100644 --- a/arch/alpha/include/uapi/asm/fcntl.h +++ b/arch/alpha/include/uapi/asm/fcntl.h | |||
@@ -32,7 +32,7 @@ | |||
32 | #define O_SYNC (__O_SYNC|O_DSYNC) | 32 | #define O_SYNC (__O_SYNC|O_DSYNC) |
33 | 33 | ||
34 | #define O_PATH 040000000 | 34 | #define O_PATH 040000000 |
35 | #define O_TMPFILE 0100000000 | 35 | #define __O_TMPFILE 0100000000 |
36 | 36 | ||
37 | #define F_GETLK 7 | 37 | #define F_GETLK 7 |
38 | #define F_SETLK 8 | 38 | #define F_SETLK 8 |
diff --git a/arch/parisc/include/uapi/asm/fcntl.h b/arch/parisc/include/uapi/asm/fcntl.h index cc61c475f277..34a46cbc76ed 100644 --- a/arch/parisc/include/uapi/asm/fcntl.h +++ b/arch/parisc/include/uapi/asm/fcntl.h | |||
@@ -20,7 +20,7 @@ | |||
20 | #define O_INVISIBLE 004000000 /* invisible I/O, for DMAPI/XDSM */ | 20 | #define O_INVISIBLE 004000000 /* invisible I/O, for DMAPI/XDSM */ |
21 | 21 | ||
22 | #define O_PATH 020000000 | 22 | #define O_PATH 020000000 |
23 | #define O_TMPFILE 040000000 | 23 | #define __O_TMPFILE 040000000 |
24 | 24 | ||
25 | #define F_GETLK64 8 | 25 | #define F_GETLK64 8 |
26 | #define F_SETLK64 9 | 26 | #define F_SETLK64 9 |
diff --git a/arch/sparc/include/uapi/asm/fcntl.h b/arch/sparc/include/uapi/asm/fcntl.h index d73e5e008b0d..7e8ace5bf760 100644 --- a/arch/sparc/include/uapi/asm/fcntl.h +++ b/arch/sparc/include/uapi/asm/fcntl.h | |||
@@ -35,7 +35,7 @@ | |||
35 | #define O_SYNC (__O_SYNC|O_DSYNC) | 35 | #define O_SYNC (__O_SYNC|O_DSYNC) |
36 | 36 | ||
37 | #define O_PATH 0x1000000 | 37 | #define O_PATH 0x1000000 |
38 | #define O_TMPFILE 0x2000000 | 38 | #define __O_TMPFILE 0x2000000 |
39 | 39 | ||
40 | #define F_GETOWN 5 /* for sockets. */ | 40 | #define F_GETOWN 5 /* for sockets. */ |
41 | #define F_SETOWN 6 /* for sockets. */ | 41 | #define F_SETOWN 6 /* for sockets. */ |
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index 5e7c60c1cb63..277bd1be21fd 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c | |||
@@ -660,19 +660,15 @@ static int create_default_group(struct config_group *parent_group, | |||
660 | struct config_group *group) | 660 | struct config_group *group) |
661 | { | 661 | { |
662 | int ret; | 662 | int ret; |
663 | struct qstr name; | ||
664 | struct configfs_dirent *sd; | 663 | struct configfs_dirent *sd; |
665 | /* We trust the caller holds a reference to parent */ | 664 | /* We trust the caller holds a reference to parent */ |
666 | struct dentry *child, *parent = parent_group->cg_item.ci_dentry; | 665 | struct dentry *child, *parent = parent_group->cg_item.ci_dentry; |
667 | 666 | ||
668 | if (!group->cg_item.ci_name) | 667 | if (!group->cg_item.ci_name) |
669 | group->cg_item.ci_name = group->cg_item.ci_namebuf; | 668 | group->cg_item.ci_name = group->cg_item.ci_namebuf; |
670 | name.name = group->cg_item.ci_name; | ||
671 | name.len = strlen(name.name); | ||
672 | name.hash = full_name_hash(name.name, name.len); | ||
673 | 669 | ||
674 | ret = -ENOMEM; | 670 | ret = -ENOMEM; |
675 | child = d_alloc(parent, &name); | 671 | child = d_alloc_name(parent, group->cg_item.ci_name); |
676 | if (child) { | 672 | if (child) { |
677 | d_add(child, NULL); | 673 | d_add(child, NULL); |
678 | 674 | ||
@@ -1650,7 +1646,6 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys) | |||
1650 | { | 1646 | { |
1651 | int err; | 1647 | int err; |
1652 | struct config_group *group = &subsys->su_group; | 1648 | struct config_group *group = &subsys->su_group; |
1653 | struct qstr name; | ||
1654 | struct dentry *dentry; | 1649 | struct dentry *dentry; |
1655 | struct dentry *root; | 1650 | struct dentry *root; |
1656 | struct configfs_dirent *sd; | 1651 | struct configfs_dirent *sd; |
@@ -1667,12 +1662,8 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys) | |||
1667 | 1662 | ||
1668 | mutex_lock_nested(&root->d_inode->i_mutex, I_MUTEX_PARENT); | 1663 | mutex_lock_nested(&root->d_inode->i_mutex, I_MUTEX_PARENT); |
1669 | 1664 | ||
1670 | name.name = group->cg_item.ci_name; | ||
1671 | name.len = strlen(name.name); | ||
1672 | name.hash = full_name_hash(name.name, name.len); | ||
1673 | |||
1674 | err = -ENOMEM; | 1665 | err = -ENOMEM; |
1675 | dentry = d_alloc(root, &name); | 1666 | dentry = d_alloc_name(root, group->cg_item.ci_name); |
1676 | if (dentry) { | 1667 | if (dentry) { |
1677 | d_add(dentry, NULL); | 1668 | d_add(dentry, NULL); |
1678 | 1669 | ||
diff --git a/fs/efivarfs/inode.c b/fs/efivarfs/inode.c index 7e787fb90293..07ab49745e31 100644 --- a/fs/efivarfs/inode.c +++ b/fs/efivarfs/inode.c | |||
@@ -155,20 +155,8 @@ static int efivarfs_unlink(struct inode *dir, struct dentry *dentry) | |||
155 | return 0; | 155 | return 0; |
156 | }; | 156 | }; |
157 | 157 | ||
158 | /* | ||
159 | * Handle negative dentry. | ||
160 | */ | ||
161 | static struct dentry *efivarfs_lookup(struct inode *dir, struct dentry *dentry, | ||
162 | unsigned int flags) | ||
163 | { | ||
164 | if (dentry->d_name.len > NAME_MAX) | ||
165 | return ERR_PTR(-ENAMETOOLONG); | ||
166 | d_add(dentry, NULL); | ||
167 | return NULL; | ||
168 | } | ||
169 | |||
170 | const struct inode_operations efivarfs_dir_inode_operations = { | 158 | const struct inode_operations efivarfs_dir_inode_operations = { |
171 | .lookup = efivarfs_lookup, | 159 | .lookup = simple_lookup, |
172 | .unlink = efivarfs_unlink, | 160 | .unlink = efivarfs_unlink, |
173 | .create = efivarfs_create, | 161 | .create = efivarfs_create, |
174 | }; | 162 | }; |
diff --git a/fs/file_table.c b/fs/file_table.c index 08e719b884ca..b44e4c559786 100644 --- a/fs/file_table.c +++ b/fs/file_table.c | |||
@@ -265,18 +265,15 @@ static void __fput(struct file *file) | |||
265 | mntput(mnt); | 265 | mntput(mnt); |
266 | } | 266 | } |
267 | 267 | ||
268 | static DEFINE_SPINLOCK(delayed_fput_lock); | 268 | static LLIST_HEAD(delayed_fput_list); |
269 | static LIST_HEAD(delayed_fput_list); | ||
270 | static void delayed_fput(struct work_struct *unused) | 269 | static void delayed_fput(struct work_struct *unused) |
271 | { | 270 | { |
272 | LIST_HEAD(head); | 271 | struct llist_node *node = llist_del_all(&delayed_fput_list); |
273 | spin_lock_irq(&delayed_fput_lock); | 272 | struct llist_node *next; |
274 | list_splice_init(&delayed_fput_list, &head); | 273 | |
275 | spin_unlock_irq(&delayed_fput_lock); | 274 | for (; node; node = next) { |
276 | while (!list_empty(&head)) { | 275 | next = llist_next(node); |
277 | struct file *f = list_first_entry(&head, struct file, f_u.fu_list); | 276 | __fput(llist_entry(node, struct file, f_u.fu_llist)); |
278 | list_del_init(&f->f_u.fu_list); | ||
279 | __fput(f); | ||
280 | } | 277 | } |
281 | } | 278 | } |
282 | 279 | ||
@@ -306,18 +303,22 @@ void fput(struct file *file) | |||
306 | { | 303 | { |
307 | if (atomic_long_dec_and_test(&file->f_count)) { | 304 | if (atomic_long_dec_and_test(&file->f_count)) { |
308 | struct task_struct *task = current; | 305 | struct task_struct *task = current; |
309 | unsigned long flags; | ||
310 | 306 | ||
311 | file_sb_list_del(file); | 307 | file_sb_list_del(file); |
312 | if (likely(!in_interrupt() && !(task->flags & PF_KTHREAD))) { | 308 | if (likely(!in_interrupt() && !(task->flags & PF_KTHREAD))) { |
313 | init_task_work(&file->f_u.fu_rcuhead, ____fput); | 309 | init_task_work(&file->f_u.fu_rcuhead, ____fput); |
314 | if (!task_work_add(task, &file->f_u.fu_rcuhead, true)) | 310 | if (!task_work_add(task, &file->f_u.fu_rcuhead, true)) |
315 | return; | 311 | return; |
312 | /* | ||
313 | * After this task has run exit_task_work(), | ||
314 | * task_work_add() will fail. free_ipc_ns()-> | ||
315 | * shm_destroy() can do this. Fall through to delayed | ||
316 | * fput to avoid leaking *file. | ||
317 | */ | ||
316 | } | 318 | } |
317 | spin_lock_irqsave(&delayed_fput_lock, flags); | 319 | |
318 | list_add(&file->f_u.fu_list, &delayed_fput_list); | 320 | if (llist_add(&file->f_u.fu_llist, &delayed_fput_list)) |
319 | schedule_work(&delayed_fput_work); | 321 | schedule_work(&delayed_fput_work); |
320 | spin_unlock_irqrestore(&delayed_fput_lock, flags); | ||
321 | } | 322 | } |
322 | } | 323 | } |
323 | 324 | ||
diff --git a/fs/libfs.c b/fs/libfs.c index c3a0837fb861..3a3a9b53bf5a 100644 --- a/fs/libfs.c +++ b/fs/libfs.c | |||
@@ -61,7 +61,8 @@ struct dentry *simple_lookup(struct inode *dir, struct dentry *dentry, unsigned | |||
61 | 61 | ||
62 | if (dentry->d_name.len > NAME_MAX) | 62 | if (dentry->d_name.len > NAME_MAX) |
63 | return ERR_PTR(-ENAMETOOLONG); | 63 | return ERR_PTR(-ENAMETOOLONG); |
64 | d_set_d_op(dentry, &simple_dentry_operations); | 64 | if (!dentry->d_sb->s_d_op) |
65 | d_set_d_op(dentry, &simple_dentry_operations); | ||
65 | d_add(dentry, NULL); | 66 | d_add(dentry, NULL); |
66 | return NULL; | 67 | return NULL; |
67 | } | 68 | } |
diff --git a/fs/namei.c b/fs/namei.c index b2beee7a733f..8b61d103a8a7 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -2977,7 +2977,7 @@ static struct file *path_openat(int dfd, struct filename *pathname, | |||
2977 | 2977 | ||
2978 | file->f_flags = op->open_flag; | 2978 | file->f_flags = op->open_flag; |
2979 | 2979 | ||
2980 | if (unlikely(file->f_flags & O_TMPFILE)) { | 2980 | if (unlikely(file->f_flags & __O_TMPFILE)) { |
2981 | error = do_tmpfile(dfd, pathname, nd, flags, op, file, &opened); | 2981 | error = do_tmpfile(dfd, pathname, nd, flags, op, file, &opened); |
2982 | goto out; | 2982 | goto out; |
2983 | } | 2983 | } |
@@ -840,8 +840,8 @@ static inline int build_open_flags(int flags, umode_t mode, struct open_flags *o | |||
840 | if (flags & __O_SYNC) | 840 | if (flags & __O_SYNC) |
841 | flags |= O_DSYNC; | 841 | flags |= O_DSYNC; |
842 | 842 | ||
843 | if (flags & O_TMPFILE) { | 843 | if (flags & __O_TMPFILE) { |
844 | if (!(flags & O_CREAT)) | 844 | if ((flags & O_TMPFILE_MASK) != O_TMPFILE) |
845 | return -EINVAL; | 845 | return -EINVAL; |
846 | acc_mode = MAY_OPEN | ACC_MODE(flags); | 846 | acc_mode = MAY_OPEN | ACC_MODE(flags); |
847 | } else if (flags & O_PATH) { | 847 | } else if (flags & O_PATH) { |
diff --git a/include/linux/fs.h b/include/linux/fs.h index a35b10e9a680..981874773e85 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/stat.h> | 10 | #include <linux/stat.h> |
11 | #include <linux/cache.h> | 11 | #include <linux/cache.h> |
12 | #include <linux/list.h> | 12 | #include <linux/list.h> |
13 | #include <linux/llist.h> | ||
13 | #include <linux/radix-tree.h> | 14 | #include <linux/radix-tree.h> |
14 | #include <linux/rbtree.h> | 15 | #include <linux/rbtree.h> |
15 | #include <linux/init.h> | 16 | #include <linux/init.h> |
@@ -768,6 +769,7 @@ struct file { | |||
768 | */ | 769 | */ |
769 | union { | 770 | union { |
770 | struct list_head fu_list; | 771 | struct list_head fu_list; |
772 | struct llist_node fu_llist; | ||
771 | struct rcu_head fu_rcuhead; | 773 | struct rcu_head fu_rcuhead; |
772 | } f_u; | 774 | } f_u; |
773 | struct path f_path; | 775 | struct path f_path; |
diff --git a/include/linux/llist.h b/include/linux/llist.h index a5199f6d0e82..cdaa7f023899 100644 --- a/include/linux/llist.h +++ b/include/linux/llist.h | |||
@@ -142,6 +142,9 @@ static inline struct llist_node *llist_next(struct llist_node *node) | |||
142 | return node->next; | 142 | return node->next; |
143 | } | 143 | } |
144 | 144 | ||
145 | extern bool llist_add_batch(struct llist_node *new_first, | ||
146 | struct llist_node *new_last, | ||
147 | struct llist_head *head); | ||
145 | /** | 148 | /** |
146 | * llist_add - add a new entry | 149 | * llist_add - add a new entry |
147 | * @new: new entry to be added | 150 | * @new: new entry to be added |
@@ -151,18 +154,7 @@ static inline struct llist_node *llist_next(struct llist_node *node) | |||
151 | */ | 154 | */ |
152 | static inline bool llist_add(struct llist_node *new, struct llist_head *head) | 155 | static inline bool llist_add(struct llist_node *new, struct llist_head *head) |
153 | { | 156 | { |
154 | struct llist_node *entry, *old_entry; | 157 | return llist_add_batch(new, new, head); |
155 | |||
156 | entry = head->first; | ||
157 | for (;;) { | ||
158 | old_entry = entry; | ||
159 | new->next = entry; | ||
160 | entry = cmpxchg(&head->first, old_entry, new); | ||
161 | if (entry == old_entry) | ||
162 | break; | ||
163 | } | ||
164 | |||
165 | return old_entry == NULL; | ||
166 | } | 158 | } |
167 | 159 | ||
168 | /** | 160 | /** |
@@ -178,9 +170,6 @@ static inline struct llist_node *llist_del_all(struct llist_head *head) | |||
178 | return xchg(&head->first, NULL); | 170 | return xchg(&head->first, NULL); |
179 | } | 171 | } |
180 | 172 | ||
181 | extern bool llist_add_batch(struct llist_node *new_first, | ||
182 | struct llist_node *new_last, | ||
183 | struct llist_head *head); | ||
184 | extern struct llist_node *llist_del_first(struct llist_head *head); | 173 | extern struct llist_node *llist_del_first(struct llist_head *head); |
185 | 174 | ||
186 | #endif /* LLIST_H */ | 175 | #endif /* LLIST_H */ |
diff --git a/include/linux/sunrpc/rpc_pipe_fs.h b/include/linux/sunrpc/rpc_pipe_fs.h index a7b422b33eda..aa5b582cc471 100644 --- a/include/linux/sunrpc/rpc_pipe_fs.h +++ b/include/linux/sunrpc/rpc_pipe_fs.h | |||
@@ -73,12 +73,12 @@ extern ssize_t rpc_pipe_generic_upcall(struct file *, struct rpc_pipe_msg *, | |||
73 | extern int rpc_queue_upcall(struct rpc_pipe *, struct rpc_pipe_msg *); | 73 | extern int rpc_queue_upcall(struct rpc_pipe *, struct rpc_pipe_msg *); |
74 | 74 | ||
75 | struct rpc_clnt; | 75 | struct rpc_clnt; |
76 | extern struct dentry *rpc_create_client_dir(struct dentry *, struct qstr *, struct rpc_clnt *); | 76 | extern struct dentry *rpc_create_client_dir(struct dentry *, const char *, struct rpc_clnt *); |
77 | extern int rpc_remove_client_dir(struct dentry *); | 77 | extern int rpc_remove_client_dir(struct dentry *); |
78 | 78 | ||
79 | struct cache_detail; | 79 | struct cache_detail; |
80 | extern struct dentry *rpc_create_cache_dir(struct dentry *, | 80 | extern struct dentry *rpc_create_cache_dir(struct dentry *, |
81 | struct qstr *, | 81 | const char *, |
82 | umode_t umode, | 82 | umode_t umode, |
83 | struct cache_detail *); | 83 | struct cache_detail *); |
84 | extern void rpc_remove_cache_dir(struct dentry *); | 84 | extern void rpc_remove_cache_dir(struct dentry *); |
diff --git a/include/uapi/asm-generic/fcntl.h b/include/uapi/asm-generic/fcntl.h index 06632beaa6d5..05ac354e124d 100644 --- a/include/uapi/asm-generic/fcntl.h +++ b/include/uapi/asm-generic/fcntl.h | |||
@@ -84,10 +84,14 @@ | |||
84 | #define O_PATH 010000000 | 84 | #define O_PATH 010000000 |
85 | #endif | 85 | #endif |
86 | 86 | ||
87 | #ifndef O_TMPFILE | 87 | #ifndef __O_TMPFILE |
88 | #define O_TMPFILE 020000000 | 88 | #define __O_TMPFILE 020000000 |
89 | #endif | 89 | #endif |
90 | 90 | ||
91 | /* a horrid kludge trying to make sure that this will fail on old kernels */ | ||
92 | #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY | O_RDWR) | ||
93 | #define O_TMPFILE_MASK (__O_TMPFILE | O_DIRECTORY | O_CREAT | O_ACCMODE) | ||
94 | |||
91 | #ifndef O_NDELAY | 95 | #ifndef O_NDELAY |
92 | #define O_NDELAY O_NONBLOCK | 96 | #define O_NDELAY O_NONBLOCK |
93 | #endif | 97 | #endif |
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index e5583d10a325..0e0b20b8c5db 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -802,7 +802,6 @@ static struct cgroup *task_cgroup_from_root(struct task_struct *task, | |||
802 | */ | 802 | */ |
803 | 803 | ||
804 | static int cgroup_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode); | 804 | static int cgroup_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode); |
805 | static struct dentry *cgroup_lookup(struct inode *, struct dentry *, unsigned int); | ||
806 | static int cgroup_rmdir(struct inode *unused_dir, struct dentry *dentry); | 805 | static int cgroup_rmdir(struct inode *unused_dir, struct dentry *dentry); |
807 | static int cgroup_populate_dir(struct cgroup *cgrp, bool base_files, | 806 | static int cgroup_populate_dir(struct cgroup *cgrp, bool base_files, |
808 | unsigned long subsys_mask); | 807 | unsigned long subsys_mask); |
@@ -2642,7 +2641,7 @@ static const struct inode_operations cgroup_file_inode_operations = { | |||
2642 | }; | 2641 | }; |
2643 | 2642 | ||
2644 | static const struct inode_operations cgroup_dir_inode_operations = { | 2643 | static const struct inode_operations cgroup_dir_inode_operations = { |
2645 | .lookup = cgroup_lookup, | 2644 | .lookup = simple_lookup, |
2646 | .mkdir = cgroup_mkdir, | 2645 | .mkdir = cgroup_mkdir, |
2647 | .rmdir = cgroup_rmdir, | 2646 | .rmdir = cgroup_rmdir, |
2648 | .rename = cgroup_rename, | 2647 | .rename = cgroup_rename, |
@@ -2652,14 +2651,6 @@ static const struct inode_operations cgroup_dir_inode_operations = { | |||
2652 | .removexattr = cgroup_removexattr, | 2651 | .removexattr = cgroup_removexattr, |
2653 | }; | 2652 | }; |
2654 | 2653 | ||
2655 | static struct dentry *cgroup_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) | ||
2656 | { | ||
2657 | if (dentry->d_name.len > NAME_MAX) | ||
2658 | return ERR_PTR(-ENAMETOOLONG); | ||
2659 | d_add(dentry, NULL); | ||
2660 | return NULL; | ||
2661 | } | ||
2662 | |||
2663 | /* | 2654 | /* |
2664 | * Check if a file is a control file | 2655 | * Check if a file is a control file |
2665 | */ | 2656 | */ |
diff --git a/lib/llist.c b/lib/llist.c index 4a15115e90f8..4a70d120138c 100644 --- a/lib/llist.c +++ b/lib/llist.c | |||
@@ -39,18 +39,13 @@ | |||
39 | bool llist_add_batch(struct llist_node *new_first, struct llist_node *new_last, | 39 | bool llist_add_batch(struct llist_node *new_first, struct llist_node *new_last, |
40 | struct llist_head *head) | 40 | struct llist_head *head) |
41 | { | 41 | { |
42 | struct llist_node *entry, *old_entry; | 42 | struct llist_node *first; |
43 | 43 | ||
44 | entry = head->first; | 44 | do { |
45 | for (;;) { | 45 | new_last->next = first = ACCESS_ONCE(head->first); |
46 | old_entry = entry; | 46 | } while (cmpxchg(&head->first, first, new_first) != first); |
47 | new_last->next = entry; | ||
48 | entry = cmpxchg(&head->first, old_entry, new_first); | ||
49 | if (entry == old_entry) | ||
50 | break; | ||
51 | } | ||
52 | 47 | ||
53 | return old_entry == NULL; | 48 | return !first; |
54 | } | 49 | } |
55 | EXPORT_SYMBOL_GPL(llist_add_batch); | 50 | EXPORT_SYMBOL_GPL(llist_add_batch); |
56 | 51 | ||
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index 49eb37010aa3..a72de074172d 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c | |||
@@ -1823,19 +1823,11 @@ int sunrpc_cache_register_pipefs(struct dentry *parent, | |||
1823 | const char *name, umode_t umode, | 1823 | const char *name, umode_t umode, |
1824 | struct cache_detail *cd) | 1824 | struct cache_detail *cd) |
1825 | { | 1825 | { |
1826 | struct qstr q; | 1826 | struct dentry *dir = rpc_create_cache_dir(parent, name, umode, cd); |
1827 | struct dentry *dir; | 1827 | if (IS_ERR(dir)) |
1828 | int ret = 0; | 1828 | return PTR_ERR(dir); |
1829 | 1829 | cd->u.pipefs.dir = dir; | |
1830 | q.name = name; | 1830 | return 0; |
1831 | q.len = strlen(name); | ||
1832 | q.hash = full_name_hash(q.name, q.len); | ||
1833 | dir = rpc_create_cache_dir(parent, &q, umode, cd); | ||
1834 | if (!IS_ERR(dir)) | ||
1835 | cd->u.pipefs.dir = dir; | ||
1836 | else | ||
1837 | ret = PTR_ERR(dir); | ||
1838 | return ret; | ||
1839 | } | 1831 | } |
1840 | EXPORT_SYMBOL_GPL(sunrpc_cache_register_pipefs); | 1832 | EXPORT_SYMBOL_GPL(sunrpc_cache_register_pipefs); |
1841 | 1833 | ||
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index aa401560777b..9963584605c0 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c | |||
@@ -128,9 +128,7 @@ static struct dentry *rpc_setup_pipedir_sb(struct super_block *sb, | |||
128 | { | 128 | { |
129 | static uint32_t clntid; | 129 | static uint32_t clntid; |
130 | char name[15]; | 130 | char name[15]; |
131 | struct qstr q = { .name = name }; | ||
132 | struct dentry *dir, *dentry; | 131 | struct dentry *dir, *dentry; |
133 | int error; | ||
134 | 132 | ||
135 | dir = rpc_d_lookup_sb(sb, dir_name); | 133 | dir = rpc_d_lookup_sb(sb, dir_name); |
136 | if (dir == NULL) { | 134 | if (dir == NULL) { |
@@ -138,19 +136,17 @@ static struct dentry *rpc_setup_pipedir_sb(struct super_block *sb, | |||
138 | return dir; | 136 | return dir; |
139 | } | 137 | } |
140 | for (;;) { | 138 | for (;;) { |
141 | q.len = snprintf(name, sizeof(name), "clnt%x", (unsigned int)clntid++); | 139 | snprintf(name, sizeof(name), "clnt%x", (unsigned int)clntid++); |
142 | name[sizeof(name) - 1] = '\0'; | 140 | name[sizeof(name) - 1] = '\0'; |
143 | q.hash = full_name_hash(q.name, q.len); | 141 | dentry = rpc_create_client_dir(dir, name, clnt); |
144 | dentry = rpc_create_client_dir(dir, &q, clnt); | ||
145 | if (!IS_ERR(dentry)) | 142 | if (!IS_ERR(dentry)) |
146 | break; | 143 | break; |
147 | error = PTR_ERR(dentry); | 144 | if (dentry == ERR_PTR(-EEXIST)) |
148 | if (error != -EEXIST) { | 145 | continue; |
149 | printk(KERN_INFO "RPC: Couldn't create pipefs entry" | 146 | printk(KERN_INFO "RPC: Couldn't create pipefs entry" |
150 | " %s/%s, error %d\n", | 147 | " %s/%s, error %ld\n", |
151 | dir_name, name, error); | 148 | dir_name, name, PTR_ERR(dentry)); |
152 | break; | 149 | break; |
153 | } | ||
154 | } | 150 | } |
155 | dput(dir); | 151 | dput(dir); |
156 | return dentry; | 152 | return dentry; |
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index 61239a2cb786..406859cc68aa 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c | |||
@@ -673,13 +673,12 @@ static int __rpc_rmpipe(struct inode *dir, struct dentry *dentry) | |||
673 | } | 673 | } |
674 | 674 | ||
675 | static struct dentry *__rpc_lookup_create_exclusive(struct dentry *parent, | 675 | static struct dentry *__rpc_lookup_create_exclusive(struct dentry *parent, |
676 | struct qstr *name) | 676 | const char *name) |
677 | { | 677 | { |
678 | struct dentry *dentry; | 678 | struct qstr q = QSTR_INIT(name, strlen(name)); |
679 | 679 | struct dentry *dentry = d_hash_and_lookup(parent, &q); | |
680 | dentry = d_lookup(parent, name); | ||
681 | if (!dentry) { | 680 | if (!dentry) { |
682 | dentry = d_alloc(parent, name); | 681 | dentry = d_alloc(parent, &q); |
683 | if (!dentry) | 682 | if (!dentry) |
684 | return ERR_PTR(-ENOMEM); | 683 | return ERR_PTR(-ENOMEM); |
685 | } | 684 | } |
@@ -704,8 +703,7 @@ static void __rpc_depopulate(struct dentry *parent, | |||
704 | for (i = start; i < eof; i++) { | 703 | for (i = start; i < eof; i++) { |
705 | name.name = files[i].name; | 704 | name.name = files[i].name; |
706 | name.len = strlen(files[i].name); | 705 | name.len = strlen(files[i].name); |
707 | name.hash = full_name_hash(name.name, name.len); | 706 | dentry = d_hash_and_lookup(parent, &name); |
708 | dentry = d_lookup(parent, &name); | ||
709 | 707 | ||
710 | if (dentry == NULL) | 708 | if (dentry == NULL) |
711 | continue; | 709 | continue; |
@@ -747,12 +745,7 @@ static int rpc_populate(struct dentry *parent, | |||
747 | 745 | ||
748 | mutex_lock(&dir->i_mutex); | 746 | mutex_lock(&dir->i_mutex); |
749 | for (i = start; i < eof; i++) { | 747 | for (i = start; i < eof; i++) { |
750 | struct qstr q; | 748 | dentry = __rpc_lookup_create_exclusive(parent, files[i].name); |
751 | |||
752 | q.name = files[i].name; | ||
753 | q.len = strlen(files[i].name); | ||
754 | q.hash = full_name_hash(q.name, q.len); | ||
755 | dentry = __rpc_lookup_create_exclusive(parent, &q); | ||
756 | err = PTR_ERR(dentry); | 749 | err = PTR_ERR(dentry); |
757 | if (IS_ERR(dentry)) | 750 | if (IS_ERR(dentry)) |
758 | goto out_bad; | 751 | goto out_bad; |
@@ -785,7 +778,7 @@ out_bad: | |||
785 | } | 778 | } |
786 | 779 | ||
787 | static struct dentry *rpc_mkdir_populate(struct dentry *parent, | 780 | static struct dentry *rpc_mkdir_populate(struct dentry *parent, |
788 | struct qstr *name, umode_t mode, void *private, | 781 | const char *name, umode_t mode, void *private, |
789 | int (*populate)(struct dentry *, void *), void *args_populate) | 782 | int (*populate)(struct dentry *, void *), void *args_populate) |
790 | { | 783 | { |
791 | struct dentry *dentry; | 784 | struct dentry *dentry; |
@@ -856,7 +849,6 @@ struct dentry *rpc_mkpipe_dentry(struct dentry *parent, const char *name, | |||
856 | struct dentry *dentry; | 849 | struct dentry *dentry; |
857 | struct inode *dir = parent->d_inode; | 850 | struct inode *dir = parent->d_inode; |
858 | umode_t umode = S_IFIFO | S_IRUSR | S_IWUSR; | 851 | umode_t umode = S_IFIFO | S_IRUSR | S_IWUSR; |
859 | struct qstr q; | ||
860 | int err; | 852 | int err; |
861 | 853 | ||
862 | if (pipe->ops->upcall == NULL) | 854 | if (pipe->ops->upcall == NULL) |
@@ -864,12 +856,8 @@ struct dentry *rpc_mkpipe_dentry(struct dentry *parent, const char *name, | |||
864 | if (pipe->ops->downcall == NULL) | 856 | if (pipe->ops->downcall == NULL) |
865 | umode &= ~S_IWUGO; | 857 | umode &= ~S_IWUGO; |
866 | 858 | ||
867 | q.name = name; | ||
868 | q.len = strlen(name); | ||
869 | q.hash = full_name_hash(q.name, q.len), | ||
870 | |||
871 | mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); | 859 | mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); |
872 | dentry = __rpc_lookup_create_exclusive(parent, &q); | 860 | dentry = __rpc_lookup_create_exclusive(parent, name); |
873 | if (IS_ERR(dentry)) | 861 | if (IS_ERR(dentry)) |
874 | goto out; | 862 | goto out; |
875 | err = __rpc_mkpipe_dentry(dir, dentry, umode, &rpc_pipe_fops, | 863 | err = __rpc_mkpipe_dentry(dir, dentry, umode, &rpc_pipe_fops, |
@@ -940,8 +928,8 @@ static void rpc_clntdir_depopulate(struct dentry *dentry) | |||
940 | 928 | ||
941 | /** | 929 | /** |
942 | * rpc_create_client_dir - Create a new rpc_client directory in rpc_pipefs | 930 | * rpc_create_client_dir - Create a new rpc_client directory in rpc_pipefs |
943 | * @dentry: dentry from the rpc_pipefs root to the new directory | 931 | * @dentry: the parent of new directory |
944 | * @name: &struct qstr for the name | 932 | * @name: the name of new directory |
945 | * @rpc_client: rpc client to associate with this directory | 933 | * @rpc_client: rpc client to associate with this directory |
946 | * | 934 | * |
947 | * This creates a directory at the given @path associated with | 935 | * This creates a directory at the given @path associated with |
@@ -950,7 +938,7 @@ static void rpc_clntdir_depopulate(struct dentry *dentry) | |||
950 | * later be created using rpc_mkpipe(). | 938 | * later be created using rpc_mkpipe(). |
951 | */ | 939 | */ |
952 | struct dentry *rpc_create_client_dir(struct dentry *dentry, | 940 | struct dentry *rpc_create_client_dir(struct dentry *dentry, |
953 | struct qstr *name, | 941 | const char *name, |
954 | struct rpc_clnt *rpc_client) | 942 | struct rpc_clnt *rpc_client) |
955 | { | 943 | { |
956 | return rpc_mkdir_populate(dentry, name, S_IRUGO | S_IXUGO, NULL, | 944 | return rpc_mkdir_populate(dentry, name, S_IRUGO | S_IXUGO, NULL, |
@@ -996,7 +984,7 @@ static void rpc_cachedir_depopulate(struct dentry *dentry) | |||
996 | rpc_depopulate(dentry, cache_pipefs_files, 0, 3); | 984 | rpc_depopulate(dentry, cache_pipefs_files, 0, 3); |
997 | } | 985 | } |
998 | 986 | ||
999 | struct dentry *rpc_create_cache_dir(struct dentry *parent, struct qstr *name, | 987 | struct dentry *rpc_create_cache_dir(struct dentry *parent, const char *name, |
1000 | umode_t umode, struct cache_detail *cd) | 988 | umode_t umode, struct cache_detail *cd) |
1001 | { | 989 | { |
1002 | return rpc_mkdir_populate(parent, name, umode, NULL, | 990 | return rpc_mkdir_populate(parent, name, umode, NULL, |
@@ -1076,9 +1064,7 @@ struct dentry *rpc_d_lookup_sb(const struct super_block *sb, | |||
1076 | const unsigned char *dir_name) | 1064 | const unsigned char *dir_name) |
1077 | { | 1065 | { |
1078 | struct qstr dir = QSTR_INIT(dir_name, strlen(dir_name)); | 1066 | struct qstr dir = QSTR_INIT(dir_name, strlen(dir_name)); |
1079 | 1067 | return d_hash_and_lookup(sb->s_root, &dir); | |
1080 | dir.hash = full_name_hash(dir.name, dir.len); | ||
1081 | return d_lookup(sb->s_root, &dir); | ||
1082 | } | 1068 | } |
1083 | EXPORT_SYMBOL_GPL(rpc_d_lookup_sb); | 1069 | EXPORT_SYMBOL_GPL(rpc_d_lookup_sb); |
1084 | 1070 | ||