NFS: Fix a bogus warning in nfs_generic_pgio
authorTrond Myklebust <trond.myklebust@primarydata.com>
Mon, 13 Oct 2014 14:56:12 +0000 (10:56 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 Oct 2014 16:40:14 +0000 (09:40 -0700)
commit b8fb9c30f25e45dab5d2cd310ab6913b6861d00f upstream.

It is OK for pageused == pagecount in the loop, as long as we don't add
another entry to the *pages array. Move the test so that it only triggers
in that case.

Reported-by: Steve Dickson <SteveD@redhat.com>
Fixes: bba5c1887a92 (nfs: disallow duplicate pages in pgio page vectors)
Cc: Weston Andros Adamson <dros@primarydata.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/nfs/pagelist.c

index 0a26b40eda3bc3a787c0efc4216e657da16cddd3..3a9c34a0f898bb17c19dcd7d8322c2d724e2ecdb 100644 (file)
@@ -754,12 +754,11 @@ int nfs_generic_pgio(struct nfs_pageio_descriptor *desc,
                nfs_list_remove_request(req);
                nfs_list_add_request(req, &hdr->pages);
 
-               if (WARN_ON_ONCE(pageused >= pagecount))
-                       return nfs_pgio_error(desc, hdr);
-
                if (!last_page || last_page != req->wb_page) {
-                       *pages++ = last_page = req->wb_page;
                        pageused++;
+                       if (pageused > pagecount)
+                               break;
+                       *pages++ = last_page = req->wb_page;
                }
        }
        if (WARN_ON_ONCE(pageused != pagecount))