提交 6b8d84e2 编写于 作者: O Olga Kornievskaia 提交者: Anna Schumaker

NFS add a simple sync nfs4_proc_commit after async COPY

A COPY with unstable write data needs a simple sync commit.
Filehandle value is gotten as a part of the inner loop so in
case of a reboot retry it should get the new value.
Signed-off-by: NOlga Kornievskaia <kolga@netapp.com>
Signed-off-by: NAnna Schumaker <Anna.Schumaker@Netapp.com>
上级 539f57b3
...@@ -185,6 +185,30 @@ static int handle_async_copy(struct nfs42_copy_res *res, ...@@ -185,6 +185,30 @@ static int handle_async_copy(struct nfs42_copy_res *res,
return status; return status;
} }
static int process_copy_commit(struct file *dst, loff_t pos_dst,
struct nfs42_copy_res *res)
{
struct nfs_commitres cres;
int status = -ENOMEM;
cres.verf = kzalloc(sizeof(struct nfs_writeverf), GFP_NOFS);
if (!cres.verf)
goto out;
status = nfs4_proc_commit(dst, pos_dst, res->write_res.count, &cres);
if (status)
goto out_free;
if (nfs_write_verifier_cmp(&res->write_res.verifier.verifier,
&cres.verf->verifier)) {
dprintk("commit verf differs from copy verf\n");
status = -EAGAIN;
}
out_free:
kfree(cres.verf);
out:
return status;
}
static ssize_t _nfs42_proc_copy(struct file *src, static ssize_t _nfs42_proc_copy(struct file *src,
struct nfs_lock_context *src_lock, struct nfs_lock_context *src_lock,
struct file *dst, struct file *dst,
...@@ -251,6 +275,13 @@ static ssize_t _nfs42_proc_copy(struct file *src, ...@@ -251,6 +275,13 @@ static ssize_t _nfs42_proc_copy(struct file *src,
return status; return status;
} }
if ((!res->synchronous || !args->sync) &&
res->write_res.verifier.committed != NFS_FILE_SYNC) {
status = process_copy_commit(dst, pos_dst, res);
if (status)
return status;
}
truncate_pagecache_range(dst_inode, pos_dst, truncate_pagecache_range(dst_inode, pos_dst,
pos_dst + res->write_res.count); pos_dst + res->write_res.count);
......
...@@ -508,7 +508,7 @@ extern int nfs4_sequence_done(struct rpc_task *task, ...@@ -508,7 +508,7 @@ extern int nfs4_sequence_done(struct rpc_task *task,
struct nfs4_sequence_res *res); struct nfs4_sequence_res *res);
extern void nfs4_free_lock_state(struct nfs_server *server, struct nfs4_lock_state *lsp); extern void nfs4_free_lock_state(struct nfs_server *server, struct nfs4_lock_state *lsp);
extern int nfs4_proc_commit(struct file *dst, __u64 offset, __u32 count, struct nfs_commitres *res);
extern const nfs4_stateid zero_stateid; extern const nfs4_stateid zero_stateid;
extern const nfs4_stateid invalid_stateid; extern const nfs4_stateid invalid_stateid;
......
...@@ -5137,6 +5137,40 @@ static void nfs4_proc_commit_setup(struct nfs_commit_data *data, struct rpc_mess ...@@ -5137,6 +5137,40 @@ static void nfs4_proc_commit_setup(struct nfs_commit_data *data, struct rpc_mess
nfs4_state_protect(server->nfs_client, NFS_SP4_MACH_CRED_COMMIT, clnt, msg); nfs4_state_protect(server->nfs_client, NFS_SP4_MACH_CRED_COMMIT, clnt, msg);
} }
static int _nfs4_proc_commit(struct file *dst, struct nfs_commitargs *args,
struct nfs_commitres *res)
{
struct inode *dst_inode = file_inode(dst);
struct nfs_server *server = NFS_SERVER(dst_inode);
struct rpc_message msg = {
.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_COMMIT],
.rpc_argp = args,
.rpc_resp = res,
};
args->fh = NFS_FH(dst_inode);
return nfs4_call_sync(server->client, server, &msg,
&args->seq_args, &res->seq_res, 1);
}
int nfs4_proc_commit(struct file *dst, __u64 offset, __u32 count, struct nfs_commitres *res)
{
struct nfs_commitargs args = {
.offset = offset,
.count = count,
};
struct nfs_server *dst_server = NFS_SERVER(file_inode(dst));
struct nfs4_exception exception = { };
int status;
do {
status = _nfs4_proc_commit(dst, &args, res);
status = nfs4_handle_exception(dst_server, status, &exception);
} while (exception.retry);
return status;
}
struct nfs4_renewdata { struct nfs4_renewdata {
struct nfs_client *client; struct nfs_client *client;
unsigned long timestamp; unsigned long timestamp;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册