public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH 09/10] xfs: handle ENOMEM correctly during initialisation of perag structures
Date: Mon, 11 Jan 2010 22:47:48 +1100	[thread overview]
Message-ID: <1263210469-22171-10-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1263210469-22171-1-git-send-email-david@fromorbit.com>

Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 fs/xfs/xfs_mount.c |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 049dbc7..be643e5 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -432,11 +432,13 @@ xfs_initialize_perag(
 	xfs_agnumber_t	*maxagi)
 {
 	xfs_agnumber_t	index, max_metadata;
+	xfs_agnumber_t	first_initialised = 0;
 	xfs_perag_t	*pag;
 	xfs_agino_t	agino;
 	xfs_ino_t	ino;
 	xfs_sb_t	*sbp = &mp->m_sb;
 	xfs_ino_t	max_inum = XFS_MAXINUMBER_32;
+	int		error = -ENOMEM;
 
 	/* Check to see if the filesystem can overflow 32 bit inodes */
 	agino = XFS_OFFBNO_TO_AGINO(mp, sbp->sb_agblocks - 1, 0);
@@ -453,17 +455,20 @@ xfs_initialize_perag(
 			xfs_perag_put(pag);
 			continue;
 		}
+		if (!first_initialised)
+			first_initialised = index;
 		pag = kmem_zalloc(sizeof(*pag), KM_MAYFAIL);
 		if (!pag)
-			return -ENOMEM;
+			goto out_unwind;
 		if (radix_tree_preload(GFP_NOFS))
-			return -ENOMEM;
+			goto out_unwind;
 		spin_lock(&mp->m_perag_lock);
 		if (radix_tree_insert(&mp->m_perag_tree, index, pag)) {
 			BUG();
 			spin_unlock(&mp->m_perag_lock);
-			kmem_free(pag);
-			return -EEXIST;
+			radix_tree_preload_end();
+			error = -EEXIST;
+			goto out_unwind;
 		}
 		pag->pag_agno = index;
 		pag->pag_mount = mp;
@@ -523,6 +528,14 @@ xfs_initialize_perag(
 	if (maxagi)
 		*maxagi = index;
 	return 0;
+
+out_unwind:
+	kmem_free(pag);
+	for (; index > first_initialised; index--) {
+		pag = radix_tree_delete(&mp->m_perag_tree, index);
+		kmem_free(pag);
+	}
+	return error;
 }
 
 void
-- 
1.6.5

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2010-01-11 11:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-11 11:47 [PATCH 0/10] Perag lookup rework Dave Chinner
2010-01-11 11:47 ` [PATCH 01/10] XFS: rename xfs_get_perag Dave Chinner
2010-01-11 11:47 ` [PATCH 02/10] XFS: Don't directly reference m_perag in allocation code Dave Chinner
2010-01-11 11:47 ` [PATCH 03/10] XFS: Convert filestreams code to use per-ag get/put routines Dave Chinner
2010-01-11 11:47 ` [PATCH 04/10] XFS: convert remaining direct references to m_perag Dave Chinner
2010-01-11 11:47 ` [PATCH 05/10] XFS: Replace per-ag array with a radix tree Dave Chinner
2010-01-11 11:47 ` [PATCH 06/10] XFS: Reference count per-ag structures Dave Chinner
2010-01-11 11:47 ` [PATCH 07/10] XFS: Add trace points for per-ag refcount debugging Dave Chinner
2010-01-11 11:47 ` [PATCH 08/10] XFS: Kill filestreams cache flush Dave Chinner
2010-01-11 11:47 ` Dave Chinner [this message]
2010-01-11 11:47 ` [PATCH 10/10] xfs: embed the pagb_list array in the perag structure Dave Chinner
2010-01-11 22:33 ` [PATCH 0/10] Perag lookup rework Christoph Hellwig
2010-01-11 22:34 ` Christoph Hellwig
2010-01-14 18:42 ` Alex Elder
2010-01-14 22:37   ` Dave Chinner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1263210469-22171-10-git-send-email-david@fromorbit.com \
    --to=david@fromorbit.com \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox