SUNRPC: Dont run rpcauth_cache_shrinker() when gfp_mask is GFP_NOFS
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Thu, 13 May 2010 16:51:03 +0000 (12:51 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Fri, 14 May 2010 19:09:34 +0000 (15:09 -0400)
Under some circumstances, put_rpccred() can end up allocating memory, so
check the gfp_mask to prevent deadlocks.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
net/sunrpc/auth.c

index 95afe79dd9d74ea14568f63a73a082ac31f9b887..0667a36aee7878c176f3c21d74305080305e0dc6 100644 (file)
@@ -270,6 +270,8 @@ rpcauth_cache_shrinker(int nr_to_scan, gfp_t gfp_mask)
        LIST_HEAD(free);
        int res;
 
+       if ((gfp_mask & GFP_KERNEL) != GFP_KERNEL)
+               return (nr_to_scan == 0) ? 0 : -1;
        if (list_empty(&cred_unused))
                return 0;
        spin_lock(&rpc_credcache_lock);