--- Begin Message --- Adds consistency checks for nfs_page list operations
Signed-off-by: Trond Myklebust <Trond.Myklebust@xxxxxxxxxx>
---
fs/nfs/write.c | 8 ++++++--
include/linux/nfs_page.h | 3 +++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index cadbf3c..9be626d 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -194,6 +194,7 @@ static int nfs_writepage_setup(struct nfs_open_context *ctx, struct page *page,
nfs_grow_file(page, offset, count);
/* Set the PG_uptodate flag? */
nfs_mark_uptodate(page, offset, count);
+ WARN_ON(test_bit(PG_NEED_COMMIT,&(req)->wb_flags));
nfs_unlock_request(req);
return 0;
}
@@ -459,6 +460,7 @@ nfs_mark_request_commit(struct nfs_page *req)
struct inode *inode = req->wb_context->dentry->d_inode;
struct nfs_inode *nfsi = NFS_I(inode);
+ WARN_ON(nfs_dirty_request(req));
spin_lock(&nfsi->req_lock);
nfs_list_add_request(req, &nfsi->commit);
nfsi->ncommit++;
@@ -552,7 +554,7 @@ static void nfs_cancel_commit_list(struct list_head *head)
req = nfs_list_entry(head->next);
dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
nfs_list_remove_request(req);
- clear_bit(PG_NEED_COMMIT, &(req)->wb_flags);
+ WARN_ON(!test_and_clear_bit(PG_NEED_COMMIT,&(req)->wb_flags));
nfs_inode_remove_request(req);
nfs_unlock_request(req);
}
@@ -1033,6 +1035,7 @@ static void nfs_writeback_done_full(struct rpc_task *task, void *calldata)
if (nfs_write_need_commit(data)) {
memcpy(&req->wb_verf, &data->verf, sizeof(req->wb_verf));
+ set_bit(PG_NEED_COMMIT,&(req)->wb_flags);
nfs_mark_request_commit(req);
nfs_end_page_writeback(page);
dprintk(" marked for commit\n");
@@ -1206,6 +1209,7 @@ nfs_commit_list(struct inode *inode, struct list_head *head, int how)
nfs_list_remove_request(req);
nfs_mark_request_commit(req);
dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
+ WARN_ON(!test_and_clear_bit(PG_NEED_COMMIT,&(req)->wb_flags));
nfs_clear_page_writeback(req);
}
return -ENOMEM;
@@ -1229,7 +1233,7 @@ static void nfs_commit_done(struct rpc_task *task, void *calldata)
while (!list_empty(&data->pages)) {
req = nfs_list_entry(data->pages.next);
nfs_list_remove_request(req);
- clear_bit(PG_NEED_COMMIT, &(req)->wb_flags);
+ WARN_ON(!test_and_clear_bit(PG_NEED_COMMIT,&(req)->wb_flags));
dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
dprintk("NFS: commit (%s/%Ld %d@%Ld)",
diff --git a/include/linux/nfs_page.h b/include/linux/nfs_page.h
index 41afab6..75c2d34 100644
--- a/include/linux/nfs_page.h
+++ b/include/linux/nfs_page.h
@@ -116,6 +116,9 @@ nfs_lock_request(struct nfs_page *req)
static inline void
nfs_list_add_request(struct nfs_page *req, struct list_head *head)
{
+ BUG_ON(!list_empty(&req->wb_list));
+ BUG_ON(req->wb_list_head != NULL);
+
list_add_tail(&req->wb_list, head);
req->wb_list_head = head;
}
--- End Message ---