xfs
[Top] [All Lists]

Re: [PATCH] xfs: prevent deadlock in xfs_qm_shake()

To: Felix Blyakher <felixb@xxxxxxx>
Subject: Re: [PATCH] xfs: prevent deadlock in xfs_qm_shake()
From: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Date: Fri, 29 May 2009 15:25:29 -0400
Cc: xfs@xxxxxxxxxxx, Hedi Berriche <hedi@xxxxxxx>
In-reply-to: <1243620631-10749-2-git-send-email-felixb@xxxxxxx>
References: <1243620631-10749-1-git-send-email-felixb@xxxxxxx> <1243620631-10749-2-git-send-email-felixb@xxxxxxx>
User-agent: Mutt/1.5.18 (2008-05-17)
On Fri, May 29, 2009 at 01:10:31PM -0500, Felix Blyakher wrote:
> It's possible to recurse into filesystem from the memory
> allocation, which deadlocks in xfs_qm_shake(). Add check
> for __GFP_FS, and bailout if it is not set.
> 
> Signed-off-by: Felix Blyakher <felixb@xxxxxxx>
> Signed-off-by: Hedi Berriche <hedi@xxxxxxx>
> ---
>  fs/xfs/linux-2.6/kmem.h |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/xfs/linux-2.6/kmem.h b/fs/xfs/linux-2.6/kmem.h
> index af6843c..d8d2321 100644
> --- a/fs/xfs/linux-2.6/kmem.h
> +++ b/fs/xfs/linux-2.6/kmem.h
> @@ -103,7 +103,7 @@ extern void *kmem_zone_zalloc(kmem_zone_t *, unsigned int 
> __nocast);
>  static inline int
>  kmem_shake_allow(gfp_t gfp_mask)
>  {
> -     return (gfp_mask & __GFP_WAIT) != 0;
> +     return ((gfp_mask & __GFP_WAIT && gfp_mask & __GFP_FS) != 0;

Looks good to me.  But this could be written simpler as:

        return ((gfp_mask & (__GFP_WAIT|__GFP_FS)) != 0;

<Prev in Thread] Current Thread [Next in Thread>