aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_alloc.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@sgi.com>2005-11-01 23:11:25 -0500
committerNathan Scott <nathans@sgi.com>2005-11-01 23:11:25 -0500
commit16259e7d952e26e949cc2c8c68b74f34b293935d (patch)
treea016791ecb67761236d32b9915efa9a92f6f3767 /fs/xfs/xfs_alloc.c
parente2ed81fbbb7c76e0a1b3e2f1b5a7414f4d66a559 (diff)
[XFS] Endianess annotations for various allocator data structures
SGI-PV: 943272 SGI-Modid: xfs-linux:xfs-kern:201006a Signed-off-by: Christoph Hellwig <hch@sgi.com> Signed-off-by: Nathan Scott <nathans@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_alloc.c')
-rw-r--r--fs/xfs/xfs_alloc.c146
1 files changed, 68 insertions, 78 deletions
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c
index a439e07253a..f4328e1e2a7 100644
--- a/fs/xfs/xfs_alloc.c
+++ b/fs/xfs/xfs_alloc.c
@@ -231,8 +231,8 @@ xfs_alloc_fix_minleft(
231 if (args->minleft == 0) 231 if (args->minleft == 0)
232 return 1; 232 return 1;
233 agf = XFS_BUF_TO_AGF(args->agbp); 233 agf = XFS_BUF_TO_AGF(args->agbp);
234 diff = INT_GET(agf->agf_freeblks, ARCH_CONVERT) 234 diff = be32_to_cpu(agf->agf_freeblks)
235 + INT_GET(agf->agf_flcount, ARCH_CONVERT) 235 + be32_to_cpu(agf->agf_flcount)
236 - args->len - args->minleft; 236 - args->len - args->minleft;
237 if (diff >= 0) 237 if (diff >= 0)
238 return 1; 238 return 1;
@@ -307,7 +307,8 @@ xfs_alloc_fixup_trees(
307 bnoblock = XFS_BUF_TO_ALLOC_BLOCK(bno_cur->bc_bufs[0]); 307 bnoblock = XFS_BUF_TO_ALLOC_BLOCK(bno_cur->bc_bufs[0]);
308 cntblock = XFS_BUF_TO_ALLOC_BLOCK(cnt_cur->bc_bufs[0]); 308 cntblock = XFS_BUF_TO_ALLOC_BLOCK(cnt_cur->bc_bufs[0]);
309 XFS_WANT_CORRUPTED_RETURN( 309 XFS_WANT_CORRUPTED_RETURN(
310 INT_GET(bnoblock->bb_numrecs, ARCH_CONVERT) == INT_GET(cntblock->bb_numrecs, ARCH_CONVERT)); 310 be16_to_cpu(bnoblock->bb_numrecs) ==
311 be16_to_cpu(cntblock->bb_numrecs));
311 } 312 }
312 } 313 }
313#endif 314#endif
@@ -493,21 +494,17 @@ xfs_alloc_trace_modagf(
493 (void *)str, 494 (void *)str,
494 (void *)mp, 495 (void *)mp,
495 (void *)(__psint_t)flags, 496 (void *)(__psint_t)flags,
496 (void *)(__psunsigned_t)INT_GET(agf->agf_seqno, ARCH_CONVERT), 497 (void *)(__psunsigned_t)be32_to_cpu(agf->agf_seqno),
497 (void *)(__psunsigned_t)INT_GET(agf->agf_length, ARCH_CONVERT), 498 (void *)(__psunsigned_t)be32_to_cpu(agf->agf_length),
498 (void *)(__psunsigned_t)INT_GET(agf->agf_roots[XFS_BTNUM_BNO], 499 (void *)(__psunsigned_t)be32_to_cpu(agf->agf_roots[XFS_BTNUM_BNO]),
499 ARCH_CONVERT), 500 (void *)(__psunsigned_t)be32_to_cpu(agf->agf_roots[XFS_BTNUM_CNT]),
500 (void *)(__psunsigned_t)INT_GET(agf->agf_roots[XFS_BTNUM_CNT], 501 (void *)(__psunsigned_t)be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]),
501 ARCH_CONVERT), 502 (void *)(__psunsigned_t)be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]),
502 (void *)(__psunsigned_t)INT_GET(agf->agf_levels[XFS_BTNUM_BNO], 503 (void *)(__psunsigned_t)be32_to_cpu(agf->agf_flfirst),
503 ARCH_CONVERT), 504 (void *)(__psunsigned_t)be32_to_cpu(agf->agf_fllast),
504 (void *)(__psunsigned_t)INT_GET(agf->agf_levels[XFS_BTNUM_CNT], 505 (void *)(__psunsigned_t)be32_to_cpu(agf->agf_flcount),
505 ARCH_CONVERT), 506 (void *)(__psunsigned_t)be32_to_cpu(agf->agf_freeblks),
506 (void *)(__psunsigned_t)INT_GET(agf->agf_flfirst, ARCH_CONVERT), 507 (void *)(__psunsigned_t)be32_to_cpu(agf->agf_longest));
507 (void *)(__psunsigned_t)INT_GET(agf->agf_fllast, ARCH_CONVERT),
508 (void *)(__psunsigned_t)INT_GET(agf->agf_flcount, ARCH_CONVERT),
509 (void *)(__psunsigned_t)INT_GET(agf->agf_freeblks, ARCH_CONVERT),
510 (void *)(__psunsigned_t)INT_GET(agf->agf_longest, ARCH_CONVERT));
511} 508}
512 509
513STATIC void 510STATIC void
@@ -600,12 +597,12 @@ xfs_alloc_ag_vextent(
600 if (!(args->wasfromfl)) { 597 if (!(args->wasfromfl)) {
601 598
602 agf = XFS_BUF_TO_AGF(args->agbp); 599 agf = XFS_BUF_TO_AGF(args->agbp);
603 INT_MOD(agf->agf_freeblks, ARCH_CONVERT, -(args->len)); 600 be32_add(&agf->agf_freeblks, -(args->len));
604 xfs_trans_agblocks_delta(args->tp, 601 xfs_trans_agblocks_delta(args->tp,
605 -((long)(args->len))); 602 -((long)(args->len)));
606 args->pag->pagf_freeblks -= args->len; 603 args->pag->pagf_freeblks -= args->len;
607 ASSERT(INT_GET(agf->agf_freeblks, ARCH_CONVERT) 604 ASSERT(be32_to_cpu(agf->agf_freeblks) <=
608 <= INT_GET(agf->agf_length, ARCH_CONVERT)); 605 be32_to_cpu(agf->agf_length));
609 TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS); 606 TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS);
610 xfs_alloc_log_agf(args->tp, args->agbp, 607 xfs_alloc_log_agf(args->tp, args->agbp,
611 XFS_AGF_FREEBLKS); 608 XFS_AGF_FREEBLKS);
@@ -711,8 +708,7 @@ xfs_alloc_ag_vextent_exact(
711 cnt_cur = xfs_btree_init_cursor(args->mp, args->tp, args->agbp, 708 cnt_cur = xfs_btree_init_cursor(args->mp, args->tp, args->agbp,
712 args->agno, XFS_BTNUM_CNT, NULL, 0); 709 args->agno, XFS_BTNUM_CNT, NULL, 0);
713 ASSERT(args->agbno + args->len <= 710 ASSERT(args->agbno + args->len <=
714 INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_length, 711 be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length));
715 ARCH_CONVERT));
716 if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur, fbno, flen, 712 if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur, fbno, flen,
717 args->agbno, args->len, XFSA_FIXUP_BNO_OK))) { 713 args->agbno, args->len, XFSA_FIXUP_BNO_OK))) {
718 xfs_btree_del_cursor(cnt_cur, XFS_BTREE_ERROR); 714 xfs_btree_del_cursor(cnt_cur, XFS_BTREE_ERROR);
@@ -885,8 +881,7 @@ xfs_alloc_ag_vextent_near(
885 goto error0; 881 goto error0;
886 XFS_WANT_CORRUPTED_GOTO(i == 1, error0); 882 XFS_WANT_CORRUPTED_GOTO(i == 1, error0);
887 ltend = ltbno + ltlen; 883 ltend = ltbno + ltlen;
888 ASSERT(ltend <= INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_length, 884 ASSERT(ltend <= be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length));
889 ARCH_CONVERT));
890 args->len = blen; 885 args->len = blen;
891 if (!xfs_alloc_fix_minleft(args)) { 886 if (!xfs_alloc_fix_minleft(args)) {
892 xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); 887 xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR);
@@ -1241,8 +1236,7 @@ xfs_alloc_ag_vextent_near(
1241 ltlen, &ltnew); 1236 ltlen, &ltnew);
1242 ASSERT(ltnew >= ltbno); 1237 ASSERT(ltnew >= ltbno);
1243 ASSERT(ltnew + rlen <= ltend); 1238 ASSERT(ltnew + rlen <= ltend);
1244 ASSERT(ltnew + rlen <= INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_length, 1239 ASSERT(ltnew + rlen <= be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length));
1245 ARCH_CONVERT));
1246 args->agbno = ltnew; 1240 args->agbno = ltnew;
1247 if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur_lt, ltbno, ltlen, 1241 if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur_lt, ltbno, ltlen,
1248 ltnew, rlen, XFSA_FIXUP_BNO_OK))) 1242 ltnew, rlen, XFSA_FIXUP_BNO_OK)))
@@ -1405,8 +1399,7 @@ xfs_alloc_ag_vextent_size(
1405 args->agbno = rbno; 1399 args->agbno = rbno;
1406 XFS_WANT_CORRUPTED_GOTO( 1400 XFS_WANT_CORRUPTED_GOTO(
1407 args->agbno + args->len <= 1401 args->agbno + args->len <=
1408 INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_length, 1402 be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length),
1409 ARCH_CONVERT),
1410 error0); 1403 error0);
1411 TRACE_ALLOC("normal", args); 1404 TRACE_ALLOC("normal", args);
1412 return 0; 1405 return 0;
@@ -1454,8 +1447,8 @@ xfs_alloc_ag_vextent_small(
1454 * freelist. 1447 * freelist.
1455 */ 1448 */
1456 else if (args->minlen == 1 && args->alignment == 1 && !args->isfl && 1449 else if (args->minlen == 1 && args->alignment == 1 && !args->isfl &&
1457 (INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_flcount, 1450 (be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_flcount)
1458 ARCH_CONVERT) > args->minleft)) { 1451 > args->minleft)) {
1459 if ((error = xfs_alloc_get_freelist(args->tp, args->agbp, &fbno))) 1452 if ((error = xfs_alloc_get_freelist(args->tp, args->agbp, &fbno)))
1460 goto error0; 1453 goto error0;
1461 if (fbno != NULLAGBLOCK) { 1454 if (fbno != NULLAGBLOCK) {
@@ -1470,8 +1463,7 @@ xfs_alloc_ag_vextent_small(
1470 args->agbno = fbno; 1463 args->agbno = fbno;
1471 XFS_WANT_CORRUPTED_GOTO( 1464 XFS_WANT_CORRUPTED_GOTO(
1472 args->agbno + args->len <= 1465 args->agbno + args->len <=
1473 INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_length, 1466 be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length),
1474 ARCH_CONVERT),
1475 error0); 1467 error0);
1476 args->wasfromfl = 1; 1468 args->wasfromfl = 1;
1477 TRACE_ALLOC("freelist", args); 1469 TRACE_ALLOC("freelist", args);
@@ -1745,12 +1737,12 @@ xfs_free_ag_extent(
1745 1737
1746 agf = XFS_BUF_TO_AGF(agbp); 1738 agf = XFS_BUF_TO_AGF(agbp);
1747 pag = &mp->m_perag[agno]; 1739 pag = &mp->m_perag[agno];
1748 INT_MOD(agf->agf_freeblks, ARCH_CONVERT, len); 1740 be32_add(&agf->agf_freeblks, len);
1749 xfs_trans_agblocks_delta(tp, len); 1741 xfs_trans_agblocks_delta(tp, len);
1750 pag->pagf_freeblks += len; 1742 pag->pagf_freeblks += len;
1751 XFS_WANT_CORRUPTED_GOTO( 1743 XFS_WANT_CORRUPTED_GOTO(
1752 INT_GET(agf->agf_freeblks, ARCH_CONVERT) 1744 be32_to_cpu(agf->agf_freeblks) <=
1753 <= INT_GET(agf->agf_length, ARCH_CONVERT), 1745 be32_to_cpu(agf->agf_length),
1754 error0); 1746 error0);
1755 TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS); 1747 TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS);
1756 xfs_alloc_log_agf(tp, agbp, XFS_AGF_FREEBLKS); 1748 xfs_alloc_log_agf(tp, agbp, XFS_AGF_FREEBLKS);
@@ -1897,18 +1889,18 @@ xfs_alloc_fix_freelist(
1897 */ 1889 */
1898 agf = XFS_BUF_TO_AGF(agbp); 1890 agf = XFS_BUF_TO_AGF(agbp);
1899 need = XFS_MIN_FREELIST(agf, mp); 1891 need = XFS_MIN_FREELIST(agf, mp);
1900 delta = need > INT_GET(agf->agf_flcount, ARCH_CONVERT) ? 1892 delta = need > be32_to_cpu(agf->agf_flcount) ?
1901 (need - INT_GET(agf->agf_flcount, ARCH_CONVERT)) : 0; 1893 (need - be32_to_cpu(agf->agf_flcount)) : 0;
1902 /* 1894 /*
1903 * If there isn't enough total or single-extent, reject it. 1895 * If there isn't enough total or single-extent, reject it.
1904 */ 1896 */
1905 longest = INT_GET(agf->agf_longest, ARCH_CONVERT); 1897 longest = be32_to_cpu(agf->agf_longest);
1906 longest = (longest > delta) ? (longest - delta) : 1898 longest = (longest > delta) ? (longest - delta) :
1907 (INT_GET(agf->agf_flcount, ARCH_CONVERT) > 0 || longest > 0); 1899 (be32_to_cpu(agf->agf_flcount) > 0 || longest > 0);
1908 if (args->minlen + args->alignment + args->minalignslop - 1 > longest || 1900 if (args->minlen + args->alignment + args->minalignslop - 1 > longest ||
1909 (args->minleft && 1901 (args->minleft &&
1910 (int)(INT_GET(agf->agf_freeblks, ARCH_CONVERT) + 1902 (int)(be32_to_cpu(agf->agf_freeblks) +
1911 INT_GET(agf->agf_flcount, ARCH_CONVERT) - need - args->total) < 1903 be32_to_cpu(agf->agf_flcount) - need - args->total) <
1912 (int)args->minleft)) { 1904 (int)args->minleft)) {
1913 xfs_trans_brelse(tp, agbp); 1905 xfs_trans_brelse(tp, agbp);
1914 args->agbp = NULL; 1906 args->agbp = NULL;
@@ -1917,7 +1909,7 @@ xfs_alloc_fix_freelist(
1917 /* 1909 /*
1918 * Make the freelist shorter if it's too long. 1910 * Make the freelist shorter if it's too long.
1919 */ 1911 */
1920 while (INT_GET(agf->agf_flcount, ARCH_CONVERT) > need) { 1912 while (be32_to_cpu(agf->agf_flcount) > need) {
1921 xfs_buf_t *bp; 1913 xfs_buf_t *bp;
1922 1914
1923 if ((error = xfs_alloc_get_freelist(tp, agbp, &bno))) 1915 if ((error = xfs_alloc_get_freelist(tp, agbp, &bno)))
@@ -1944,9 +1936,9 @@ xfs_alloc_fix_freelist(
1944 /* 1936 /*
1945 * Make the freelist longer if it's too short. 1937 * Make the freelist longer if it's too short.
1946 */ 1938 */
1947 while (INT_GET(agf->agf_flcount, ARCH_CONVERT) < need) { 1939 while (be32_to_cpu(agf->agf_flcount) < need) {
1948 targs.agbno = 0; 1940 targs.agbno = 0;
1949 targs.maxlen = need - INT_GET(agf->agf_flcount, ARCH_CONVERT); 1941 targs.maxlen = need - be32_to_cpu(agf->agf_flcount);
1950 /* 1942 /*
1951 * Allocate as many blocks as possible at once. 1943 * Allocate as many blocks as possible at once.
1952 */ 1944 */
@@ -2006,19 +1998,19 @@ xfs_alloc_get_freelist(
2006 */ 1998 */
2007 mp = tp->t_mountp; 1999 mp = tp->t_mountp;
2008 if ((error = xfs_alloc_read_agfl(mp, tp, 2000 if ((error = xfs_alloc_read_agfl(mp, tp,
2009 INT_GET(agf->agf_seqno, ARCH_CONVERT), &agflbp))) 2001 be32_to_cpu(agf->agf_seqno), &agflbp)))
2010 return error; 2002 return error;
2011 agfl = XFS_BUF_TO_AGFL(agflbp); 2003 agfl = XFS_BUF_TO_AGFL(agflbp);
2012 /* 2004 /*
2013 * Get the block number and update the data structures. 2005 * Get the block number and update the data structures.
2014 */ 2006 */
2015 bno = INT_GET(agfl->agfl_bno[INT_GET(agf->agf_flfirst, ARCH_CONVERT)], ARCH_CONVERT); 2007 bno = INT_GET(agfl->agfl_bno[be32_to_cpu(agf->agf_flfirst)], ARCH_CONVERT);
2016 INT_MOD(agf->agf_flfirst, ARCH_CONVERT, 1); 2008 be32_add(&agf->agf_flfirst, 1);
2017 xfs_trans_brelse(tp, agflbp); 2009 xfs_trans_brelse(tp, agflbp);
2018 if (INT_GET(agf->agf_flfirst, ARCH_CONVERT) == XFS_AGFL_SIZE(mp)) 2010 if (be32_to_cpu(agf->agf_flfirst) == XFS_AGFL_SIZE(mp))
2019 agf->agf_flfirst = 0; 2011 agf->agf_flfirst = 0;
2020 pag = &mp->m_perag[INT_GET(agf->agf_seqno, ARCH_CONVERT)]; 2012 pag = &mp->m_perag[be32_to_cpu(agf->agf_seqno)];
2021 INT_MOD(agf->agf_flcount, ARCH_CONVERT, -1); 2013 be32_add(&agf->agf_flcount, -1);
2022 xfs_trans_agflist_delta(tp, -1); 2014 xfs_trans_agflist_delta(tp, -1);
2023 pag->pagf_flcount--; 2015 pag->pagf_flcount--;
2024 TRACE_MODAGF(NULL, agf, XFS_AGF_FLFIRST | XFS_AGF_FLCOUNT); 2016 TRACE_MODAGF(NULL, agf, XFS_AGF_FLFIRST | XFS_AGF_FLCOUNT);
@@ -2033,7 +2025,7 @@ xfs_alloc_get_freelist(
2033 * the freeing transaction must be pushed to disk NOW by forcing 2025 * the freeing transaction must be pushed to disk NOW by forcing
2034 * to disk all iclogs up that transaction's LSN. 2026 * to disk all iclogs up that transaction's LSN.
2035 */ 2027 */
2036 xfs_alloc_search_busy(tp, INT_GET(agf->agf_seqno, ARCH_CONVERT), bno, 1); 2028 xfs_alloc_search_busy(tp, be32_to_cpu(agf->agf_seqno), bno, 1);
2037 return 0; 2029 return 0;
2038} 2030}
2039 2031
@@ -2111,18 +2103,18 @@ xfs_alloc_put_freelist(
2111 mp = tp->t_mountp; 2103 mp = tp->t_mountp;
2112 2104
2113 if (!agflbp && (error = xfs_alloc_read_agfl(mp, tp, 2105 if (!agflbp && (error = xfs_alloc_read_agfl(mp, tp,
2114 INT_GET(agf->agf_seqno, ARCH_CONVERT), &agflbp))) 2106 be32_to_cpu(agf->agf_seqno), &agflbp)))
2115 return error; 2107 return error;
2116 agfl = XFS_BUF_TO_AGFL(agflbp); 2108 agfl = XFS_BUF_TO_AGFL(agflbp);
2117 INT_MOD(agf->agf_fllast, ARCH_CONVERT, 1); 2109 be32_add(&agf->agf_fllast, 1);
2118 if (INT_GET(agf->agf_fllast, ARCH_CONVERT) == XFS_AGFL_SIZE(mp)) 2110 if (be32_to_cpu(agf->agf_fllast) == XFS_AGFL_SIZE(mp))
2119 agf->agf_fllast = 0; 2111 agf->agf_fllast = 0;
2120 pag = &mp->m_perag[INT_GET(agf->agf_seqno, ARCH_CONVERT)]; 2112 pag = &mp->m_perag[be32_to_cpu(agf->agf_seqno)];
2121 INT_MOD(agf->agf_flcount, ARCH_CONVERT, 1); 2113 be32_add(&agf->agf_flcount, 1);
2122 xfs_trans_agflist_delta(tp, 1); 2114 xfs_trans_agflist_delta(tp, 1);
2123 pag->pagf_flcount++; 2115 pag->pagf_flcount++;
2124 ASSERT(INT_GET(agf->agf_flcount, ARCH_CONVERT) <= XFS_AGFL_SIZE(mp)); 2116 ASSERT(be32_to_cpu(agf->agf_flcount) <= XFS_AGFL_SIZE(mp));
2125 blockp = &agfl->agfl_bno[INT_GET(agf->agf_fllast, ARCH_CONVERT)]; 2117 blockp = &agfl->agfl_bno[be32_to_cpu(agf->agf_fllast)];
2126 INT_SET(*blockp, ARCH_CONVERT, bno); 2118 INT_SET(*blockp, ARCH_CONVERT, bno);
2127 TRACE_MODAGF(NULL, agf, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT); 2119 TRACE_MODAGF(NULL, agf, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT);
2128 xfs_alloc_log_agf(tp, agbp, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT); 2120 xfs_alloc_log_agf(tp, agbp, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT);
@@ -2169,14 +2161,12 @@ xfs_alloc_read_agf(
2169 */ 2161 */
2170 agf = XFS_BUF_TO_AGF(bp); 2162 agf = XFS_BUF_TO_AGF(bp);
2171 agf_ok = 2163 agf_ok =
2172 INT_GET(agf->agf_magicnum, ARCH_CONVERT) == XFS_AGF_MAGIC && 2164 be32_to_cpu(agf->agf_magicnum) == XFS_AGF_MAGIC &&
2173 XFS_AGF_GOOD_VERSION( 2165 XFS_AGF_GOOD_VERSION(be32_to_cpu(agf->agf_versionnum)) &&
2174 INT_GET(agf->agf_versionnum, ARCH_CONVERT)) && 2166 be32_to_cpu(agf->agf_freeblks) <= be32_to_cpu(agf->agf_length) &&
2175 INT_GET(agf->agf_freeblks, ARCH_CONVERT) <= 2167 be32_to_cpu(agf->agf_flfirst) < XFS_AGFL_SIZE(mp) &&
2176 INT_GET(agf->agf_length, ARCH_CONVERT) && 2168 be32_to_cpu(agf->agf_fllast) < XFS_AGFL_SIZE(mp) &&
2177 INT_GET(agf->agf_flfirst, ARCH_CONVERT) < XFS_AGFL_SIZE(mp) && 2169 be32_to_cpu(agf->agf_flcount) <= XFS_AGFL_SIZE(mp);
2178 INT_GET(agf->agf_fllast, ARCH_CONVERT) < XFS_AGFL_SIZE(mp) &&
2179 INT_GET(agf->agf_flcount, ARCH_CONVERT) <= XFS_AGFL_SIZE(mp);
2180 if (unlikely(XFS_TEST_ERROR(!agf_ok, mp, XFS_ERRTAG_ALLOC_READ_AGF, 2170 if (unlikely(XFS_TEST_ERROR(!agf_ok, mp, XFS_ERRTAG_ALLOC_READ_AGF,
2181 XFS_RANDOM_ALLOC_READ_AGF))) { 2171 XFS_RANDOM_ALLOC_READ_AGF))) {
2182 XFS_CORRUPTION_ERROR("xfs_alloc_read_agf", 2172 XFS_CORRUPTION_ERROR("xfs_alloc_read_agf",
@@ -2186,13 +2176,13 @@ xfs_alloc_read_agf(
2186 } 2176 }
2187 pag = &mp->m_perag[agno]; 2177 pag = &mp->m_perag[agno];
2188 if (!pag->pagf_init) { 2178 if (!pag->pagf_init) {
2189 pag->pagf_freeblks = INT_GET(agf->agf_freeblks, ARCH_CONVERT); 2179 pag->pagf_freeblks = be32_to_cpu(agf->agf_freeblks);
2190 pag->pagf_flcount = INT_GET(agf->agf_flcount, ARCH_CONVERT); 2180 pag->pagf_flcount = be32_to_cpu(agf->agf_flcount);
2191 pag->pagf_longest = INT_GET(agf->agf_longest, ARCH_CONVERT); 2181 pag->pagf_longest = be32_to_cpu(agf->agf_longest);
2192 pag->pagf_levels[XFS_BTNUM_BNOi] = 2182 pag->pagf_levels[XFS_BTNUM_BNOi] =
2193 INT_GET(agf->agf_levels[XFS_BTNUM_BNOi], ARCH_CONVERT); 2183 be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNOi]);
2194 pag->pagf_levels[XFS_BTNUM_CNTi] = 2184 pag->pagf_levels[XFS_BTNUM_CNTi] =
2195 INT_GET(agf->agf_levels[XFS_BTNUM_CNTi], ARCH_CONVERT); 2185 be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNTi]);
2196 spinlock_init(&pag->pagb_lock, "xfspagb"); 2186 spinlock_init(&pag->pagb_lock, "xfspagb");
2197 pag->pagb_list = kmem_zalloc(XFS_PAGB_NUM_SLOTS * 2187 pag->pagb_list = kmem_zalloc(XFS_PAGB_NUM_SLOTS *
2198 sizeof(xfs_perag_busy_t), KM_SLEEP); 2188 sizeof(xfs_perag_busy_t), KM_SLEEP);
@@ -2200,13 +2190,13 @@ xfs_alloc_read_agf(
2200 } 2190 }
2201#ifdef DEBUG 2191#ifdef DEBUG
2202 else if (!XFS_FORCED_SHUTDOWN(mp)) { 2192 else if (!XFS_FORCED_SHUTDOWN(mp)) {
2203 ASSERT(pag->pagf_freeblks == INT_GET(agf->agf_freeblks, ARCH_CONVERT)); 2193 ASSERT(pag->pagf_freeblks == be32_to_cpu(agf->agf_freeblks));
2204 ASSERT(pag->pagf_flcount == INT_GET(agf->agf_flcount, ARCH_CONVERT)); 2194 ASSERT(pag->pagf_flcount == be32_to_cpu(agf->agf_flcount));
2205 ASSERT(pag->pagf_longest == INT_GET(agf->agf_longest, ARCH_CONVERT)); 2195 ASSERT(pag->pagf_longest == be32_to_cpu(agf->agf_longest));
2206 ASSERT(pag->pagf_levels[XFS_BTNUM_BNOi] == 2196 ASSERT(pag->pagf_levels[XFS_BTNUM_BNOi] ==
2207 INT_GET(agf->agf_levels[XFS_BTNUM_BNOi], ARCH_CONVERT)); 2197 be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNOi]));
2208 ASSERT(pag->pagf_levels[XFS_BTNUM_CNTi] == 2198 ASSERT(pag->pagf_levels[XFS_BTNUM_CNTi] ==
2209 INT_GET(agf->agf_levels[XFS_BTNUM_CNTi], ARCH_CONVERT)); 2199 be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNTi]));
2210 } 2200 }
2211#endif 2201#endif
2212 XFS_BUF_SET_VTYPE_REF(bp, B_FS_AGF, XFS_AGF_REF); 2202 XFS_BUF_SET_VTYPE_REF(bp, B_FS_AGF, XFS_AGF_REF);
@@ -2455,7 +2445,7 @@ xfs_free_extent(
2455#ifdef DEBUG 2445#ifdef DEBUG
2456 ASSERT(args.agbp != NULL); 2446 ASSERT(args.agbp != NULL);
2457 agf = XFS_BUF_TO_AGF(args.agbp); 2447 agf = XFS_BUF_TO_AGF(args.agbp);
2458 ASSERT(args.agbno + len <= INT_GET(agf->agf_length, ARCH_CONVERT)); 2448 ASSERT(args.agbno + len <= be32_to_cpu(agf->agf_length));
2459#endif 2449#endif
2460 error = xfs_free_ag_extent(tp, args.agbp, args.agno, args.agbno, 2450 error = xfs_free_ag_extent(tp, args.agbp, args.agno, args.agbno,
2461 len, 0); 2451 len, 0);