[patch 3/6] gfs2: remove dependency on __GFP_NOFAIL

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

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

Signed-off-by: David Rientjes <rientjes@google.com>
---
 fs/gfs2/log.c     |   10 ++++++++--
 fs/gfs2/meta_io.c |    5 ++++-
 fs/gfs2/rgrp.c    |   27 +++++++++++++++------------
 3 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -523,7 +523,10 @@ struct buffer_head *gfs2_log_fake_buf(struct gfs2_sbd *sdp,
 	u64 blkno = log_bmap(sdp, sdp->sd_log_flush_head);
 	struct buffer_head *bh;
 
-	bh = alloc_buffer_head(GFP_NOFS | __GFP_NOFAIL);
+	do {
+		/* FIXME: this may potentially loop forever */
+		bh = alloc_buffer_head(GFP_NOFS);
+	} while (!bh);
 	atomic_set(&bh->b_count, 1);
 	bh->b_state = (1 << BH_Mapped) | (1 << BH_Uptodate) | (1 << BH_Lock);
 	set_bh_page(bh, real->b_page, bh_offset(real));
@@ -709,7 +712,10 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl)
 	}
 	trace_gfs2_log_flush(sdp, 1);
 
-	ai = kzalloc(sizeof(struct gfs2_ail), GFP_NOFS | __GFP_NOFAIL);
+	do {
+		/* FIXME: this may potentially loop forever */
+		ai = kzalloc(sizeof(struct gfs2_ail), GFP_NOFS);
+	} while (!ai);
 	INIT_LIST_HEAD(&ai->ai_ail1_list);
 	INIT_LIST_HEAD(&ai->ai_ail2_list);
 
diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c
--- a/fs/gfs2/meta_io.c
+++ b/fs/gfs2/meta_io.c
@@ -289,7 +289,10 @@ void gfs2_attach_bufdata(struct gfs2_glock *gl, struct buffer_head *bh,
 		return;
 	}
 
-	bd = kmem_cache_zalloc(gfs2_bufdata_cachep, GFP_NOFS | __GFP_NOFAIL);
+	do {
+		/* FIXME: this may potentially loop forever */
+		bd = kmem_cache_zalloc(gfs2_bufdata_cachep, GFP_NOFS);
+	} while (!bd);
 	bd->bd_bh = bh;
 	bd->bd_gl = gl;
 
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -1440,8 +1440,11 @@ static struct gfs2_rgrpd *rgblk_free(struct gfs2_sbd *sdp, u64 bstart,
 		rgrp_blk++;
 
 		if (!bi->bi_clone) {
-			bi->bi_clone = kmalloc(bi->bi_bh->b_size,
-					       GFP_NOFS | __GFP_NOFAIL);
+			do {
+				/* FIXME: this may potentially loop forever */
+				bi->bi_clone = kmalloc(bi->bi_bh->b_size,
+								GFP_NOFS);
+			} while (!bi->bi_clone);
 			memcpy(bi->bi_clone + bi->bi_offset,
 			       bi->bi_bh->b_data + bi->bi_offset,
 			       bi->bi_len);
@@ -1759,9 +1762,6 @@ fail:
  * @block: the block
  *
  * Figure out what RG a block belongs to and add that RG to the list
- *
- * FIXME: Don't use NOFAIL
- *
  */
 
 void gfs2_rlist_add(struct gfs2_sbd *sdp, struct gfs2_rgrp_list *rlist,
@@ -1789,8 +1789,11 @@ void gfs2_rlist_add(struct gfs2_sbd *sdp, struct gfs2_rgrp_list *rlist,
 	if (rlist->rl_rgrps == rlist->rl_space) {
 		new_space = rlist->rl_space + 10;
 
-		tmp = kcalloc(new_space, sizeof(struct gfs2_rgrpd *),
-			      GFP_NOFS | __GFP_NOFAIL);
+		do {
+			/* FIXME: this may potentially loop forever */
+			tmp = kcalloc(new_space, sizeof(struct gfs2_rgrpd *),
+					GFP_NOFS);
+		} while (!tmp);
 
 		if (rlist->rl_rgd) {
 			memcpy(tmp, rlist->rl_rgd,
@@ -1811,17 +1814,17 @@ void gfs2_rlist_add(struct gfs2_sbd *sdp, struct gfs2_rgrp_list *rlist,
  * @rlist: the list of resource groups
  * @state: the lock state to acquire the RG lock in
  * @flags: the modifier flags for the holder structures
- *
- * FIXME: Don't use NOFAIL
- *
  */
 
 void gfs2_rlist_alloc(struct gfs2_rgrp_list *rlist, unsigned int state)
 {
 	unsigned int x;
 
-	rlist->rl_ghs = kcalloc(rlist->rl_rgrps, sizeof(struct gfs2_holder),
-				GFP_NOFS | __GFP_NOFAIL);
+	do {
+		/* FIXME: this may potentially loop forever */
+		rlist->rl_ghs = kcalloc(rlist->rl_rgrps,
+					sizeof(struct gfs2_holder), GFP_NOFS);
+	} while (!rlist->rl_ghs);
 	for (x = 0; x < rlist->rl_rgrps; x++)
 		gfs2_holder_init(rlist->rl_rgd[x]->rd_gl,
 				state, 0,
--
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)