NFS: Share NFS superblocks per-protocol per-server per-FSID
[safe/jmp/linux-2.6] / fs / nfs / nfs3proc.c
index 740f8b1..9e8258e 100644 (file)
 #include <linux/nfs_mount.h>
 
 #include "iostat.h"
+#include "internal.h"
 
 #define NFSDBG_FACILITY                NFSDBG_PROC
 
-extern struct rpc_procinfo nfs3_procedures[];
-
 /* A wrapper to handle the EJUKEBOX error message */
 static int
 nfs3_rpc_wrapper(struct rpc_clnt *clnt, struct rpc_message *msg, int flags)
@@ -82,7 +81,7 @@ do_proc_get_root(struct rpc_clnt *client, struct nfs_fh *fhandle,
 }
 
 /*
- * Bare-bones access to getattr: this is for nfs_read_super.
+ * Bare-bones access to getattr: this is for nfs_get_root/nfs_get_sb
  */
 static int
 nfs3_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
@@ -91,8 +90,8 @@ nfs3_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
        int     status;
 
        status = do_proc_get_root(server->client, fhandle, info);
-       if (status && server->client_sys != server->client)
-               status = do_proc_get_root(server->client_sys, fhandle, info);
+       if (status && server->nfs_client->cl_rpcclient != server->client)
+               status = do_proc_get_root(server->nfs_client->cl_rpcclient, fhandle, info);
        return status;
 }
 
@@ -786,7 +785,7 @@ nfs3_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle,
 
        dprintk("NFS call  fsinfo\n");
        nfs_fattr_init(info->fattr);
-       status = rpc_call_sync(server->client_sys, &msg, 0);
+       status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0);
        dprintk("NFS reply fsinfo: %d\n", status);
        return status;
 }
@@ -809,31 +808,18 @@ nfs3_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle,
        return status;
 }
 
-extern u32 *nfs3_decode_dirent(u32 *, struct nfs_entry *, int);
-
-static void nfs3_read_done(struct rpc_task *task, void *calldata)
+static int nfs3_read_done(struct rpc_task *task, struct nfs_read_data *data)
 {
-       struct nfs_read_data *data = calldata;
-
        if (nfs3_async_handle_jukebox(task, data->inode))
-               return;
+               return -EAGAIN;
        /* Call back common NFS readpage processing */
        if (task->tk_status >= 0)
                nfs_refresh_inode(data->inode, &data->fattr);
-       nfs_readpage_result(task, calldata);
+       return 0;
 }
 
-static const struct rpc_call_ops nfs3_read_ops = {
-       .rpc_call_done = nfs3_read_done,
-       .rpc_release = nfs_readdata_release,
-};
-
-static void
-nfs3_proc_read_setup(struct nfs_read_data *data)
+static void nfs3_proc_read_setup(struct nfs_read_data *data)
 {
-       struct rpc_task         *task = &data->task;
-       struct inode            *inode = data->inode;
-       int                     flags;
        struct rpc_message      msg = {
                .rpc_proc       = &nfs3_procedures[NFS3PROC_READ],
                .rpc_argp       = &data->args,
@@ -841,37 +827,20 @@ nfs3_proc_read_setup(struct nfs_read_data *data)
                .rpc_cred       = data->cred,
        };
 
-       /* N.B. Do we need to test? Never called for swapfile inode */
-       flags = RPC_TASK_ASYNC | (IS_SWAPFILE(inode)? NFS_RPC_SWAPFLAGS : 0);
-
-       /* Finalize the task. */
-       rpc_init_task(task, NFS_CLIENT(inode), flags, &nfs3_read_ops, data);
-       rpc_call_setup(task, &msg, 0);
+       rpc_call_setup(&data->task, &msg, 0);
 }
 
-static void nfs3_write_done(struct rpc_task *task, void *calldata)
+static int nfs3_write_done(struct rpc_task *task, struct nfs_write_data *data)
 {
-       struct nfs_write_data *data = calldata;
-
        if (nfs3_async_handle_jukebox(task, data->inode))
-               return;
+               return -EAGAIN;
        if (task->tk_status >= 0)
                nfs_post_op_update_inode(data->inode, data->res.fattr);
-       nfs_writeback_done(task, calldata);
+       return 0;
 }
 
