]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/sunrpc/rpc_pipe.c
SUNRPC: Teach rpc_pipe.c to use new rpc_peeraddr() API
[linux-2.6-omap-h63xx.git] / net / sunrpc / rpc_pipe.c
index 6db6006616c67bb63aaf96c848a7e692815f5fcc..c21dc07f2a8cc6aa890ae2bd10728a1eade50af1 100644 (file)
@@ -327,10 +327,8 @@ rpc_show_info(struct seq_file *m, void *v)
        seq_printf(m, "RPC server: %s\n", clnt->cl_server);
        seq_printf(m, "service: %s (%d) version %d\n", clnt->cl_protname,
                        clnt->cl_prog, clnt->cl_vers);
-       seq_printf(m, "address: %u.%u.%u.%u\n",
-                       NIPQUAD(clnt->cl_xprt->addr.sin_addr.s_addr));
-       seq_printf(m, "protocol: %s\n",
-                       clnt->cl_xprt->prot == IPPROTO_UDP ? "udp" : "tcp");
+       seq_printf(m, "address: %s\n", rpc_peeraddr2str(clnt, RPC_DISPLAY_ADDR));
+       seq_printf(m, "protocol: %s\n", rpc_peeraddr2str(clnt, RPC_DISPLAY_PROTO));
        return 0;
 }
 
@@ -515,7 +513,7 @@ rpc_depopulate(struct dentry *parent)
        struct dentry *dentry, *dvec[10];
        int n = 0;
 
-       mutex_lock(&dir->i_mutex);
+       mutex_lock_nested(&dir->i_mutex, I_MUTEX_CHILD);
 repeat:
        spin_lock(&dcache_lock);
        list_for_each_safe(pos, next, &parent->d_subdirs) {
@@ -539,6 +537,7 @@ repeat:
                                rpc_close_pipes(dentry->d_inode);
                                simple_unlink(dir, dentry);
                        }
+                       inode_dir_notify(dir, DN_DELETE);
                        dput(dentry);
                } while (n);
                goto repeat;
@@ -610,8 +609,8 @@ __rpc_rmdir(struct inode *dir, struct dentry *dentry)
        int error;
 
        shrink_dcache_parent(dentry);
-       if (dentry->d_inode)
-               rpc_close_pipes(dentry->d_inode);
+       if (d_unhashed(dentry))
+               return 0;
        if ((error = simple_rmdir(dir, dentry)) != 0)
                return error;
        if (!error) {
@@ -631,7 +630,7 @@ rpc_lookup_negative(char *path, struct nameidata *nd)
        if ((error = rpc_lookup_parent(path, nd)) != 0)
                return ERR_PTR(error);
        dir = nd->dentry->d_inode;
-       mutex_lock(&dir->i_mutex);
+       mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
        dentry = lookup_one_len(nd->last.name, nd->dentry, nd->last.len);
        if (IS_ERR(dentry))
                goto out_err;
@@ -667,10 +666,11 @@ rpc_mkdir(char *path, struct rpc_clnt *rpc_client)
                        RPCAUTH_info, RPCAUTH_EOF);
        if (error)
                goto err_depopulate;
+       dget(dentry);
 out:
        mutex_unlock(&dir->i_mutex);
        rpc_release_path(&nd);
-       return dget(dentry);
+       return dentry;
 err_depopulate:
        rpc_depopulate(dentry);
        __rpc_rmdir(dir, dentry);
@@ -683,28 +683,20 @@ err_dput:
 }
 
 int
-rpc_rmdir(char *path)
+rpc_rmdir(struct dentry *dentry)
 {
-       struct nameidata nd;
-       struct dentry *dentry;
+       struct dentry *parent;
        struct inode *dir;
        int error;
 
-       if ((error = rpc_lookup_parent(path, &nd)) != 0)
-               return error;
-       dir = nd.dentry->d_inode;
-       mutex_lock(&dir->i_mutex);
-       dentry = lookup_one_len(nd.last.name, nd.dentry, nd.last.len);
-       if (IS_ERR(dentry)) {
-               error = PTR_ERR(dentry);
-               goto out_release;
-       }
+       parent = dget_parent(dentry);
+       dir = parent->d_inode;
+       mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
        rpc_depopulate(dentry);
        error = __rpc_rmdir(dir, dentry);
        dput(dentry);
-out_release:
        mutex_unlock(&dir->i_mutex);
-       rpc_release_path(&nd);
+       dput(parent);
        return error;
 }
 
@@ -731,10 +723,11 @@ rpc_mkpipe(char *path, void *private, struct rpc_pipe_ops *ops, int flags)
        rpci->flags = flags;
        rpci->ops = ops;
        inode_dir_notify(dir, DN_CREATE);
+       dget(dentry);
 out:
        mutex_unlock(&dir->i_mutex);
        rpc_release_path(&nd);
-       return dget(dentry);
+       return dentry;
 err_dput:
        dput(dentry);
        dentry = ERR_PTR(-ENOMEM);
@@ -744,32 +737,26 @@ err_dput:
 }
 
 int
-rpc_unlink(char *path)
+rpc_unlink(struct dentry *dentry)
 {
-       struct nameidata nd;
-       struct dentry *dentry;
+       struct dentry *parent;
        struct inode *dir;
-       int error;
+       int error = 0;
 
-       if ((error = rpc_lookup_parent(path, &nd)) != 0)
-               return error;
-       dir = nd.dentry->d_inode;
-       mutex_lock(&dir->i_mutex);
-       dentry = lookup_one_len(nd.last.name, nd.dentry, nd.last.len);
-       if (IS_ERR(dentry)) {
-               error = PTR_ERR(dentry);
-               goto out_release;
-       }
-       d_drop(dentry);
-       if (dentry->d_inode) {
-               rpc_close_pipes(dentry->d_inode);
-               error = simple_unlink(dir, dentry);
+       parent = dget_parent(dentry);
+       dir = parent->d_inode;
+       mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
+       if (!d_unhashed(dentry)) {
+               d_drop(dentry);
+               if (dentry->d_inode) {
+                       rpc_close_pipes(dentry->d_inode);
+                       error = simple_unlink(dir, dentry);
+               }
+               inode_dir_notify(dir, DN_DELETE);
        }
        dput(dentry);
-       inode_dir_notify(dir, DN_DELETE);
-out_release:
        mutex_unlock(&dir->i_mutex);
-       rpc_release_path(&nd);
+       dput(parent);
        return error;
 }