提交 9bce008b 编写于 作者: T Trond Myklebust

NFS: Fix a commit bug

The new commit code fails to copy the verifier into the wb_verf field
of _all_ the nfs_page structures; it only copies it into the first entry.
The consequence is that most requests end up failing to match in
nfs_commit_release.

Fix is to copy the verifier into the req->wb_verf field in
nfs_write_completion.
Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
Cc: Fred Isaman <iisaman@netapp.com>
上级 cdf66442
...@@ -710,12 +710,12 @@ static void nfs_direct_write_completion(struct nfs_pgio_header *hdr) ...@@ -710,12 +710,12 @@ static void nfs_direct_write_completion(struct nfs_pgio_header *hdr)
if (dreq->flags == NFS_ODIRECT_RESCHED_WRITES) if (dreq->flags == NFS_ODIRECT_RESCHED_WRITES)
bit = NFS_IOHDR_NEED_RESCHED; bit = NFS_IOHDR_NEED_RESCHED;
else if (dreq->flags == 0) { else if (dreq->flags == 0) {
memcpy(&dreq->verf, &req->wb_verf, memcpy(&dreq->verf, hdr->verf,
sizeof(dreq->verf)); sizeof(dreq->verf));
bit = NFS_IOHDR_NEED_COMMIT; bit = NFS_IOHDR_NEED_COMMIT;
dreq->flags = NFS_ODIRECT_DO_COMMIT; dreq->flags = NFS_ODIRECT_DO_COMMIT;
} else if (dreq->flags == NFS_ODIRECT_DO_COMMIT) { } else if (dreq->flags == NFS_ODIRECT_DO_COMMIT) {
if (memcmp(&dreq->verf, &req->wb_verf, sizeof(dreq->verf))) { if (memcmp(&dreq->verf, hdr->verf, sizeof(dreq->verf))) {
dreq->flags = NFS_ODIRECT_RESCHED_WRITES; dreq->flags = NFS_ODIRECT_RESCHED_WRITES;
bit = NFS_IOHDR_NEED_RESCHED; bit = NFS_IOHDR_NEED_RESCHED;
} else } else
......
...@@ -80,6 +80,7 @@ struct nfs_write_header *nfs_writehdr_alloc(void) ...@@ -80,6 +80,7 @@ struct nfs_write_header *nfs_writehdr_alloc(void)
INIT_LIST_HEAD(&hdr->rpc_list); INIT_LIST_HEAD(&hdr->rpc_list);
spin_lock_init(&hdr->lock); spin_lock_init(&hdr->lock);
atomic_set(&hdr->refcnt, 0); atomic_set(&hdr->refcnt, 0);
hdr->verf = &p->verf;
} }
return p; return p;
} }
...@@ -619,6 +620,7 @@ static void nfs_write_completion(struct nfs_pgio_header *hdr) ...@@ -619,6 +620,7 @@ static void nfs_write_completion(struct nfs_pgio_header *hdr)
goto next; goto next;
} }
if (test_bit(NFS_IOHDR_NEED_COMMIT, &hdr->flags)) { if (test_bit(NFS_IOHDR_NEED_COMMIT, &hdr->flags)) {
memcpy(&req->wb_verf, hdr->verf, sizeof(req->wb_verf));
nfs_mark_request_commit(req, hdr->lseg, &cinfo); nfs_mark_request_commit(req, hdr->lseg, &cinfo);
goto next; goto next;
} }
...@@ -1255,15 +1257,14 @@ static void nfs_writeback_release_common(void *calldata) ...@@ -1255,15 +1257,14 @@ static void nfs_writeback_release_common(void *calldata)
struct nfs_write_data *data = calldata; struct nfs_write_data *data = calldata;
struct nfs_pgio_header *hdr = data->header; struct nfs_pgio_header *hdr = data->header;
int status = data->task.tk_status; int status = data->task.tk_status;
struct nfs_page *req = hdr->req;
if ((status >= 0) && nfs_write_need_commit(data)) { if ((status >= 0) && nfs_write_need_commit(data)) {
spin_lock(&hdr->lock); spin_lock(&hdr->lock);
if (test_bit(NFS_IOHDR_NEED_RESCHED, &hdr->flags)) if (test_bit(NFS_IOHDR_NEED_RESCHED, &hdr->flags))
; /* Do nothing */ ; /* Do nothing */
else if (!test_and_set_bit(NFS_IOHDR_NEED_COMMIT, &hdr->flags)) else if (!test_and_set_bit(NFS_IOHDR_NEED_COMMIT, &hdr->flags))
memcpy(&req->wb_verf, &data->verf, sizeof(req->wb_verf)); memcpy(hdr->verf, &data->verf, sizeof(*hdr->verf));
else if (memcmp(&req->wb_verf, &data->verf, sizeof(req->wb_verf))) else if (memcmp(hdr->verf, &data->verf, sizeof(*hdr->verf)))
set_bit(NFS_IOHDR_NEED_RESCHED, &hdr->flags); set_bit(NFS_IOHDR_NEED_RESCHED, &hdr->flags);
spin_unlock(&hdr->lock); spin_unlock(&hdr->lock);
} }
......
...@@ -1237,6 +1237,7 @@ struct nfs_pgio_header { ...@@ -1237,6 +1237,7 @@ struct nfs_pgio_header {
struct list_head rpc_list; struct list_head rpc_list;
atomic_t refcnt; atomic_t refcnt;
struct nfs_page *req; struct nfs_page *req;
struct nfs_writeverf *verf;
struct pnfs_layout_segment *lseg; struct pnfs_layout_segment *lseg;
loff_t io_start; loff_t io_start;
const struct rpc_call_ops *mds_ops; const struct rpc_call_ops *mds_ops;
...@@ -1274,6 +1275,7 @@ struct nfs_write_data { ...@@ -1274,6 +1275,7 @@ struct nfs_write_data {
struct nfs_write_header { struct nfs_write_header {
struct nfs_pgio_header header; struct nfs_pgio_header header;
struct nfs_write_data rpc_data; struct nfs_write_data rpc_data;
struct nfs_writeverf verf;
}; };
struct nfs_mds_commit_info { struct nfs_mds_commit_info {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册