xfs
[Top] [All Lists]

[PATCH v4 14/18] xfs: randomly do sparse inode allocations in DEBUG mode

To: xfs@xxxxxxxxxxx
Subject: [PATCH v4 14/18] xfs: randomly do sparse inode allocations in DEBUG mode
From: Brian Foster <bfoster@xxxxxxxxxx>
Date: Thu, 12 Feb 2015 13:17:21 -0500
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1423765045-15791-1-git-send-email-bfoster@xxxxxxxxxx>
References: <1423765045-15791-1-git-send-email-bfoster@xxxxxxxxxx>
Sparse inode allocations generally only occur when full inode chunk
allocation fails. This requires some level of filesystem space usage and
fragmentation.

For filesystems formatted with sparse inode chunks enabled, do random
sparse inode chunk allocs when compiled in DEBUG mode to increase test
coverage.

Signed-off-by: Brian Foster <bfoster@xxxxxxxxxx>
---
 fs/xfs/libxfs/xfs_ialloc.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index 1c81f08..d96c5e1 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -609,9 +609,18 @@ xfs_ialloc_ag_alloc(
        struct xfs_inobt_rec_incore rec;
        struct xfs_perag *pag;
 
+       int             do_sparse = 0;
+
+#ifdef DEBUG
+       /* randomly do sparse inode allocations */
+       if (xfs_sb_version_hassparseinodes(&tp->t_mountp->m_sb))
+               do_sparse = prandom_u32() & 1;
+#endif
+
        memset(&args, 0, sizeof(args));
        args.tp = tp;
        args.mp = tp->t_mountp;
+       args.fsbno = NULLFSBLOCK;
 
        /*
         * Locking will ensure that we don't have two callers in here
@@ -632,6 +641,8 @@ xfs_ialloc_ag_alloc(
        agno = be32_to_cpu(agi->agi_seqno);
        args.agbno = XFS_AGINO_TO_AGBNO(args.mp, newino) +
                     args.mp->m_ialloc_blks;
+       if (do_sparse)
+               goto sparse_alloc;
        if (likely(newino != NULLAGINO &&
                  (args.agbno < be32_to_cpu(agi->agi_length)))) {
                args.fsbno = XFS_AGB_TO_FSB(args.mp, agno, args.agbno);
@@ -670,8 +681,7 @@ xfs_ialloc_ag_alloc(
                 * subsequent requests.
                 */
                args.minalignslop = 0;
-       } else
-               args.fsbno = NULLFSBLOCK;
+       }
 
        if (unlikely(args.fsbno == NULLFSBLOCK)) {
                /*
@@ -729,6 +739,7 @@ xfs_ialloc_ag_alloc(
        if (xfs_sb_version_hassparseinodes(&args.mp->m_sb) &&
            args.mp->m_ialloc_min_blks < args.mp->m_ialloc_blks &&
            args.fsbno == NULLFSBLOCK) {
+sparse_alloc:
                args.type = XFS_ALLOCTYPE_NEAR_BNO;
                args.agbno = be32_to_cpu(agi->agi_root);
                args.fsbno = XFS_AGB_TO_FSB(args.mp, agno, args.agbno);
-- 
1.8.3.1

<Prev in Thread] Current Thread [Next in Thread>