[patch 5/6] ntfs: remove dependency on __GFP_NOFAIL

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: David Rientjes
Date: Monday, August 16, 2010 - 7:58 pm

Removes the dependency on __GFP_NOFAIL by looping indefinitely in the
caller.

Instead of maintaining a seperate _nofail() variant, it's possible to
remove it and use ntfs_malloc_nofs() instead.

Signed-off-by: David Rientjes <rientjes@google.com>
---
 fs/ntfs/malloc.h  |   17 -----------------
 fs/ntfs/runlist.c |    6 ++++--
 2 files changed, 4 insertions(+), 19 deletions(-)

diff --git a/fs/ntfs/malloc.h b/fs/ntfs/malloc.h
--- a/fs/ntfs/malloc.h
+++ b/fs/ntfs/malloc.h
@@ -66,23 +66,6 @@ static inline void *ntfs_malloc_nofs(unsigned long size)
 	return __ntfs_malloc(size, GFP_NOFS | __GFP_HIGHMEM);
 }
 
-/**
- * ntfs_malloc_nofs_nofail - allocate memory in multiples of pages
- * @size:	number of bytes to allocate
- *
- * Allocates @size bytes of memory, rounded up to multiples of PAGE_SIZE and
- * returns a pointer to the allocated memory.
- *
- * This function guarantees that the allocation will succeed.  It will sleep
- * for as long as it takes to complete the allocation.
- *
- * If there was insufficient memory to complete the request, return NULL.
- */
-static inline void *ntfs_malloc_nofs_nofail(unsigned long size)
-{
-	return __ntfs_malloc(size, GFP_NOFS | __GFP_HIGHMEM | __GFP_NOFAIL);
-}
-
 static inline void ntfs_free(void *addr)
 {
 	if (!is_vmalloc_addr(addr)) {
diff --git a/fs/ntfs/runlist.c b/fs/ntfs/runlist.c
--- a/fs/ntfs/runlist.c
+++ b/fs/ntfs/runlist.c
@@ -127,8 +127,10 @@ static inline runlist_element *ntfs_rl_realloc_nofail(runlist_element *rl,
 	if (old_size == new_size)
 		return rl;
 
-	new_rl = ntfs_malloc_nofs_nofail(new_size);
-	BUG_ON(!new_rl);
+	do {
+		/* FIXME: this may potentially loop forever */
+		new_rl = ntfs_malloc_nofs(new_size);
+	} while (!new_rl);
 
 	if (likely(rl != NULL)) {
 		if (unlikely(old_size > new_size))
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch 0/6] remove dependency on __GFP_NOFAIL, David Rientjes, (Mon Aug 16, 7:57 pm)
[patch 1/6] md: remove dependency on __GFP_NOFAIL, David Rientjes, (Mon Aug 16, 7:57 pm)
[patch 2/6] btrfs: remove dependency on __GFP_NOFAIL, David Rientjes, (Mon Aug 16, 7:57 pm)
[patch 3/6] gfs2: remove dependency on __GFP_NOFAIL, David Rientjes, (Mon Aug 16, 7:57 pm)
[patch 4/6] jbd: remove dependency on __GFP_NOFAIL, David Rientjes, (Mon Aug 16, 7:58 pm)
[patch 5/6] ntfs: remove dependency on __GFP_NOFAIL, David Rientjes, (Mon Aug 16, 7:58 pm)
[patch 6/6] reiserfs: remove dependency on __GFP_NOFAIL, David Rientjes, (Mon Aug 16, 7:58 pm)
Re: [patch 4/6] jbd: remove dependency on __GFP_NOFAIL, David Rientjes, (Tue Aug 17, 10:48 am)
Re: [patch 1/6] md: remove dependency on __GFP_NOFAIL, Andrew Morton, (Mon Aug 23, 12:26 pm)
Re: [patch 4/6] jbd: remove dependency on __GFP_NOFAIL, Andrew Morton, (Mon Aug 23, 12:28 pm)
Re: [patch 1/6] md: remove dependency on __GFP_NOFAIL, David Rientjes, (Mon Aug 23, 12:35 pm)
Re: [patch 1/6] md: remove dependency on __GFP_NOFAIL, Andrew Morton, (Mon Aug 23, 12:51 pm)
Re: [patch 1/6] md: remove dependency on __GFP_NOFAIL, Andrew Morton, (Mon Aug 23, 1:01 pm)
Re: [patch 1/6] md: remove dependency on __GFP_NOFAIL, David Rientjes, (Mon Aug 23, 1:03 pm)
Re: [patch 1/6] md: remove dependency on __GFP_NOFAIL, David Rientjes, (Mon Aug 23, 1:08 pm)
Re: [patch 1/6] md: remove dependency on __GFP_NOFAIL, Pekka Enberg, (Mon Aug 23, 1:09 pm)
Re: [patch 1/6] md: remove dependency on __GFP_NOFAIL, David Rientjes, (Mon Aug 23, 1:13 pm)
Re: [patch 1/6] md: remove dependency on __GFP_NOFAIL, Andrew Morton, (Mon Aug 23, 1:23 pm)
Re: [patch 1/6] md: remove dependency on __GFP_NOFAIL, Pekka Enberg, (Mon Aug 23, 1:29 pm)
Re: [patch 1/6] md: remove dependency on __GFP_NOFAIL, David Rientjes, (Mon Aug 23, 1:37 pm)
Re: [patch 1/6] md: remove dependency on __GFP_NOFAIL, David Rientjes, (Mon Aug 23, 1:40 pm)
Re: [patch 4/6] jbd: remove dependency on __GFP_NOFAIL, Andrew Morton, (Mon Aug 23, 3:11 pm)
Re: [patch 4/6] jbd: remove dependency on __GFP_NOFAIL, David Rientjes, (Mon Aug 23, 3:22 pm)