From eafc897d59e7e8fba66fa186ea613008f7200d33 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 4 Jul 2012 10:54:48 -0400 Subject: [PATCH] --- yaml --- r: 319859 b: refs/heads/master c: 4bb61069d2019dea2a7e4e0f4432101f03a9b820 h: refs/heads/master i: 319857: 35f8ee83c164b4aa4d2f23b6bd0f0727edf9889e 319855: 9fc9b4784675428a35e7250de15993ee581fe92f v: v3 --- [refs] | 2 +- trunk/fs/xfs/xfs_ialloc.c | 47 ++++++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/[refs] b/[refs] index ae13d5ae1656..0763fab3fa53 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 08358906ed78f6ab4d3ff8e4fd1b87b9a4aea645 +refs/heads/master: 4bb61069d2019dea2a7e4e0f4432101f03a9b820 diff --git a/trunk/fs/xfs/xfs_ialloc.c b/trunk/fs/xfs/xfs_ialloc.c index 2b70952c9d8c..7aa8a02b7937 100644 --- a/trunk/fs/xfs/xfs_ialloc.c +++ b/trunk/fs/xfs/xfs_ialloc.c @@ -634,6 +634,10 @@ xfs_dialloc_ag( pag = xfs_perag_get(mp, agno); + ASSERT(pag->pagi_init); + ASSERT(pag->pagi_inodeok); + ASSERT(pag->pagi_freecount > 0); + restart_pagno: cur = xfs_inobt_init_cursor(mp, tp, agbp, agno); /* @@ -907,32 +911,32 @@ xfs_dialloc( xfs_agnumber_t tagno; struct xfs_perag *pag; - if (*IO_agbp == NULL) { - /* - * We do not have an agbp, so select an initial allocation - * group for inode allocation. - */ - agbp = xfs_ialloc_ag_select(tp, parent, mode, okalloc); + if (*IO_agbp) { /* - * Couldn't find an allocation group satisfying the - * criteria, give up. - */ - if (!agbp) { - *inop = NULLFSINO; - return 0; - } - agi = XFS_BUF_TO_AGI(agbp); - ASSERT(agi->agi_magicnum == cpu_to_be32(XFS_AGI_MAGIC)); - } else { - /* - * Continue where we left off before. In this case, we + * If the caller passes in a pointer to the AGI buffer, + * continue where we left off before. In this case, we * know that the allocation group has free inodes. */ agbp = *IO_agbp; - agi = XFS_BUF_TO_AGI(agbp); - ASSERT(agi->agi_magicnum == cpu_to_be32(XFS_AGI_MAGIC)); - ASSERT(be32_to_cpu(agi->agi_freecount) > 0); + goto out_alloc; } + + /* + * We do not have an agbp, so select an initial allocation + * group for inode allocation. + */ + agbp = xfs_ialloc_ag_select(tp, parent, mode, okalloc); + + /* + * Couldn't find an allocation group satisfying the + * criteria, give up. + */ + if (!agbp) { + *inop = NULLFSINO; + return 0; + } + agi = XFS_BUF_TO_AGI(agbp); + mp = tp->t_mountp; agno = be32_to_cpu(agi->agi_seqno); tagno = agno; @@ -1012,6 +1016,7 @@ xfs_dialloc( ASSERT(agi->agi_magicnum == cpu_to_be32(XFS_AGI_MAGIC)); } +out_alloc: *IO_agbp = NULL; return xfs_dialloc_ag(tp, agbp, parent, inop); }