-static const struct rpc_call_ops nfs3_write_ops = {
-       .rpc_call_done = nfs3_write_done,
-       .rpc_release = nfs_writedata_release,
-};
-
-static void
-nfs3_proc_write_setup(struct nfs_write_data *data, int how)
+static void nfs3_proc_write_setup(struct nfs_write_data *data, int how)
 {
-       struct rpc_task         *task = &data->task;
-       struct inode            *inode = data->inode;
-       int                     stable;
-       int                     flags;
        struct rpc_message      msg = {
                .rpc_proc       = &nfs3_procedures[NFS3PROC_WRITE],
                .rpc_argp       = &data->args,
@@ -879,45 +848,28 @@ nfs3_proc_write_setup(struct nfs_write_data *data, int how)
                .rpc_cred       = data->cred,
        };
 
+       data->args.stable = NFS_UNSTABLE;
        if (how & FLUSH_STABLE) {
-               if (!NFS_I(inode)->ncommit)
-                       stable = NFS_FILE_SYNC;
-               else
-                       stable = NFS_DATA_SYNC;
-       } else
-               stable = NFS_UNSTABLE;
-       data->args.stable = stable;
-
-       /* Set the initial flags for the task.  */
-       flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC;
+               data->args.stable = NFS_FILE_SYNC;
+               if (NFS_I(data->inode)->ncommit)
+                       data->args.stable = NFS_DATA_SYNC;
+       }
 
        /* Finalize the task. */
-       rpc_init_task(task, NFS_CLIENT(inode), flags, &nfs3_write_ops, data);
-       rpc_call_setup(task, &msg, 0);
+       rpc_call_setup(&data->task, &msg, 0);
 }
 
-static void nfs3_commit_done(struct rpc_task *task, void *calldata)
+static int nfs3_commit_done(struct rpc_task *task, struct nfs_write_data *data)
 {
-       struct nfs_write_data *data = calldata;
-
        if (nfs3_async_handle_jukebox(task, data->inode))
-               return;
+               return -EAGAIN;
        if (task->tk_status >= 0)
                nfs_post_op_update_inode(data->inode, data->res.fattr);
-       nfs_commit_done(task, calldata);
+       return 0;
 }
 
-static const struct rpc_call_ops nfs3_commit_ops = {
-       .rpc_call_done = nfs3_commit_done,
-       .rpc_release = nfs_commit_release,
-};
-
-static void
-nfs3_proc_commit_setup(struct nfs_write_data *data, int how)
+static void nfs3_proc_commit_setup(struct nfs_write_data *data, int how)
 {
-       struct rpc_task         *task = &data->task;
-       struct inode            *inode = data->inode;
-       int                     flags;
        struct rpc_message      msg = {
                .rpc_proc       = &nfs3_procedures[NFS3PROC_COMMIT],
                .rpc_argp       = &data->args,
@@ -925,12 +877,7 @@ nfs3_proc_commit_setup(struct nfs_write_data *data, int how)
                .rpc_cred       = data->cred,
        };
 
-       /* Set the initial flags for the task.  */
-       flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC;
-
-       /* Finalize the task. */
-       rpc_init_task(task, NFS_CLIENT(inode), flags, &nfs3_commit_ops, data);
-       rpc_call_setup(task, &msg, 0);
+       rpc_call_setup(&data->task, &msg, 0);
 }
 
 static int
@@ -939,7 +886,7 @@ nfs3_proc_lock(struct file *filp, int cmd, struct file_lock *fl)
        return nlmclnt_proc(filp->f_dentry->d_inode, cmd, fl);
 }
 
-struct nfs_rpc_ops     nfs_v3_clientops = {
+const struct nfs_rpc_ops nfs_v3_clientops = {
        .version        = 3,                    /* protocol version */
        .dentry_ops     = &nfs_dentry_operations,
        .dir_inode_ops  = &nfs3_dir_inode_operations,
@@ -969,8 +916,11 @@ struct nfs_rpc_ops nfs_v3_clientops = {
        .pathconf       = nfs3_proc_pathconf,
        .decode_dirent  = nfs3_decode_dirent,
        .read_setup     = nfs3_proc_read_setup,
+       .read_done      = nfs3_read_done,
        .write_setup    = nfs3_proc_write_setup,
+       .write_done     = nfs3_write_done,
        .commit_setup   = nfs3_proc_commit_setup,
+       .commit_done    = nfs3_commit_done,
        .file_open      = nfs_open,
        .file_release   = nfs_release,
        .lock           = nfs3_proc_lock,