diff options
Diffstat (limited to 'fs/xfs/xfs_alloc.c')
-rw-r--r-- | fs/xfs/xfs_alloc.c | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c index 012a649a19c3..bdbfbbee4959 100644 --- a/fs/xfs/xfs_alloc.c +++ b/fs/xfs/xfs_alloc.c | |||
@@ -592,7 +592,7 @@ xfs_alloc_ag_vextent( | |||
592 | if (!(args->wasfromfl)) { | 592 | if (!(args->wasfromfl)) { |
593 | 593 | ||
594 | agf = XFS_BUF_TO_AGF(args->agbp); | 594 | agf = XFS_BUF_TO_AGF(args->agbp); |
595 | be32_add(&agf->agf_freeblks, -(args->len)); | 595 | be32_add_cpu(&agf->agf_freeblks, -(args->len)); |
596 | xfs_trans_agblocks_delta(args->tp, | 596 | xfs_trans_agblocks_delta(args->tp, |
597 | -((long)(args->len))); | 597 | -((long)(args->len))); |
598 | args->pag->pagf_freeblks -= args->len; | 598 | args->pag->pagf_freeblks -= args->len; |
@@ -1720,7 +1720,7 @@ xfs_free_ag_extent( | |||
1720 | 1720 | ||
1721 | agf = XFS_BUF_TO_AGF(agbp); | 1721 | agf = XFS_BUF_TO_AGF(agbp); |
1722 | pag = &mp->m_perag[agno]; | 1722 | pag = &mp->m_perag[agno]; |
1723 | be32_add(&agf->agf_freeblks, len); | 1723 | be32_add_cpu(&agf->agf_freeblks, len); |
1724 | xfs_trans_agblocks_delta(tp, len); | 1724 | xfs_trans_agblocks_delta(tp, len); |
1725 | pag->pagf_freeblks += len; | 1725 | pag->pagf_freeblks += len; |
1726 | XFS_WANT_CORRUPTED_GOTO( | 1726 | XFS_WANT_CORRUPTED_GOTO( |
@@ -2008,18 +2008,18 @@ xfs_alloc_get_freelist( | |||
2008 | * Get the block number and update the data structures. | 2008 | * Get the block number and update the data structures. |
2009 | */ | 2009 | */ |
2010 | bno = be32_to_cpu(agfl->agfl_bno[be32_to_cpu(agf->agf_flfirst)]); | 2010 | bno = be32_to_cpu(agfl->agfl_bno[be32_to_cpu(agf->agf_flfirst)]); |
2011 | be32_add(&agf->agf_flfirst, 1); | 2011 | be32_add_cpu(&agf->agf_flfirst, 1); |
2012 | xfs_trans_brelse(tp, agflbp); | 2012 | xfs_trans_brelse(tp, agflbp); |
2013 | if (be32_to_cpu(agf->agf_flfirst) == XFS_AGFL_SIZE(mp)) | 2013 | if (be32_to_cpu(agf->agf_flfirst) == XFS_AGFL_SIZE(mp)) |
2014 | agf->agf_flfirst = 0; | 2014 | agf->agf_flfirst = 0; |
2015 | pag = &mp->m_perag[be32_to_cpu(agf->agf_seqno)]; | 2015 | pag = &mp->m_perag[be32_to_cpu(agf->agf_seqno)]; |
2016 | be32_add(&agf->agf_flcount, -1); | 2016 | be32_add_cpu(&agf->agf_flcount, -1); |
2017 | xfs_trans_agflist_delta(tp, -1); | 2017 | xfs_trans_agflist_delta(tp, -1); |
2018 | pag->pagf_flcount--; | 2018 | pag->pagf_flcount--; |
2019 | 2019 | ||
2020 | logflags = XFS_AGF_FLFIRST | XFS_AGF_FLCOUNT; | 2020 | logflags = XFS_AGF_FLFIRST | XFS_AGF_FLCOUNT; |
2021 | if (btreeblk) { | 2021 | if (btreeblk) { |
2022 | be32_add(&agf->agf_btreeblks, 1); | 2022 | be32_add_cpu(&agf->agf_btreeblks, 1); |
2023 | pag->pagf_btreeblks++; | 2023 | pag->pagf_btreeblks++; |
2024 | logflags |= XFS_AGF_BTREEBLKS; | 2024 | logflags |= XFS_AGF_BTREEBLKS; |
2025 | } | 2025 | } |
@@ -2117,17 +2117,17 @@ xfs_alloc_put_freelist( | |||
2117 | be32_to_cpu(agf->agf_seqno), &agflbp))) | 2117 | be32_to_cpu(agf->agf_seqno), &agflbp))) |
2118 | return error; | 2118 | return error; |
2119 | agfl = XFS_BUF_TO_AGFL(agflbp); | 2119 | agfl = XFS_BUF_TO_AGFL(agflbp); |
2120 | be32_add(&agf->agf_fllast, 1); | 2120 | be32_add_cpu(&agf->agf_fllast, 1); |
2121 | if (be32_to_cpu(agf->agf_fllast) == XFS_AGFL_SIZE(mp)) | 2121 | if (be32_to_cpu(agf->agf_fllast) == XFS_AGFL_SIZE(mp)) |
2122 | agf->agf_fllast = 0; | 2122 | agf->agf_fllast = 0; |
2123 | pag = &mp->m_perag[be32_to_cpu(agf->agf_seqno)]; | 2123 | pag = &mp->m_perag[be32_to_cpu(agf->agf_seqno)]; |
2124 | be32_add(&agf->agf_flcount, 1); | 2124 | be32_add_cpu(&agf->agf_flcount, 1); |
2125 | xfs_trans_agflist_delta(tp, 1); | 2125 | xfs_trans_agflist_delta(tp, 1); |
2126 | pag->pagf_flcount++; | 2126 | pag->pagf_flcount++; |
2127 | 2127 | ||
2128 | logflags = XFS_AGF_FLLAST | XFS_AGF_FLCOUNT; | 2128 | logflags = XFS_AGF_FLLAST | XFS_AGF_FLCOUNT; |
2129 | if (btreeblk) { | 2129 | if (btreeblk) { |
2130 | be32_add(&agf->agf_btreeblks, -1); | 2130 | be32_add_cpu(&agf->agf_btreeblks, -1); |
2131 | pag->pagf_btreeblks--; | 2131 | pag->pagf_btreeblks--; |
2132 | logflags |= XFS_AGF_BTREEBLKS; | 2132 | logflags |= XFS_AGF_BTREEBLKS; |
2133 | } | 2133 | } |
@@ -2206,7 +2206,7 @@ xfs_alloc_read_agf( | |||
2206 | be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNOi]); | 2206 | be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNOi]); |
2207 | pag->pagf_levels[XFS_BTNUM_CNTi] = | 2207 | pag->pagf_levels[XFS_BTNUM_CNTi] = |
2208 | be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNTi]); | 2208 | be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNTi]); |
2209 | spinlock_init(&pag->pagb_lock, "xfspagb"); | 2209 | spin_lock_init(&pag->pagb_lock); |
2210 | pag->pagb_list = kmem_zalloc(XFS_PAGB_NUM_SLOTS * | 2210 | pag->pagb_list = kmem_zalloc(XFS_PAGB_NUM_SLOTS * |
2211 | sizeof(xfs_perag_busy_t), KM_SLEEP); | 2211 | sizeof(xfs_perag_busy_t), KM_SLEEP); |
2212 | pag->pagf_init = 1; | 2212 | pag->pagf_init = 1; |
@@ -2500,10 +2500,9 @@ xfs_alloc_mark_busy(xfs_trans_t *tp, | |||
2500 | xfs_mount_t *mp; | 2500 | xfs_mount_t *mp; |
2501 | xfs_perag_busy_t *bsy; | 2501 | xfs_perag_busy_t *bsy; |
2502 | int n; | 2502 | int n; |
2503 | SPLDECL(s); | ||
2504 | 2503 | ||
2505 | mp = tp->t_mountp; | 2504 | mp = tp->t_mountp; |
2506 | s = mutex_spinlock(&mp->m_perag[agno].pagb_lock); | 2505 | spin_lock(&mp->m_perag[agno].pagb_lock); |
2507 | 2506 | ||
2508 | /* search pagb_list for an open slot */ | 2507 | /* search pagb_list for an open slot */ |
2509 | for (bsy = mp->m_perag[agno].pagb_list, n = 0; | 2508 | for (bsy = mp->m_perag[agno].pagb_list, n = 0; |
@@ -2533,7 +2532,7 @@ xfs_alloc_mark_busy(xfs_trans_t *tp, | |||
2533 | xfs_trans_set_sync(tp); | 2532 | xfs_trans_set_sync(tp); |
2534 | } | 2533 | } |
2535 | 2534 | ||
2536 | mutex_spinunlock(&mp->m_perag[agno].pagb_lock, s); | 2535 | spin_unlock(&mp->m_perag[agno].pagb_lock); |
2537 | } | 2536 | } |
2538 | 2537 | ||
2539 | void | 2538 | void |
@@ -2543,11 +2542,10 @@ xfs_alloc_clear_busy(xfs_trans_t *tp, | |||
2543 | { | 2542 | { |
2544 | xfs_mount_t *mp; | 2543 | xfs_mount_t *mp; |
2545 | xfs_perag_busy_t *list; | 2544 | xfs_perag_busy_t *list; |
2546 | SPLDECL(s); | ||
2547 | 2545 | ||
2548 | mp = tp->t_mountp; | 2546 | mp = tp->t_mountp; |
2549 | 2547 | ||
2550 | s = mutex_spinlock(&mp->m_perag[agno].pagb_lock); | 2548 | spin_lock(&mp->m_perag[agno].pagb_lock); |
2551 | list = mp->m_perag[agno].pagb_list; | 2549 | list = mp->m_perag[agno].pagb_list; |
2552 | 2550 | ||
2553 | ASSERT(idx < XFS_PAGB_NUM_SLOTS); | 2551 | ASSERT(idx < XFS_PAGB_NUM_SLOTS); |
@@ -2559,7 +2557,7 @@ xfs_alloc_clear_busy(xfs_trans_t *tp, | |||
2559 | TRACE_UNBUSY("xfs_alloc_clear_busy", "missing", agno, idx, tp); | 2557 | TRACE_UNBUSY("xfs_alloc_clear_busy", "missing", agno, idx, tp); |
2560 | } | 2558 | } |
2561 | 2559 | ||
2562 | mutex_spinunlock(&mp->m_perag[agno].pagb_lock, s); | 2560 | spin_unlock(&mp->m_perag[agno].pagb_lock); |
2563 | } | 2561 | } |
2564 | 2562 | ||
2565 | 2563 | ||
@@ -2578,11 +2576,10 @@ xfs_alloc_search_busy(xfs_trans_t *tp, | |||
2578 | xfs_agblock_t uend, bend; | 2576 | xfs_agblock_t uend, bend; |
2579 | xfs_lsn_t lsn; | 2577 | xfs_lsn_t lsn; |
2580 | int cnt; | 2578 | int cnt; |
2581 | SPLDECL(s); | ||
2582 | 2579 | ||
2583 | mp = tp->t_mountp; | 2580 | mp = tp->t_mountp; |
2584 | 2581 | ||
2585 | s = mutex_spinlock(&mp->m_perag[agno].pagb_lock); | 2582 | spin_lock(&mp->m_perag[agno].pagb_lock); |
2586 | cnt = mp->m_perag[agno].pagb_count; | 2583 | cnt = mp->m_perag[agno].pagb_count; |
2587 | 2584 | ||
2588 | uend = bno + len - 1; | 2585 | uend = bno + len - 1; |
@@ -2615,12 +2612,12 @@ xfs_alloc_search_busy(xfs_trans_t *tp, | |||
2615 | if (cnt) { | 2612 | if (cnt) { |
2616 | TRACE_BUSYSEARCH("xfs_alloc_search_busy", "found", agno, bno, len, n, tp); | 2613 | TRACE_BUSYSEARCH("xfs_alloc_search_busy", "found", agno, bno, len, n, tp); |
2617 | lsn = bsy->busy_tp->t_commit_lsn; | 2614 | lsn = bsy->busy_tp->t_commit_lsn; |
2618 | mutex_spinunlock(&mp->m_perag[agno].pagb_lock, s); | 2615 | spin_unlock(&mp->m_perag[agno].pagb_lock); |
2619 | xfs_log_force(mp, lsn, XFS_LOG_FORCE|XFS_LOG_SYNC); | 2616 | xfs_log_force(mp, lsn, XFS_LOG_FORCE|XFS_LOG_SYNC); |
2620 | } else { | 2617 | } else { |
2621 | TRACE_BUSYSEARCH("xfs_alloc_search_busy", "not-found", agno, bno, len, n, tp); | 2618 | TRACE_BUSYSEARCH("xfs_alloc_search_busy", "not-found", agno, bno, len, n, tp); |
2622 | n = -1; | 2619 | n = -1; |
2623 | mutex_spinunlock(&mp->m_perag[agno].pagb_lock, s); | 2620 | spin_unlock(&mp->m_perag[agno].pagb_lock); |
2624 | } | 2621 | } |
2625 | 2622 | ||
2626 | return n; | 2623 | return n; |