Commit cd21f96e authored by Trond Myklebust's avatar Trond Myklebust Committed by Linus Torvalds

[PATCH] NFS: synchronous NFSv3/v4 COMMIT

Add support for synchronous calls to the NFSv3/v4 COMMIT functions.
parent 88a88295
...@@ -284,6 +284,29 @@ nfs3_proc_write(struct nfs_write_data *wdata, struct file *filp) ...@@ -284,6 +284,29 @@ nfs3_proc_write(struct nfs_write_data *wdata, struct file *filp)
return status < 0? status : wdata->res.count; return status < 0? status : wdata->res.count;
} }
static int
nfs3_proc_commit(struct nfs_write_data *cdata, struct file *filp)
{
struct inode * inode = cdata->inode;
struct nfs_fattr * fattr = cdata->res.fattr;
struct rpc_message msg = {
.rpc_proc = &nfs3_procedures[NFS3PROC_COMMIT],
.rpc_argp = &cdata->args,
.rpc_resp = &cdata->res,
};
int status;
dprintk("NFS call commit %d @ %Ld\n", cdata->args.count,
(long long) cdata->args.offset);
fattr->valid = 0;
msg.rpc_cred = nfs_cred(inode, filp);
status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
if (status >= 0)
nfs3_write_refresh_inode(inode, fattr);
dprintk("NFS reply commit: %d\n", status);
return status;
}
/* /*
* Create a regular file. * Create a regular file.
* For now, we don't implement O_EXCL. * For now, we don't implement O_EXCL.
...@@ -883,6 +906,7 @@ struct nfs_rpc_ops nfs_v3_clientops = { ...@@ -883,6 +906,7 @@ struct nfs_rpc_ops nfs_v3_clientops = {
.readlink = nfs3_proc_readlink, .readlink = nfs3_proc_readlink,
.read = nfs3_proc_read, .read = nfs3_proc_read,
.write = nfs3_proc_write, .write = nfs3_proc_write,
.commit = nfs3_proc_commit,
.create = nfs3_proc_create, .create = nfs3_proc_create,
.remove = nfs3_proc_remove, .remove = nfs3_proc_remove,
.unlink_setup = nfs3_proc_unlink_setup, .unlink_setup = nfs3_proc_unlink_setup,
......
...@@ -1107,6 +1107,41 @@ nfs4_proc_write(struct nfs_write_data *wdata, struct file *filp) ...@@ -1107,6 +1107,41 @@ nfs4_proc_write(struct nfs_write_data *wdata, struct file *filp)
return status; return status;
} }
static int
nfs4_proc_commit(struct nfs_write_data *cdata, struct file *filp)
{
struct inode *inode = cdata->inode;
struct nfs_fattr *fattr = cdata->res.fattr;
struct nfs_server *server = NFS_SERVER(inode);
struct rpc_message msg = {
.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_COMMIT],
.rpc_argp = &cdata->args,
.rpc_resp = &cdata->res,
};
int status;
dprintk("NFS call commit %d @ %Ld\n", cdata->args.count,
(long long) cdata->args.offset);
/*
* Try first to use O_WRONLY, then O_RDWR stateid.
*/
if (filp) {
struct nfs4_state *state;
state = (struct nfs4_state *)filp->private_data;
memcpy(&cdata->args.stateid, &state->stateid, sizeof(cdata->args.stateid));
msg.rpc_cred = state->owner->so_cred;
} else {
memcpy(&cdata->args.stateid, &zero_stateid, sizeof(cdata->args.stateid));
msg.rpc_cred = NFS_I(inode)->mm_cred;
}
fattr->valid = 0;
status = rpc_call_sync(server->client, &msg, 0);
dprintk("NFS reply commit: %d\n", status);
return status;
}
/* /*
* Got race? * Got race?
* We will need to arrange for the VFS layer to provide an atomic open. * We will need to arrange for the VFS layer to provide an atomic open.
...@@ -1777,7 +1812,7 @@ struct nfs_rpc_ops nfs_v4_clientops = { ...@@ -1777,7 +1812,7 @@ struct nfs_rpc_ops nfs_v4_clientops = {
.readlink = nfs4_proc_readlink, .readlink = nfs4_proc_readlink,
.read = nfs4_proc_read, .read = nfs4_proc_read,
.write = nfs4_proc_write, .write = nfs4_proc_write,
.commit = NULL, .commit = nfs4_proc_commit,
.create = nfs4_proc_create, .create = nfs4_proc_create,
.remove = nfs4_proc_remove, .remove = nfs4_proc_remove,
.unlink_setup = nfs4_proc_unlink_setup, .unlink_setup = nfs4_proc_unlink_setup,
......
...@@ -639,8 +639,7 @@ struct nfs_rpc_ops { ...@@ -639,8 +639,7 @@ struct nfs_rpc_ops {
int (*readlink)(struct inode *, struct page *); int (*readlink)(struct inode *, struct page *);
int (*read) (struct nfs_read_data *, struct file *); int (*read) (struct nfs_read_data *, struct file *);
int (*write) (struct nfs_write_data *, struct file *); int (*write) (struct nfs_write_data *, struct file *);
int (*commit) (struct inode *, struct nfs_fattr *, int (*commit) (struct nfs_write_data *, struct file *);
unsigned long, unsigned int);
struct inode * (*create) (struct inode *, struct qstr *, struct inode * (*create) (struct inode *, struct qstr *,
struct iattr *, int); struct iattr *, int);
int (*remove) (struct inode *, struct qstr *); int (*remove) (struct inode *, struct qstr *);
......
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