Commit 7e19d190 authored by Trond Myklebust's avatar Trond Myklebust

NFSv2/v3/v4: Add support for asynchronous reads even if rsize<PAGE_CACHE_SIZE.

parent 6c2689a5
......@@ -128,6 +128,7 @@ nfs_direct_read_seg(struct inode *inode, struct file *file,
.inode = inode,
.args = {
.fh = NFS_FH(inode),
.lockowner = current->files,
},
.res = {
.fattr = &rdata.fattr,
......
......@@ -729,11 +729,10 @@ nfs3_read_done(struct rpc_task *task)
}
static void
nfs3_proc_read_setup(struct nfs_read_data *data, unsigned int count)
nfs3_proc_read_setup(struct nfs_read_data *data)
{
struct rpc_task *task = &data->task;
struct inode *inode = data->inode;
struct nfs_page *req;
int flags;
struct rpc_message msg = {
.rpc_proc = &nfs3_procedures[NFS3PROC_READ],
......@@ -741,27 +740,13 @@ nfs3_proc_read_setup(struct nfs_read_data *data, unsigned int count)
.rpc_resp = &data->res,
.rpc_cred = data->cred,
};
req = nfs_list_entry(data->pages.next);
data->args.fh = NFS_FH(inode);
data->args.offset = req_offset(req);
data->args.pgbase = req->wb_pgbase;
data->args.pages = data->pagevec;
data->args.count = count;
data->res.fattr = &data->fattr;
data->res.count = count;
data->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;
rpc_call_setup(&data->task, &msg, 0);
rpc_call_setup(task, &msg, 0);
}
static void
......
......@@ -1096,10 +1096,10 @@ nfs4_proc_read(struct nfs_read_data *rdata, struct file *filp)
if (filp) {
struct nfs4_state *state;
state = (struct nfs4_state *)filp->private_data;
nfs4_copy_stateid(&rdata->args.stateid, state, rdata->lockowner);
rdata->args.state = state;
msg.rpc_cred = state->owner->so_cred;
} else {
memcpy(&rdata->args.stateid, &zero_stateid, sizeof(rdata->args.stateid));
rdata->args.state = NULL;
msg.rpc_cred = NFS_I(inode)->mm_cred;
}
......@@ -1509,20 +1509,6 @@ nfs4_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle,
return nfs4_map_errors(nfs4_call_compound(&compound, NULL, 0));
}
static void
nfs4_restart_read(struct rpc_task *task)
{
struct nfs_read_data *data = (struct nfs_read_data *)task->tk_calldata;
struct nfs_page *req;
rpc_restart_call(task);
req = nfs_list_entry(data->pages.next);
if (req->wb_state)
nfs4_copy_stateid(&data->args.stateid, req->wb_state, req->wb_lockowner);
else
memcpy(&data->args.stateid, &zero_stateid, sizeof(data->args.stateid));
}
static void
nfs4_read_done(struct rpc_task *task)
{
......@@ -1530,7 +1516,7 @@ nfs4_read_done(struct rpc_task *task)
struct inode *inode = data->inode;
if (nfs4_async_handle_error(task, NFS_SERVER(inode)) == -EAGAIN) {
task->tk_action = nfs4_restart_read;
rpc_restart_call(task);
return;
}
if (task->tk_status > 0)
......@@ -1540,7 +1526,7 @@ nfs4_read_done(struct rpc_task *task)
}
static void
nfs4_proc_read_setup(struct nfs_read_data *data, unsigned int count)
nfs4_proc_read_setup(struct nfs_read_data *data)
{
struct rpc_task *task = &data->task;
struct rpc_message msg = {
......@@ -1550,34 +1536,15 @@ nfs4_proc_read_setup(struct nfs_read_data *data, unsigned int count)
.rpc_cred = data->cred,
};
struct inode *inode = data->inode;
struct nfs_page *req = nfs_list_entry(data->pages.next);
int flags;
data->args.fh = NFS_FH(inode);
data->args.offset = req_offset(req);
data->args.pgbase = req->wb_pgbase;
data->args.pages = data->pagevec;
data->args.count = count;
data->res.fattr = &data->fattr;
data->res.count = count;
data->res.eof = 0;
data->timestamp = jiffies;
data->lockowner = req->wb_lockowner;
if (req->wb_state)
nfs4_copy_stateid(&data->args.stateid, req->wb_state, req->wb_lockowner);
else
memcpy(&data->args.stateid, &zero_stateid, sizeof(data->args.stateid));
/* 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), nfs4_read_done, flags);
task->tk_calldata = data;
/* Release requests */
task->tk_release = nfs_readdata_release;
rpc_call_setup(task, &msg, 0);
}
......
......@@ -868,14 +868,32 @@ encode_putrootfh(struct xdr_stream *xdr)
return 0;
}
static void
encode_stateid(struct xdr_stream *xdr, struct nfs4_state *state, fl_owner_t lockowner)
{
extern nfs4_stateid zero_stateid;
nfs4_stateid stateid;
uint32_t *p;
RESERVE_SPACE(16);
if (state != NULL) {
nfs4_copy_stateid(&stateid, state, lockowner);
WRITEMEM(stateid.data, sizeof(stateid.data));
} else
WRITEMEM(zero_stateid.data, sizeof(zero_stateid.data));
}
static int
encode_read(struct xdr_stream *xdr, struct nfs_readargs *args)
{
uint32_t *p;
RESERVE_SPACE(32);
RESERVE_SPACE(4);
WRITE32(OP_READ);
WRITEMEM(args->stateid.data, sizeof(args->stateid.data));
encode_stateid(xdr, args->state, args->lockowner);
RESERVE_SPACE(12);
WRITE64(args->offset);
WRITE32(args->count);
......
......@@ -559,11 +559,10 @@ nfs_read_done(struct rpc_task *task)
}
static void
nfs_proc_read_setup(struct nfs_read_data *data, unsigned int count)
nfs_proc_read_setup(struct nfs_read_data *data)
{
struct rpc_task *task = &data->task;
struct inode *inode = data->inode;
struct nfs_page *req;
int flags;
struct rpc_message msg = {
.rpc_proc = &nfs_procedures[NFSPROC_READ],
......@@ -571,27 +570,13 @@ nfs_proc_read_setup(struct nfs_read_data *data, unsigned int count)
.rpc_resp = &data->res,
.rpc_cred = data->cred,
};
req = nfs_list_entry(data->pages.next);
data->args.fh = NFS_FH(inode);
data->args.offset = req_offset(req);
data->args.pgbase = req->wb_pgbase;
data->args.pages = data->pagevec;
data->args.count = count;
data->res.fattr = &data->fattr;
data->res.count = count;
data->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), nfs_read_done, flags);
task->tk_calldata = data;
/* Release requests */
task->tk_release = nfs_readdata_release;
rpc_call_setup(&data->task, &msg, 0);
rpc_call_setup(task, &msg, 0);
}
static void
......
This diff is collapsed.
......@@ -397,7 +397,6 @@ extern int nfs_readpages(struct file *, struct address_space *,
struct list_head *, unsigned);
extern int nfs_pagein_list(struct list_head *, int);
extern void nfs_readpage_result(struct rpc_task *);
extern void nfs_readdata_release(struct rpc_task *);
/*
* linux/fs/mount_clnt.c
......
......@@ -229,7 +229,8 @@ struct nfs_lockres {
struct nfs_readargs {
struct nfs_fh * fh;
nfs4_stateid stateid;
fl_owner_t lockowner;
struct nfs4_state * state;
__u64 offset;
__u32 count;
unsigned int pgbase;
......@@ -663,7 +664,6 @@ struct nfs_read_data {
struct rpc_task task;
struct inode *inode;
struct rpc_cred *cred;
fl_owner_t lockowner;
struct nfs_fattr fattr; /* fattr storage */
struct list_head pages; /* Coalesced read requests */
struct nfs_page *req; /* multi ops per nfs_page */
......@@ -741,7 +741,7 @@ struct nfs_rpc_ops {
int (*pathconf) (struct nfs_server *, struct nfs_fh *,
struct nfs_pathconf *);
u32 * (*decode_dirent)(u32 *, struct nfs_entry *, int plus);
void (*read_setup) (struct nfs_read_data *, unsigned int count);
void (*read_setup) (struct nfs_read_data *);
void (*write_setup) (struct nfs_write_data *, unsigned int count, int how);
void (*commit_setup) (struct nfs_write_data *, u64 start, u32 len, int how);
int (*file_open) (struct inode *, struct file *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment