aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2007-04-20 16:12:34 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-04-21 01:56:29 -0400
commit8e821cad12e80cd1a8a3fbadf91f62f17f32549e (patch)
tree7a3755731152198410008921b3a2b8e7015e5f0e /fs
parent7ab77e03c1f665d5dee78f1248fffd11fa0c5154 (diff)
NFS: clean up the unstable write code
Get rid of the inlined #ifdefs. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfs/write.c117
1 files changed, 71 insertions, 46 deletions
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index ad2e91b4904f..3ed4feb8c856 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -460,6 +460,43 @@ nfs_mark_request_commit(struct nfs_page *req)
460 inc_zone_page_state(req->wb_page, NR_UNSTABLE_NFS); 460 inc_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
461 __mark_inode_dirty(inode, I_DIRTY_DATASYNC); 461 __mark_inode_dirty(inode, I_DIRTY_DATASYNC);
462} 462}
463
464static inline
465int nfs_write_need_commit(struct nfs_write_data *data)
466{
467 return data->verf.committed != NFS_FILE_SYNC;
468}
469
470static inline
471int nfs_reschedule_unstable_write(struct nfs_page *req)
472{
473 if (test_and_clear_bit(PG_NEED_COMMIT, &req->wb_flags)) {
474 nfs_mark_request_commit(req);
475 return 1;
476 }
477 if (test_and_clear_bit(PG_NEED_RESCHED, &req->wb_flags)) {
478 nfs_redirty_request(req);
479 return 1;
480 }
481 return 0;
482}
483#else
484static inline void
485nfs_mark_request_commit(struct nfs_page *req)
486{
487}
488
489static inline
490int nfs_write_need_commit(struct nfs_write_data *data)
491{
492 return 0;
493}
494
495static inline
496int nfs_reschedule_unstable_write(struct nfs_page *req)
497{
498 return 0;
499}
463#endif 500#endif
464 501
465/* 502/*
@@ -746,26 +783,12 @@ int nfs_updatepage(struct file *file, struct page *page,
746 783
747static void nfs_writepage_release(struct nfs_page *req) 784static void nfs_writepage_release(struct nfs_page *req)
748{ 785{
749 nfs_end_page_writeback(req->wb_page);
750 786
751#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4) 787 if (PageError(req->wb_page) || !nfs_reschedule_unstable_write(req)) {
752 if (!PageError(req->wb_page)) { 788 nfs_end_page_writeback(req->wb_page);
753 if (NFS_NEED_RESCHED(req)) { 789 nfs_inode_remove_request(req);
754 nfs_redirty_request(req); 790 } else
755 goto out; 791 nfs_end_page_writeback(req->wb_page);
756 } else if (NFS_NEED_COMMIT(req)) {
757 nfs_mark_request_commit(req);
758 goto out;
759 }
760 }
761 nfs_inode_remove_request(req);
762
763out:
764 nfs_clear_commit(req);
765 nfs_clear_reschedule(req);
766#else
767 nfs_inode_remove_request(req);
768#endif
769 nfs_clear_page_writeback(req); 792 nfs_clear_page_writeback(req);
770} 793}
771 794
@@ -1008,22 +1031,28 @@ static void nfs_writeback_done_partial(struct rpc_task *task, void *calldata)
1008 nfs_set_pageerror(page); 1031 nfs_set_pageerror(page);
1009 req->wb_context->error = task->tk_status; 1032 req->wb_context->error = task->tk_status;
1010 dprintk(", error = %d\n", task->tk_status); 1033 dprintk(", error = %d\n", task->tk_status);
1011 } else { 1034 goto out;
1012#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
1013 if (data->verf.committed < NFS_FILE_SYNC) {
1014 if (!NFS_NEED_COMMIT(req)) {
1015 nfs_defer_commit(req);
1016 memcpy(&req->wb_verf, &data->verf, sizeof(req->wb_verf));
1017 dprintk(" defer commit\n");
1018 } else if (memcmp(&req->wb_verf, &data->verf, sizeof(req->wb_verf))) {
1019 nfs_defer_reschedule(req);
1020 dprintk(" server reboot detected\n");
1021 }
1022 } else
1023#endif
1024 dprintk(" OK\n");
1025 } 1035 }
1026 1036
1037 if (nfs_write_need_commit(data)) {
1038 spinlock_t *req_lock = &NFS_I(page->mapping->host)->req_lock;
1039
1040 spin_lock(req_lock);
1041 if (test_bit(PG_NEED_RESCHED, &req->wb_flags)) {
1042 /* Do nothing we need to resend the writes */
1043 } else if (!test_and_set_bit(PG_NEED_COMMIT, &req->wb_flags)) {
1044 memcpy(&req->wb_verf, &data->verf, sizeof(req->wb_verf));
1045 dprintk(" defer commit\n");
1046 } else if (memcmp(&req->wb_verf, &data->verf, sizeof(req->wb_verf))) {
1047 set_bit(PG_NEED_RESCHED, &req->wb_flags);
1048 clear_bit(PG_NEED_COMMIT, &req->wb_flags);
1049 dprintk(" server reboot detected\n");
1050 }
1051 spin_unlock(req_lock);
1052 } else
1053 dprintk(" OK\n");
1054
1055out:
1027 if (atomic_dec_and_test(&req->wb_complete)) 1056 if (atomic_dec_and_test(&req->wb_complete))
1028 nfs_writepage_release(req); 1057 nfs_writepage_release(req);
1029} 1058}
@@ -1064,25 +1093,21 @@ static void nfs_writeback_done_full(struct rpc_task *task, void *calldata)
1064 if (task->tk_status < 0) { 1093 if (task->tk_status < 0) {
1065 nfs_set_pageerror(page); 1094 nfs_set_pageerror(page);
1066 req->wb_context->error = task->tk_status; 1095 req->wb_context->error = task->tk_status;
1067 nfs_end_page_writeback(page);
1068 nfs_inode_remove_request(req);
1069 dprintk(", error = %d\n", task->tk_status); 1096 dprintk(", error = %d\n", task->tk_status);
1070 goto next; 1097 goto remove_request;
1071 } 1098 }
1072 nfs_end_page_writeback(page);
1073 1099
1074#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4) 1100 if (nfs_write_need_commit(data)) {
1075 if (data->args.stable != NFS_UNSTABLE || data->verf.committed == NFS_FILE_SYNC) { 1101 memcpy(&req->wb_verf, &data->verf, sizeof(req->wb_verf));
1076 nfs_inode_remove_request(req); 1102 nfs_mark_request_commit(req);
1077 dprintk(" OK\n"); 1103 nfs_end_page_writeback(page);
1104 dprintk(" marked for commit\n");
1078 goto next; 1105 goto next;
1079 } 1106 }
1080 memcpy(&req->wb_verf, &data->verf, sizeof(req->wb_verf)); 1107 dprintk(" OK\n");
1081 nfs_mark_request_commit(req); 1108remove_request:
1082 dprintk(" marked for commit\n"); 1109 nfs_end_page_writeback(page);
1083#else
1084 nfs_inode_remove_request(req); 1110 nfs_inode_remove_request(req);
1085#endif
1086 next: 1111 next:
1087 nfs_clear_page_writeback(req); 1112 nfs_clear_page_writeback(req);
1088 } 1113 }