Skip to content

Commit

Permalink
NFS: Fix a potential deadlock in nfs_release_page
Browse files Browse the repository at this point in the history
nfs_wb_page() waits on request completion and, as a result, is not safe to be
called from nfs_release_page() invoked by VM scanner as part of GFP_NOFS
allocation. Fix possible deadlock by analyzing gfp mask and refusing to
release page if __GFP_FS is not set.

Signed-off-by: Nikita Danilov <danilov@gmail.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
(cherry picked from 374d969debfb290bafcb41d28918dc6f7e43ce31 commit)
  • Loading branch information
Nikita Danilov authored and Trond Myklebust committed Aug 24, 2006
1 parent ef7d1b2 commit ddeff52
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion fs/nfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,13 @@ static void nfs_invalidate_page(struct page *page, unsigned long offset)

static int nfs_release_page(struct page *page, gfp_t gfp)
{
return !nfs_wb_page(page->mapping->host, page);
if (gfp & __GFP_FS)
return !nfs_wb_page(page->mapping->host, page);
else
/*
* Avoid deadlock on nfs_wait_on_request().
*/
return 0;
}

const struct address_space_operations nfs_file_aops = {
Expand Down

0 comments on commit ddeff52

Please sign in to comment.