aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2015-05-28 19:19:29 -0400
committerDave Chinner <david@fromorbit.com>2015-05-28 19:19:29 -0400
commit1cdadee11f8d44b16f8110cf01498bd7c38474d8 (patch)
treefa80bf105720663ae9b4f631c757c7ecfdd59ded
parent56d1115c9bc7853e143f59fb5976cf3de609f657 (diff)
xfs: randomly do sparse inode allocations in DEBUG mode
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@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
-rw-r--r--fs/xfs/libxfs/xfs_ialloc.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index 90594b880653..9a18c0b5beb9 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -607,9 +607,18 @@ xfs_ialloc_ag_alloc(
607 struct xfs_inobt_rec_incore rec; 607 struct xfs_inobt_rec_incore rec;
608 struct xfs_perag *pag; 608 struct xfs_perag *pag;
609 609
610 int do_sparse = 0;
611
612#ifdef DEBUG
613 /* randomly do sparse inode allocations */
614 if (xfs_sb_version_hassparseinodes(&tp->t_mountp->m_sb))
615 do_sparse = prandom_u32() & 1;
616#endif
617
610 memset(&args, 0, sizeof(args)); 618 memset(&args, 0, sizeof(args));
611 args.tp = tp; 619 args.tp = tp;
612 args.mp = tp->t_mountp; 620 args.mp = tp->t_mountp;
621 args.fsbno = NULLFSBLOCK;
613 622
614 /* 623 /*
615 * Locking will ensure that we don't have two callers in here 624 * Locking will ensure that we don't have two callers in here
@@ -631,6 +640,8 @@ xfs_ialloc_ag_alloc(
631 agno = be32_to_cpu(agi->agi_seqno); 640 agno = be32_to_cpu(agi->agi_seqno);
632 args.agbno = XFS_AGINO_TO_AGBNO(args.mp, newino) + 641 args.agbno = XFS_AGINO_TO_AGBNO(args.mp, newino) +
633 args.mp->m_ialloc_blks; 642 args.mp->m_ialloc_blks;
643 if (do_sparse)
644 goto sparse_alloc;
634 if (likely(newino != NULLAGINO && 645 if (likely(newino != NULLAGINO &&
635 (args.agbno < be32_to_cpu(agi->agi_length)))) { 646 (args.agbno < be32_to_cpu(agi->agi_length)))) {
636 args.fsbno = XFS_AGB_TO_FSB(args.mp, agno, args.agbno); 647 args.fsbno = XFS_AGB_TO_FSB(args.mp, agno, args.agbno);
@@ -669,8 +680,7 @@ xfs_ialloc_ag_alloc(
669 * subsequent requests. 680 * subsequent requests.
670 */ 681 */
671 args.minalignslop = 0; 682 args.minalignslop = 0;
672 } else 683 }
673 args.fsbno = NULLFSBLOCK;
674 684
675 if (unlikely(args.fsbno == NULLFSBLOCK)) { 685 if (unlikely(args.fsbno == NULLFSBLOCK)) {
676 /* 686 /*
@@ -728,6 +738,7 @@ xfs_ialloc_ag_alloc(
728 if (xfs_sb_version_hassparseinodes(&args.mp->m_sb) && 738 if (xfs_sb_version_hassparseinodes(&args.mp->m_sb) &&
729 args.mp->m_ialloc_min_blks < args.mp->m_ialloc_blks && 739 args.mp->m_ialloc_min_blks < args.mp->m_ialloc_blks &&
730 args.fsbno == NULLFSBLOCK) { 740 args.fsbno == NULLFSBLOCK) {
741sparse_alloc:
731 args.type = XFS_ALLOCTYPE_NEAR_BNO; 742 args.type = XFS_ALLOCTYPE_NEAR_BNO;
732 args.agbno = be32_to_cpu(agi->agi_root); 743 args.agbno = be32_to_cpu(agi->agi_root);
733 args.fsbno = XFS_AGB_TO_FSB(args.mp, agno, args.agbno); 744 args.fsbno = XFS_AGB_TO_FSB(args.mp, agno, args.agbno);