NFS: Simplify the nfs_read_completion functions
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 1 May 2012 16:49:58 +0000 (12:49 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 1 May 2012 19:42:22 +0000 (15:42 -0400)
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: Fred Isaman <iisaman@netapp.com>
fs/nfs/direct.c
fs/nfs/read.c

index f17e4695c84245258e1c60df2d7869a16bac447a..aab3016c437ce23e151353ade5493cdd00f2218e 100644 (file)
@@ -243,36 +243,28 @@ static void nfs_direct_read_completion(struct nfs_pgio_header *hdr)
                dreq->count += hdr->good_bytes;
        spin_unlock(&dreq->lock);
 
-       if (!test_bit(NFS_IOHDR_ERROR, &hdr->flags)) {
-               while (!list_empty(&hdr->pages)) {
-                       struct nfs_page *req = nfs_list_entry(hdr->pages.next);
-                       struct page *page = req->wb_page;
-
-                       if (test_bit(NFS_IOHDR_EOF, &hdr->flags)) {
-                               if (bytes > hdr->good_bytes)
-                                       zero_user(page, 0, PAGE_SIZE);
-                               else if (hdr->good_bytes - bytes < PAGE_SIZE)
-                                       zero_user_segment(page,
-                                               hdr->good_bytes & ~PAGE_MASK,
-                                               PAGE_SIZE);
-                       }
-                       bytes += req->wb_bytes;
-                       nfs_list_remove_request(req);
-                       if (!PageCompound(page))
-                               set_page_dirty(page);
-                       nfs_direct_readpage_release(req);
+       while (!list_empty(&hdr->pages)) {
+               struct nfs_page *req = nfs_list_entry(hdr->pages.next);
+               struct page *page = req->wb_page;
+
+               if (test_bit(NFS_IOHDR_EOF, &hdr->flags)) {
+                       if (bytes > hdr->good_bytes)
+                               zero_user(page, 0, PAGE_SIZE);
+                       else if (hdr->good_bytes - bytes < PAGE_SIZE)
+                               zero_user_segment(page,
+                                       hdr->good_bytes & ~PAGE_MASK,
+                                       PAGE_SIZE);
                }
-       } else {
-               while (!list_empty(&hdr->pages)) {
-                       struct nfs_page *req = nfs_list_entry(hdr->pages.next);
-
-                       if (bytes < hdr->good_bytes)
-                               if (!PageCompound(req->wb_page))
-                                       set_page_dirty(req->wb_page);
-                       bytes += req->wb_bytes;
-                       nfs_list_remove_request(req);
-                       nfs_direct_readpage_release(req);
+               if (!PageCompound(page)) {
+                       if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) {
+                               if (bytes < hdr->good_bytes)
+                                       set_page_dirty(page);
+                       } else
+                               set_page_dirty(page);
                }
+               bytes += req->wb_bytes;
+               nfs_list_remove_request(req);
+               nfs_direct_readpage_release(req);
        }
 out_put:
        if (put_dreq(dreq))
index 1961a192f1cb53d49895479bc7065950820714b5..37c9eb2930b0d816761f938b36e79d4952a70a5f 100644 (file)
@@ -179,34 +179,26 @@ static void nfs_read_completion(struct nfs_pgio_header *hdr)
 
        if (test_bit(NFS_IOHDR_REDO, &hdr->flags))
                goto out;
-       if (!test_bit(NFS_IOHDR_ERROR, &hdr->flags)) {
-               while (!list_empty(&hdr->pages)) {
-                       struct nfs_page *req = nfs_list_entry(hdr->pages.next);
-                       struct page *page = req->wb_page;
-
-                       if (test_bit(NFS_IOHDR_EOF, &hdr->flags)) {
-                               if (bytes > hdr->good_bytes)
-                                       zero_user(page, 0, PAGE_SIZE);
-                               else if (hdr->good_bytes - bytes < PAGE_SIZE)
-                                       zero_user_segment(page,
-                                               hdr->good_bytes & ~PAGE_MASK,
-                                               PAGE_SIZE);
-                       }
-                       SetPageUptodate(page);
-                       nfs_list_remove_request(req);
-                       nfs_readpage_release(req);
-                       bytes += PAGE_SIZE;
+       while (!list_empty(&hdr->pages)) {
+               struct nfs_page *req = nfs_list_entry(hdr->pages.next);
+               struct page *page = req->wb_page;
+
+               if (test_bit(NFS_IOHDR_EOF, &hdr->flags)) {
+                       if (bytes > hdr->good_bytes)
+                               zero_user(page, 0, PAGE_SIZE);
+                       else if (hdr->good_bytes - bytes < PAGE_SIZE)
+                               zero_user_segment(page,
+                                       hdr->good_bytes & ~PAGE_MASK,
+                                       PAGE_SIZE);
                }
-       } else {
-               while (!list_empty(&hdr->pages)) {
-                       struct nfs_page *req = nfs_list_entry(hdr->pages.next);
-
-                       bytes += req->wb_bytes;
+               bytes += req->wb_bytes;
+               if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) {
                        if (bytes <= hdr->good_bytes)
-                               SetPageUptodate(req->wb_page);
-                       nfs_list_remove_request(req);
-                       nfs_readpage_release(req);
-               }
+                               SetPageUptodate(page);
+               } else
+                       SetPageUptodate(page);
+               nfs_list_remove_request(req);
+               nfs_readpage_release(req);
        }
 out:
        hdr->release(hdr);