nfs: use proc_create to setup de->proc_fops
[pandora-kernel.git] / fs / nfs / client.c
index c5c0175..89ac5bb 100644 (file)
@@ -112,6 +112,7 @@ struct nfs_client_initdata {
 static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_init)
 {
        struct nfs_client *clp;
+       struct rpc_cred *cred;
 
        if ((clp = kzalloc(sizeof(*clp), GFP_KERNEL)) == NULL)
                goto error_0;
@@ -150,6 +151,9 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_
        clp->cl_boot_time = CURRENT_TIME;
        clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED;
 #endif
+       cred = rpc_lookup_machine_cred();
+       if (!IS_ERR(cred))
+               clp->cl_machine_cred = cred;
 
        return clp;
 
@@ -170,6 +174,8 @@ static void nfs4_shutdown_client(struct nfs_client *clp)
        BUG_ON(!RB_EMPTY_ROOT(&clp->cl_state_owners));
        if (__test_and_clear_bit(NFS_CS_IDMAP, &clp->cl_res_state))
                nfs_idmap_delete(clp);
+
+       rpc_destroy_wait_queue(&clp->cl_rpcwaitq);
 #endif
 }
 
@@ -189,6 +195,9 @@ static void nfs_free_client(struct nfs_client *clp)
        if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state))
                nfs_callback_down();
 
+       if (clp->cl_machine_cred != NULL)
+               put_rpccred(clp->cl_machine_cred);
+
        kfree(clp->cl_hostname);
        kfree(clp);
 
@@ -680,10 +689,22 @@ static int nfs_init_server(struct nfs_server *server,
        if (error < 0)
                goto error;
 
+       server->port = data->nfs_server.port;
+
        error = nfs_init_server_rpcclient(server, &timeparms, data->auth_flavors[0]);
        if (error < 0)
                goto error;
 
+       /* Preserve the values of mount_server-related mount options */
+       if (data->mount_server.addrlen) {
+               memcpy(&server->mountd_address, &data->mount_server.address,
+                       data->mount_server.addrlen);
+               server->mountd_addrlen = data->mount_server.addrlen;
+       }
+       server->mountd_version = data->mount_server.version;
+       server->mountd_port = data->mount_server.port;
+       server->mountd_protocol = data->mount_server.protocol;
+
        server->namelen  = data->namlen;
        /* Create a client RPC handle for the NFSv3 ACL management interface */
        nfs_init_server_aclclient(server);
@@ -1062,6 +1083,8 @@ static int nfs4_init_server(struct nfs_server *server,
        server->acdirmin = data->acdirmin * HZ;
        server->acdirmax = data->acdirmax * HZ;
 
+       server->port = data->nfs_server.port;
+
        error = nfs_init_server_rpcclient(server, &timeparms, data->auth_flavors[0]);
 
 error:
@@ -1298,6 +1321,7 @@ static const struct file_operations nfs_server_list_fops = {
        .read           = seq_read,
        .llseek         = seq_lseek,
        .release        = seq_release,
+       .owner          = THIS_MODULE,
 };
 
 static int nfs_volume_list_open(struct inode *inode, struct file *file);
@@ -1318,6 +1342,7 @@ static const struct file_operations nfs_volume_list_fops = {
        .read           = seq_read,
        .llseek         = seq_lseek,
        .release        = seq_release,
+       .owner          = THIS_MODULE,
 };
 
 /*
@@ -1477,33 +1502,29 @@ int __init nfs_fs_proc_init(void)
 {
        struct proc_dir_entry *p;
 
-       proc_fs_nfs = proc_mkdir("nfsfs", proc_root_fs);
+       proc_fs_nfs = proc_mkdir("fs/nfsfs", NULL);
        if (!proc_fs_nfs)
                goto error_0;
 
        proc_fs_nfs->owner = THIS_MODULE;
 
        /* a file of servers with which we're dealing */
-       p = create_proc_entry("servers", S_IFREG|S_IRUGO, proc_fs_nfs);
+       p = proc_create("servers", S_IFREG|S_IRUGO,
+                       proc_fs_nfs, &nfs_server_list_fops);
        if (!p)
                goto error_1;
 
-       p->proc_fops = &nfs_server_list_fops;
-       p->owner = THIS_MODULE;
-
        /* a file of volumes that we have mounted */
-       p = create_proc_entry("volumes", S_IFREG|S_IRUGO, proc_fs_nfs);
+       p = proc_create("volumes", S_IFREG|S_IRUGO,
+                       proc_fs_nfs, &nfs_volume_list_fops);
        if (!p)
                goto error_2;
-
-       p->proc_fops = &nfs_volume_list_fops;
-       p->owner = THIS_MODULE;
        return 0;
 
 error_2:
        remove_proc_entry("servers", proc_fs_nfs);
 error_1:
-       remove_proc_entry("nfsfs", proc_root_fs);
+       remove_proc_entry("fs/nfsfs", NULL);
 error_0:
        return -ENOMEM;
 }
@@ -1515,7 +1536,7 @@ void nfs_fs_proc_exit(void)
 {
        remove_proc_entry("volumes", proc_fs_nfs);
        remove_proc_entry("servers", proc_fs_nfs);
-       remove_proc_entry("nfsfs", proc_root_fs);
+       remove_proc_entry("fs/nfsfs", NULL);
 }
 
 #endif /* CONFIG_PROC_FS */