diff options
author | Weston Andros Adamson <dros@primarydata.com> | 2014-07-11 10:20:47 -0400 |
---|---|---|
committer | Trond Myklebust <trond.myklebust@primarydata.com> | 2014-07-12 16:51:41 -0400 |
commit | 84d3a9a913ba6a90c79b7763d063bb42554a8906 (patch) | |
tree | 20992323555fa558b35468eb0841b0811a241ec6 /fs/nfs/write.c | |
parent | 85710a837c2026aae80b7c64187edf1f10027b0b (diff) |
nfs: change find_request to find_head_request
nfs_page_find_request_locked* should find the head request for that page.
Rename the functions and add comments to make this clear, and fix a bug
that could return a subrequest when page_private isn't set on the page.
Signed-off-by: Weston Andros Adamson <dros@primarydata.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs/write.c')
-rw-r--r-- | fs/nfs/write.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 8e5745a4deff..53c4a9917dac 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
@@ -91,8 +91,15 @@ static void nfs_context_set_write_error(struct nfs_open_context *ctx, int error) | |||
91 | set_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags); | 91 | set_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags); |
92 | } | 92 | } |
93 | 93 | ||
94 | /* | ||
95 | * nfs_page_find_head_request_locked - find head request associated with @page | ||
96 | * | ||
97 | * must be called while holding the inode lock. | ||
98 | * | ||
99 | * returns matching head request with reference held, or NULL if not found. | ||
100 | */ | ||
94 | static struct nfs_page * | 101 | static struct nfs_page * |
95 | nfs_page_find_request_locked(struct nfs_inode *nfsi, struct page *page) | 102 | nfs_page_find_head_request_locked(struct nfs_inode *nfsi, struct page *page) |
96 | { | 103 | { |
97 | struct nfs_page *req = NULL; | 104 | struct nfs_page *req = NULL; |
98 | 105 | ||
@@ -104,25 +111,33 @@ nfs_page_find_request_locked(struct nfs_inode *nfsi, struct page *page) | |||
104 | /* Linearly search the commit list for the correct req */ | 111 | /* Linearly search the commit list for the correct req */ |
105 | list_for_each_entry_safe(freq, t, &nfsi->commit_info.list, wb_list) { | 112 | list_for_each_entry_safe(freq, t, &nfsi->commit_info.list, wb_list) { |
106 | if (freq->wb_page == page) { | 113 | if (freq->wb_page == page) { |
107 | req = freq; | 114 | req = freq->wb_head; |
108 | break; | 115 | break; |
109 | } | 116 | } |
110 | } | 117 | } |
111 | } | 118 | } |
112 | 119 | ||
113 | if (req) | 120 | if (req) { |
121 | WARN_ON_ONCE(req->wb_head != req); | ||
122 | |||
114 | kref_get(&req->wb_kref); | 123 | kref_get(&req->wb_kref); |
124 | } | ||
115 | 125 | ||
116 | return req; | 126 | return req; |
117 | } | 127 | } |
118 | 128 | ||
119 | static struct nfs_page *nfs_page_find_request(struct page *page) | 129 | /* |
130 | * nfs_page_find_head_request - find head request associated with @page | ||
131 | * | ||
132 | * returns matching head request with reference held, or NULL if not found. | ||
133 | */ | ||
134 | static struct nfs_page *nfs_page_find_head_request(struct page *page) | ||
120 | { | 135 | { |
121 | struct inode *inode = page_file_mapping(page)->host; | 136 | struct inode *inode = page_file_mapping(page)->host; |
122 | struct nfs_page *req = NULL; | 137 | struct nfs_page *req = NULL; |
123 | 138 | ||
124 | spin_lock(&inode->i_lock); | 139 | spin_lock(&inode->i_lock); |
125 | req = nfs_page_find_request_locked(NFS_I(inode), page); | 140 | req = nfs_page_find_head_request_locked(NFS_I(inode), page); |
126 | spin_unlock(&inode->i_lock); | 141 | spin_unlock(&inode->i_lock); |
127 | return req; | 142 | return req; |
128 | } | 143 | } |
@@ -282,7 +297,7 @@ static struct nfs_page *nfs_find_and_lock_request(struct page *page, bool nonblo | |||
282 | 297 | ||
283 | spin_lock(&inode->i_lock); | 298 | spin_lock(&inode->i_lock); |
284 | for (;;) { | 299 | for (;;) { |
285 | req = nfs_page_find_request_locked(NFS_I(inode), page); | 300 | req = nfs_page_find_head_request_locked(NFS_I(inode), page); |
286 | if (req == NULL) | 301 | if (req == NULL) |
287 | break; | 302 | break; |
288 | if (nfs_lock_request(req)) | 303 | if (nfs_lock_request(req)) |
@@ -773,7 +788,7 @@ static struct nfs_page *nfs_try_to_update_request(struct inode *inode, | |||
773 | spin_lock(&inode->i_lock); | 788 | spin_lock(&inode->i_lock); |
774 | 789 | ||
775 | for (;;) { | 790 | for (;;) { |
776 | req = nfs_page_find_request_locked(NFS_I(inode), page); | 791 | req = nfs_page_find_head_request_locked(NFS_I(inode), page); |
777 | if (req == NULL) | 792 | if (req == NULL) |
778 | goto out_unlock; | 793 | goto out_unlock; |
779 | 794 | ||
@@ -881,7 +896,7 @@ int nfs_flush_incompatible(struct file *file, struct page *page) | |||
881 | * dropped page. | 896 | * dropped page. |
882 | */ | 897 | */ |
883 | do { | 898 | do { |
884 | req = nfs_page_find_request(page); | 899 | req = nfs_page_find_head_request(page); |
885 | if (req == NULL) | 900 | if (req == NULL) |
886 | return 0; | 901 | return 0; |
887 | l_ctx = req->wb_lock_context; | 902 | l_ctx = req->wb_lock_context; |
@@ -1575,7 +1590,7 @@ int nfs_wb_page_cancel(struct inode *inode, struct page *page) | |||
1575 | 1590 | ||
1576 | for (;;) { | 1591 | for (;;) { |
1577 | wait_on_page_writeback(page); | 1592 | wait_on_page_writeback(page); |
1578 | req = nfs_page_find_request(page); | 1593 | req = nfs_page_find_head_request(page); |
1579 | if (req == NULL) | 1594 | if (req == NULL) |
1580 | break; | 1595 | break; |
1581 | if (nfs_lock_request(req)) { | 1596 | if (nfs_lock_request(req)) { |