proc_fill_cache(): switch to d_alloc_parallel()
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 20 Apr 2016 20:31:31 +0000 (16:31 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 2 May 2016 23:49:29 +0000 (19:49 -0400)
... making it usable with directory locked shared

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/proc/base.c

index b1755b23893e5e34513582d51d7a9cf9ed6b7227..15b60f1a346def8edc7fac4f13962b3ab13968f5 100644 (file)
@@ -1819,12 +1819,17 @@ bool proc_fill_cache(struct file *file, struct dir_context *ctx,
 
        child = d_hash_and_lookup(dir, &qname);
        if (!child) {
-               child = d_alloc(dir, &qname);
-               if (!child)
-                       goto end_instantiate;
-               if (instantiate(d_inode(dir), child, task, ptr) < 0) {
-                       dput(child);
+               DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
+               child = d_alloc_parallel(dir, &qname, &wq);
+               if (IS_ERR(child))
                        goto end_instantiate;
+               if (d_in_lookup(child)) {
+                       int err = instantiate(d_inode(dir), child, task, ptr);
+                       d_lookup_done(child);
+                       if (err < 0) {
+                               dput(child);
+                               goto end_instantiate;
+                       }
                }
        }
        inode = d_inode(child);