xfs
[Top] [All Lists]

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

To: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Subject: Re: [PATCH] xfs: prevent deadlock in xfs_qm_shake()
From: Felix Blyakher <felixb@xxxxxxx>
Date: Fri, 29 May 2009 14:29:50 -0500
Cc: xfs@xxxxxxxxxxx, Hedi Berriche <hedi@xxxxxxx>
In-reply-to: <20090529192529.GA1599@xxxxxxxxxxxxx>
References: <1243620631-10749-1-git-send-email-felixb@xxxxxxx> <1243620631-10749-2-git-send-email-felixb@xxxxxxx> <20090529192529.GA1599@xxxxxxxxxxxxx>

On May 29, 2009, at 2:25 PM, Christoph Hellwig wrote:

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;

Yeah, sure. Weird it didn't occur to me :)

Thanks,
Felix

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