diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-05-01 12:49:58 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-05-01 15:42:22 -0400 |
commit | 4bd8b010136afa0df9122a08bad361686bda0a1d (patch) | |
tree | a23c23299e4468baa0927d44992d2bd9da59579c | |
parent | 25b11dcdbfcad69a5ec03265e2dce19e5eca936b (diff) |
NFS: Simplify the nfs_read_completion functions
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: Fred Isaman <iisaman@netapp.com>
-rw-r--r-- | fs/nfs/direct.c | 48 | ||||
-rw-r--r-- | fs/nfs/read.c | 44 |
2 files changed, 38 insertions, 54 deletions
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index f17e4695c842..aab3016c437c 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c | |||
@@ -243,36 +243,28 @@ static void nfs_direct_read_completion(struct nfs_pgio_header *hdr) | |||
243 | dreq->count += hdr->good_bytes; | 243 | dreq->count += hdr->good_bytes; |
244 | spin_unlock(&dreq->lock); | 244 | spin_unlock(&dreq->lock); |
245 | 245 | ||
246 | if (!test_bit(NFS_IOHDR_ERROR, &hdr->flags)) { | 246 | while (!list_empty(&hdr->pages)) { |
247 | while (!list_empty(&hdr->pages)) { | 247 | struct nfs_page *req = nfs_list_entry(hdr->pages.next); |
248 | struct nfs_page *req = nfs_list_entry(hdr->pages.next); | 248 | struct page *page = req->wb_page; |
249 | struct page *page = req->wb_page; | 249 | |
250 | 250 | if (test_bit(NFS_IOHDR_EOF, &hdr->flags)) { | |
251 | if (test_bit(NFS_IOHDR_EOF, &hdr->flags)) { | 251 | if (bytes > hdr->good_bytes) |
252 | if (bytes > hdr->good_bytes) | 252 | zero_user(page, 0, PAGE_SIZE); |
253 | zero_user(page, 0, PAGE_SIZE); | 253 | else if (hdr->good_bytes - bytes < PAGE_SIZE) |
254 | else if (hdr->good_bytes - bytes < PAGE_SIZE) | 254 | zero_user_segment(page, |
255 | zero_user_segment(page, | 255 | hdr->good_bytes & ~PAGE_MASK, |
256 | hdr->good_bytes & ~PAGE_MASK, | 256 | PAGE_SIZE); |
257 | PAGE_SIZE); | ||
258 | } | ||
259 | bytes += req->wb_bytes; | ||
260 | nfs_list_remove_request(req); | ||
261 | if (!PageCompound(page)) | ||
262 | set_page_dirty(page); | ||
263 | nfs_direct_readpage_release(req); | ||
264 | } | 257 | } |
265 | } else { | 258 | if (!PageCompound(page)) { |
266 | while (!list_empty(&hdr->pages)) { | 259 | if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) { |
267 | struct nfs_page *req = nfs_list_entry(hdr->pages.next); | 260 | if (bytes < hdr->good_bytes) |
268 | 261 | set_page_dirty(page); | |
269 | if (bytes < hdr->good_bytes) | 262 | } else |
270 | if (!PageCompound(req->wb_page)) | 263 | set_page_dirty(page); |
271 | set_page_dirty(req->wb_page); | ||
272 | bytes += req->wb_bytes; | ||
273 | nfs_list_remove_request(req); | ||
274 | nfs_direct_readpage_release(req); | ||
275 | } | 264 | } |
265 | bytes += req->wb_bytes; | ||
266 | nfs_list_remove_request(req); | ||
267 | nfs_direct_readpage_release(req); | ||
276 | } | 268 | } |
277 | out_put: | 269 | out_put: |
278 | if (put_dreq(dreq)) | 270 | if (put_dreq(dreq)) |
diff --git a/fs/nfs/read.c b/fs/nfs/read.c index 1961a192f1cb..37c9eb2930b0 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c | |||
@@ -179,34 +179,26 @@ static void nfs_read_completion(struct nfs_pgio_header *hdr) | |||
179 | 179 | ||
180 | if (test_bit(NFS_IOHDR_REDO, &hdr->flags)) | 180 | if (test_bit(NFS_IOHDR_REDO, &hdr->flags)) |
181 | goto out; | 181 | goto out; |
182 | if (!test_bit(NFS_IOHDR_ERROR, &hdr->flags)) { | 182 | while (!list_empty(&hdr->pages)) { |
183 | while (!list_empty(&hdr->pages)) { | 183 | struct nfs_page *req = nfs_list_entry(hdr->pages.next); |
184 | struct nfs_page *req = nfs_list_entry(hdr->pages.next); | 184 | struct page *page = req->wb_page; |
185 | struct page *page = req->wb_page; | 185 | |
186 | 186 | if (test_bit(NFS_IOHDR_EOF, &hdr->flags)) { | |
187 | if (test_bit(NFS_IOHDR_EOF, &hdr->flags)) { | 187 | if (bytes > hdr->good_bytes) |
188 | if (bytes > hdr->good_bytes) | 188 | zero_user(page, 0, PAGE_SIZE); |
189 | zero_user(page, 0, PAGE_SIZE); | 189 | else if (hdr->good_bytes - bytes < PAGE_SIZE) |
190 | else if (hdr->good_bytes - bytes < PAGE_SIZE) | 190 | zero_user_segment(page, |
191 | zero_user_segment(page, | 191 | hdr->good_bytes & ~PAGE_MASK, |
192 | hdr->good_bytes & ~PAGE_MASK, | 192 | PAGE_SIZE); |
193 | PAGE_SIZE); | ||
194 | } | ||
195 | SetPageUptodate(page); | ||
196 | nfs_list_remove_request(req); | ||
197 | nfs_readpage_release(req); | ||
198 | bytes += PAGE_SIZE; | ||
199 | } | 193 | } |
200 | } else { | 194 | bytes += req->wb_bytes; |
201 | while (!list_empty(&hdr->pages)) { | 195 | if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) { |
202 | struct nfs_page *req = nfs_list_entry(hdr->pages.next); | ||
203 | |||
204 | bytes += req->wb_bytes; | ||
205 | if (bytes <= hdr->good_bytes) | 196 | if (bytes <= hdr->good_bytes) |
206 | SetPageUptodate(req->wb_page); | 197 | SetPageUptodate(page); |
207 | nfs_list_remove_request(req); | 198 | } else |
208 | nfs_readpage_release(req); | 199 | SetPageUptodate(page); |
209 | } | 200 | nfs_list_remove_request(req); |
201 | nfs_readpage_release(req); | ||
210 | } | 202 | } |
211 | out: | 203 | out: |
212 | hdr->release(hdr); | 204 | hdr->release(hdr); |