]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[XFS] Restore the lowspace extent allocator algorithm
authorLachlan McIlroy <lachlan@sgi.com>
Fri, 27 Jun 2008 03:33:03 +0000 (13:33 +1000)
committerNiv Sardi <xaiki@debian.org>
Mon, 28 Jul 2008 06:59:11 +0000 (16:59 +1000)
When free space is running low the extent allocator may choose to allocate
an extent from an AG without leaving sufficient space for a btree split
when inserting the new extent (see where xfs_bmap_btalloc() sets minleft
to 0). In this case the allocator will enable the lowspace algorithm which
is supposed to allow further allocations (such as btree splits and
newroots) to allocate from sequential AGs. This algorithm has been broken
for a long time and this patch restores its behaviour.

SGI-PV: 983338

SGI-Modid: xfs-linux-melb:xfs-kern:31358a

Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Signed-off-by: David Chinner <dgc@sgi.com>
fs/xfs/xfs_bmap.h
fs/xfs/xfs_bmap_btree.c

index 6ff70cda451cbe6011a118ac6a612eaf79dfd3a5..9f3e3a836d153b6bbf09d222588b84ae06c1be34 100644 (file)
@@ -54,12 +54,23 @@ typedef struct xfs_bmap_free_item
 
 /*
  * Header for free extent list.
+ *
+ * xbf_low is used by the allocator to activate the lowspace algorithm -
+ * when free space is running low the extent allocator may choose to
+ * allocate an extent from an AG without leaving sufficient space for
+ * a btree split when inserting the new extent.  In this case the allocator
+ * will enable the lowspace algorithm which is supposed to allow further
+ * allocations (such as btree splits and newroots) to allocate from
+ * sequential AGs.  In order to avoid locking AGs out of order the lowspace
+ * algorithm will start searching for free space from AG 0.  If the correct
+ * transaction reservations have been made then this algorithm will eventually
+ * find all the space it needs.
  */
 typedef        struct xfs_bmap_free
 {
        xfs_bmap_free_item_t    *xbf_first;     /* list of to-be-free extents */
        int                     xbf_count;      /* count of items on list */
-       int                     xbf_low;        /* kludge: alloc in low mode */
+       int                     xbf_low;        /* alloc in low mode */
 } xfs_bmap_free_t;
 
 #define        XFS_BMAP_MAX_NMAP       4
index 3fc09cd8d5178152b15162a507aeaad3a5a56c65..1140cef4ba994d99ab56cf2e1e96584723eefabb 100644 (file)
@@ -1509,7 +1509,9 @@ xfs_bmbt_split(
                 * block allocation here and corrupt the filesystem.
                 */
                args.minleft = xfs_trans_get_block_res(args.tp);
-       } else
+       } else if (cur->bc_private.b.flist->xbf_low)
+               args.type = XFS_ALLOCTYPE_START_BNO;
+       else
                args.type = XFS_ALLOCTYPE_NEAR_BNO;
        args.mod = args.alignment = args.total = args.isfl =
                args.userdata = args.minalignslop = 0;
@@ -2237,7 +2239,9 @@ xfs_bmbt_newroot(
 #endif
                args.fsbno = be64_to_cpu(*pp);
                args.type = XFS_ALLOCTYPE_START_BNO;
-       } else
+       } else if (cur->bc_private.b.flist->xbf_low)
+               args.type = XFS_ALLOCTYPE_START_BNO;
+       else
                args.type = XFS_ALLOCTYPE_NEAR_BNO;
        if ((error = xfs_alloc_vextent(&args))) {
                XFS_BMBT_TRACE_CURSOR(cur, ERROR);