[pnfs] [PATCH 13/20] 2.6-latest pnfs client pnfs_try_to_read
Dean Hildebrand
seattleplus at gmail.com
Sun Dec 2 02:42:13 EST 2007
I notice this patch moves nfs_execute_read and nfs_initiate_read to the
top. My suggestion would be to use forward declarations instead. This
will help avoid possible errors in moving the code forward if either of
those functions changes.
If we can avoid any patches that simply move functions around the easier
it will be to see what each patch truly does.
Dean
andros at umich.edu wrote:
> From: Andy Adamson <andros at umich.edu>
>
> Call pnfs_try_to_read in read data path
> Use data server session in nfs_read_validate.
>
> pnfs_try_to_read() will be allowed to return an error on I/O. This
> error will be propagated through nfs_read_rpcsetup() to the application in
> a subsequent patch.
>
> ret == 0 means pnfs read succees.
> ret == 1 means do an NFSv4.1 read to the MDS.
> ret < 0: return error to application. (next patch allows this)
>
> Signed-off by: Andy Adamson<andros at umich.edu>
> ---
> fs/nfs/read.c | 94 +++++++++++++++++++++++++-------------------------------
> 1 files changed, 42 insertions(+), 52 deletions(-)
>
> diff --git a/fs/nfs/read.c b/fs/nfs/read.c
> index 4a4d1ed..67caf23 100644
> --- a/fs/nfs/read.c
> +++ b/fs/nfs/read.c
> @@ -160,6 +160,43 @@ static void nfs_readpage_release(struct nfs_page *req)
> }
>
> /*
> + * Start an async read operation
> + */
> +static void nfs_execute_read(struct nfs_read_data *data)
> +{
> + struct rpc_clnt *clnt = NFS_CLIENT(data->inode);
> + sigset_t oldset;
> +
> + rpc_clnt_sigmask(clnt, &oldset);
> + rpc_execute(&data->task);
> + rpc_clnt_sigunmask(clnt, &oldset);
> +}
> +
> +void nfs_initiate_read(struct nfs_read_data *data, struct rpc_clnt *clnt,
> + const struct rpc_call_ops *call_ops)
> +{
> + struct inode *inode = data->inode;
> + int flags;
> +
> + /* Set up the initial task struct. */
> + flags = RPC_TASK_ASYNC | (IS_SWAPFILE(inode)?NFS_RPC_SWAPFLAGS : 0);
> + rpc_init_task(&data->task, clnt, flags, call_ops, data);
> +
> + NFS_PROTO(inode)->read_setup(data);
> +
> + data->task.tk_cookie = (unsigned long)inode;
> +
> + dprintk("NFS: %4d initiated read call (req %s/%Ld, %u bytes @ offset %Lu)\n",
> + data->task.tk_pid,
> + inode->i_sb->s_id,
> + (long long)NFS_FILEID(inode),
> + data->args.count,
> + (unsigned long long)data->args.offset);
> +
> + nfs_execute_read(data);
> +}
> +
> +/*
> * Set up the NFS read request struct
> */
> static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
> @@ -167,7 +204,6 @@ static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
> unsigned int count, unsigned int offset)
> {
> struct inode *inode;
> - int flags;
> struct nfs_server *server = data->args.server;
>
> BUG_ON(server == NULL);
> @@ -187,19 +223,12 @@ static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
> data->res.eof = 0;
> nfs_fattr_init(&data->fattr);
>
> - /* Set up the initial task struct. */
> - flags = RPC_TASK_ASYNC | (IS_SWAPFILE(inode)? NFS_RPC_SWAPFLAGS : 0);
> - rpc_init_task(&data->task, NFS_CLIENT(inode), flags, call_ops, data);
> - NFS_PROTO(inode)->read_setup(data);
> -
> - data->task.tk_cookie = (unsigned long)inode;
> +#ifdef CONFIG_PNFS
> + if ((pnfs_try_to_read_data(data, call_ops)) <= 0)
> + return;
> +#endif /* CONFIG_PNFS*/
>
> - dprintk("NFS: %5u initiated read call (req %s/%Ld, %u bytes @ offset %Lu)\n",
> - data->task.tk_pid,
> - inode->i_sb->s_id,
> - (long long)NFS_FILEID(inode),
> - count,
> - (unsigned long long)data->args.offset);
> + nfs_initiate_read(data, NFS_CLIENT(inode), call_ops);
> }
>
> static void
> @@ -216,43 +245,6 @@ nfs_async_read_error(struct list_head *head)
> }
>
> /*
> - * Start an async read operation
> - */
> -static void nfs_execute_read(struct nfs_read_data *data)
> -{
> - struct rpc_clnt *clnt = NFS_CLIENT(data->inode);
> - sigset_t oldset;
> -
> - rpc_clnt_sigmask(clnt, &oldset);
> - rpc_execute(&data->task);
> - rpc_clnt_sigunmask(clnt, &oldset);
> -}
> -
> -void nfs_initiate_read(struct nfs_read_data *data, struct rpc_clnt *clnt,
> - const struct rpc_call_ops *call_ops)
> -{
> - struct inode *inode = data->inode;
> - int flags;
> -
> - /* Set up the initial task struct. */
> - flags = RPC_TASK_ASYNC | (IS_SWAPFILE(inode)?NFS_RPC_SWAPFLAGS : 0);
> - rpc_init_task(&data->task, clnt, flags, call_ops, data);
> -
> - NFS_PROTO(inode)->read_setup(data);
> -
> - data->task.tk_cookie = (unsigned long)inode;
> -
> - dprintk("NFS: %4d initiated read call (req %s/%Ld, %u bytes @ offset %Lu)\n",
> - data->task.tk_pid,
> - inode->i_sb->s_id,
> - (long long)NFS_FILEID(inode),
> - data->args.count,
> - (unsigned long long)data->args.offset);
> -
> - nfs_execute_read(data);
> -}
> -
> -/*
> * Generate multiple requests to fill a single page.
> *
> * We optimize to reduce the number of read operations on the wire. If we
> @@ -307,7 +299,6 @@ static int nfs_pagein_multi(struct inode *inode, struct list_head *head, unsigne
> rsize, offset);
> offset += rsize;
> nbytes -= rsize;
> - nfs_execute_read(data);
> } while (nbytes != 0);
>
> return 0;
> @@ -347,7 +338,6 @@ static int nfs_pagein_one(struct inode *inode, struct list_head *head, unsigned
>
> nfs_read_rpcsetup(req, data, &nfs_read_full_ops, count, 0);
>
> - nfs_execute_read(data);
> return 0;
> out_bad:
> nfs_async_read_error(head);
>
More information about the pNFS
mailing list