]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
NFS: Fix a bug in nfs_fscache_release_page()
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Mon, 8 Feb 2010 14:32:27 +0000 (09:32 -0500)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 1 Apr 2010 22:55:51 +0000 (15:55 -0700)
commit 2c1740098c708b465e87637b237feb2fd98f129a upstream.

Not having an fscache cookie is perfectly valid if the user didn't mount
with the fscache option.

This patch fixes http://bugzilla.kernel.org/show_bug.cgi?id=15234

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/nfs/fscache.c

index 379be678cb7e00da65cc7327614cdd580136f7aa..a81d05b693f91df69e4b0628ed4bf4b028f936b7 100644 (file)
@@ -337,21 +337,20 @@ void nfs_fscache_reset_inode_cookie(struct inode *inode)
  */
 int nfs_fscache_release_page(struct page *page, gfp_t gfp)
 {
-       struct nfs_inode *nfsi = NFS_I(page->mapping->host);
-       struct fscache_cookie *cookie = nfsi->fscache;
-
-       BUG_ON(!cookie);
-
-       if (fscache_check_page_write(cookie, page)) {
-               if (!(gfp & __GFP_WAIT))
-                       return 0;
-               fscache_wait_on_page_write(cookie, page);
-       }
-
        if (PageFsCache(page)) {
+               struct nfs_inode *nfsi = NFS_I(page->mapping->host);
+               struct fscache_cookie *cookie = nfsi->fscache;
+
+               BUG_ON(!cookie);
                dfprintk(FSCACHE, "NFS: fscache releasepage (0x%p/0x%p/0x%p)\n",
                         cookie, page, nfsi);
 
+               if (fscache_check_page_write(cookie, page)) {
+                       if (!(gfp & __GFP_WAIT))
+                               return 0;
+                       fscache_wait_on_page_write(cookie, page);
+               }
+
                fscache_uncache_page(cookie, page);
                nfs_add_fscache_stats(page->mapping->host,
                                      NFSIOS_FSCACHE_PAGES_UNCACHED, 1);