A basic NFSv4 client for 2.5.x
Subsystems (2)
PATCH 10/19 A basic NFSv4 client for 2.5.x
This is a nontrivial change to the NFS client.
In this patch, we finish modifying the async READ path so that it is version-agnostic. We define a new nfs_rpc_op ->setup_read(), and move the v2- and v3-specific code in nfs_read_rpcsetup() there. We also have to change nfs_readpage() result so that the 'count' of bytes read is a parameter. The extra parameter means that it can no longer be ->tk_exit(). Instead, it is called from a version-specific ->tk_exit() routine which is set in ->read_setup().
The upshot of all this is that the version-specific part of the async READ path has been encapsulated in a new nfs_rpc_op ->read_setup(), and NFSv4 can share the logic for asynchronous READ's with NFSv2 and v3.
fs/nfs/nfs3proc.c +47 -0
@@ -14,6 +14,7 @@#include <linux/nfs.h> #include <linux/nfs3.h> #include <linux/nfs_fs.h> +#include <linux/nfs_page.h> #include <linux/smp_lock.h> #define NFSDBG_FACILITY NFSDBG_PROC
@@ -646,6 +647,51 @@extern u32 *nfs3_decode_dirent (u32 *,struct nfs_entry *,int ); +static void +nfs3_read_done (struct rpc_task *task) +{ +struct nfs_read_data *data = (struct nfs_read_data *) task->tk_calldata; + +if (nfs_async_handle_jukebox (task)) +return ; +nfs_readpage_result (task, data->u.v3.res.count, data->u.v3.res.eof); +} + +static void +nfs3_proc_read_setup (struct nfs_read_data *data,unsigned int count) +{ +struct rpc_task *task = &data->task; +struct inode *inode = data->inode; +struct nfs_page *req; +int flags; +struct rpc_message msg; + + req =nfs_list_entry (data->pages.next); + data->u.v3.args.fh =NFS_FH (inode); + data->u.v3.args.offset =req_offset (req) + req->wb_offset; + data->u.v3.args.pgbase = req->wb_offset; + data->u.v3.args.pages = data->pagevec; + data->u.v3.args.count = count; + data->u.v3.res.fattr = &data->fattr; + data->u.v3.res.count = count; + data->u.v3.res.eof =0 ; + +/* 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), nfs3_read_done, flags); + task->tk_calldata = data; +/* Release requests */ + task->tk_release = nfs_readdata_release; + + msg.rpc_proc =NFS3PROC_READ ; + msg.rpc_argp = &data->u.v3.args; + msg.rpc_resp = &data->u.v3.res; + msg.rpc_cred = data->cred; +rpc_call_setup (&data->task, &msg,0 ); +} +struct nfs_rpc_ops nfs_v3_clientops = { .version =3 ,/* protocol version */ .getroot = nfs3_proc_get_root,
@@ -669,4 +715,5 @@ .mknod = nfs3_proc_mknod, .statfs = nfs3_proc_statfs, .decode_dirent = nfs3_decode_dirent, + .read_setup = nfs3_proc_read_setup, };
fs/nfs/proc.c +44 -0
60 lines not on this page · raw message
fs/nfs/read.c +17 -80
166 lines not on this page · raw message
include/linux/nfs_fs.h +7 -0
@@ -379,6 +379,11 @@return (error <0 ) ? error :0 ; } +/* Hack for future NFS swap support */ +#ifndef IS_SWAPFILE +# define IS_SWAPFILE (inode) (0) +#endif +/* * linux/fs/nfs/read.c */
@@ -387,6 +392,8 @@extern int nfs_pagein_list (struct list_head *,int );extern int nfs_scan_lru_read (struct nfs_server *,struct list_head *);extern int nfs_scan_lru_read_timeout (struct nfs_server *,struct list_head *); +extern void nfs_readpage_result (struct rpc_task *,unsigned int count,int eof); +extern void nfs_readdata_release (struct rpc_task *);/* * linux/fs/mount_clnt.c
include/linux/nfs_xdr.h +19 -0
@@ -308,6 +308,24 @@int plus; }; +struct nfs_read_data { +struct rpc_task task; +struct inode *inode; +struct rpc_cred *cred; +struct nfs_fattr fattr;/* fattr storage */ +struct list_head pages;/* Coalesced read requests */ +struct page *pagevec[NFS_READ_MAXIOV ]; +union { +struct { +struct nfs_readargs args; +struct nfs_readres res; + } v3;/* also v2 */ +#ifdef CONFIG_NFS_V4 +/* NFSv4 data will come here... */ +#endif + } u; +}; +/* * RPC procedure vector for NFSv2/NFSv3 demuxing */
@@ -355,6 +373,7 @@int (*statfs) (struct nfs_server *,struct nfs_fh *,struct nfs_fsinfo *);u32 * (*decode_dirent)(u32 *,struct nfs_entry *,int plus); +void (*read_setup) (struct nfs_read_data *,unsigned int count); };/*
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs