diff options
| author | Christoph Hellwig <hch@infradead.org> | 2012-07-04 10:54:48 -0400 |
|---|---|---|
| committer | Ben Myers <bpm@sgi.com> | 2012-07-29 17:03:23 -0400 |
| commit | 4bb61069d2019dea2a7e4e0f4432101f03a9b820 (patch) | |
| tree | 678553dacf1696eab22649880a24119fcdce138a /fs/xfs | |
| parent | 08358906ed78f6ab4d3ff8e4fd1b87b9a4aea645 (diff) | |
xfs: add a short cut to xfs_dialloc for the non-NULL agbp case
In this case we already have selected an AG and know it has free space
beause the buffer lock never got released. Jump directly into xfs_dialloc_ag
and short cut the AG selection loop.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs')
| -rw-r--r-- | fs/xfs/xfs_ialloc.c | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c index 2b70952c9d8c..7aa8a02b7937 100644 --- a/fs/xfs/xfs_ialloc.c +++ b/fs/xfs/xfs_ialloc.c | |||
| @@ -634,6 +634,10 @@ xfs_dialloc_ag( | |||
| 634 | 634 | ||
| 635 | pag = xfs_perag_get(mp, agno); | 635 | pag = xfs_perag_get(mp, agno); |
| 636 | 636 | ||
| 637 | ASSERT(pag->pagi_init); | ||
| 638 | ASSERT(pag->pagi_inodeok); | ||
| 639 | ASSERT(pag->pagi_freecount > 0); | ||
| 640 | |||
| 637 | restart_pagno: | 641 | restart_pagno: |
| 638 | cur = xfs_inobt_init_cursor(mp, tp, agbp, agno); | 642 | cur = xfs_inobt_init_cursor(mp, tp, agbp, agno); |
| 639 | /* | 643 | /* |
| @@ -907,32 +911,32 @@ xfs_dialloc( | |||
| 907 | xfs_agnumber_t tagno; | 911 | xfs_agnumber_t tagno; |
| 908 | struct xfs_perag *pag; | 912 | struct xfs_perag *pag; |
| 909 | 913 | ||
| 910 | if (*IO_agbp == NULL) { | 914 | if (*IO_agbp) { |
| 911 | /* | ||
| 912 | * We do not have an agbp, so select an initial allocation | ||
| 913 | * group for inode allocation. | ||
| 914 | */ | ||
| 915 | agbp = xfs_ialloc_ag_select(tp, parent, mode, okalloc); | ||
| 916 | /* | 915 | /* |
| 917 | * Couldn't find an allocation group satisfying the | 916 | * If the caller passes in a pointer to the AGI buffer, |
| 918 | * criteria, give up. | 917 | * continue where we left off before. In this case, we |
| 919 | */ | ||
| 920 | if (!agbp) { | ||
| 921 | *inop = NULLFSINO; | ||
| 922 | return 0; | ||
| 923 | } | ||
| 924 | agi = XFS_BUF_TO_AGI(agbp); | ||
| 925 | ASSERT(agi->agi_magicnum == cpu_to_be32(XFS_AGI_MAGIC)); | ||
| 926 | } else { | ||
| 927 | /* | ||
| 928 | * Continue where we left off before. In this case, we | ||
| 929 | * know that the allocation group has free inodes. | 918 | * know that the allocation group has free inodes. |
| 930 | */ | 919 | */ |
| 931 | agbp = *IO_agbp; | 920 | agbp = *IO_agbp; |
| 932 | agi = XFS_BUF_TO_AGI(agbp); | 921 | goto out_alloc; |
| 933 | ASSERT(agi->agi_magicnum == cpu_to_be32(XFS_AGI_MAGIC)); | ||
| 934 | ASSERT(be32_to_cpu(agi->agi_freecount) > 0); | ||
| 935 | } | 922 | } |
| 923 | |||
| 924 | /* | ||
| 925 | * We do not have an agbp, so select an initial allocation | ||
| 926 | * group for inode allocation. | ||
| 927 | */ | ||
| 928 | agbp = xfs_ialloc_ag_select(tp, parent, mode, okalloc); | ||
| 929 | |||
| 930 | /* | ||
| 931 | * Couldn't find an allocation group satisfying the | ||
| 932 | * criteria, give up. | ||
| 933 | */ | ||
| 934 | if (!agbp) { | ||
| 935 | *inop = NULLFSINO; | ||
| 936 | return 0; | ||
| 937 | } | ||
| 938 | agi = XFS_BUF_TO_AGI(agbp); | ||
| 939 | |||
| 936 | mp = tp->t_mountp; | 940 | mp = tp->t_mountp; |
| 937 | agno = be32_to_cpu(agi->agi_seqno); | 941 | agno = be32_to_cpu(agi->agi_seqno); |
| 938 | tagno = agno; | 942 | tagno = agno; |
| @@ -1012,6 +1016,7 @@ nextag: | |||
| 1012 | ASSERT(agi->agi_magicnum == cpu_to_be32(XFS_AGI_MAGIC)); | 1016 | ASSERT(agi->agi_magicnum == cpu_to_be32(XFS_AGI_MAGIC)); |
| 1013 | } | 1017 | } |
| 1014 | 1018 | ||
| 1019 | out_alloc: | ||
| 1015 | *IO_agbp = NULL; | 1020 | *IO_agbp = NULL; |
| 1016 | return xfs_dialloc_ag(tp, agbp, parent, inop); | 1021 | return xfs_dialloc_ag(tp, agbp, parent, inop); |
| 1017 | } | 1022 | } |
