diff options
Diffstat (limited to 'fs/xfs/xfs_alloc.c')
-rw-r--r-- | fs/xfs/xfs_alloc.c | 200 |
1 files changed, 89 insertions, 111 deletions
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c index dcfe19703620..f4328e1e2a74 100644 --- a/fs/xfs/xfs_alloc.c +++ b/fs/xfs/xfs_alloc.c | |||
@@ -1,56 +1,44 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | ||
32 | |||
33 | /* | ||
34 | * Free space allocation for XFS. | ||
35 | */ | 17 | */ |
36 | #include "xfs.h" | 18 | #include "xfs.h" |
37 | #include "xfs_macros.h" | 19 | #include "xfs_fs.h" |
38 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
39 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
40 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
41 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
42 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
43 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
44 | #include "xfs_dir.h" | 27 | #include "xfs_dir.h" |
28 | #include "xfs_dir2.h" | ||
45 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
46 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
47 | #include "xfs_alloc_btree.h" | ||
48 | #include "xfs_bmap_btree.h" | 31 | #include "xfs_bmap_btree.h" |
32 | #include "xfs_alloc_btree.h" | ||
49 | #include "xfs_ialloc_btree.h" | 33 | #include "xfs_ialloc_btree.h" |
34 | #include "xfs_dir_sf.h" | ||
35 | #include "xfs_dir2_sf.h" | ||
36 | #include "xfs_attr_sf.h" | ||
37 | #include "xfs_dinode.h" | ||
38 | #include "xfs_inode.h" | ||
50 | #include "xfs_btree.h" | 39 | #include "xfs_btree.h" |
51 | #include "xfs_ialloc.h" | 40 | #include "xfs_ialloc.h" |
52 | #include "xfs_alloc.h" | 41 | #include "xfs_alloc.h" |
53 | #include "xfs_bit.h" | ||
54 | #include "xfs_error.h" | 42 | #include "xfs_error.h" |
55 | 43 | ||
56 | 44 | ||
@@ -243,8 +231,8 @@ xfs_alloc_fix_minleft( | |||
243 | if (args->minleft == 0) | 231 | if (args->minleft == 0) |
244 | return 1; | 232 | return 1; |
245 | agf = XFS_BUF_TO_AGF(args->agbp); | 233 | agf = XFS_BUF_TO_AGF(args->agbp); |
246 | diff = INT_GET(agf->agf_freeblks, ARCH_CONVERT) | 234 | diff = be32_to_cpu(agf->agf_freeblks) |
247 | + INT_GET(agf->agf_flcount, ARCH_CONVERT) | 235 | + be32_to_cpu(agf->agf_flcount) |
248 | - args->len - args->minleft; | 236 | - args->len - args->minleft; |
249 | if (diff >= 0) | 237 | if (diff >= 0) |
250 | return 1; | 238 | return 1; |
@@ -319,7 +307,8 @@ xfs_alloc_fixup_trees( | |||
319 | bnoblock = XFS_BUF_TO_ALLOC_BLOCK(bno_cur->bc_bufs[0]); | 307 | bnoblock = XFS_BUF_TO_ALLOC_BLOCK(bno_cur->bc_bufs[0]); |
320 | cntblock = XFS_BUF_TO_ALLOC_BLOCK(cnt_cur->bc_bufs[0]); | 308 | cntblock = XFS_BUF_TO_ALLOC_BLOCK(cnt_cur->bc_bufs[0]); |
321 | XFS_WANT_CORRUPTED_RETURN( | 309 | XFS_WANT_CORRUPTED_RETURN( |
322 | 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)); | ||
323 | } | 312 | } |
324 | } | 313 | } |
325 | #endif | 314 | #endif |
@@ -505,21 +494,17 @@ xfs_alloc_trace_modagf( | |||
505 | (void *)str, | 494 | (void *)str, |
506 | (void *)mp, | 495 | (void *)mp, |
507 | (void *)(__psint_t)flags, | 496 | (void *)(__psint_t)flags, |
508 | (void *)(__psunsigned_t)INT_GET(agf->agf_seqno, ARCH_CONVERT), | 497 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_seqno), |
509 | (void *)(__psunsigned_t)INT_GET(agf->agf_length, ARCH_CONVERT), | 498 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_length), |
510 | (void *)(__psunsigned_t)INT_GET(agf->agf_roots[XFS_BTNUM_BNO], | 499 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_roots[XFS_BTNUM_BNO]), |
511 | ARCH_CONVERT), | 500 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_roots[XFS_BTNUM_CNT]), |
512 | (void *)(__psunsigned_t)INT_GET(agf->agf_roots[XFS_BTNUM_CNT], | 501 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]), |
513 | ARCH_CONVERT), | 502 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]), |
514 | (void *)(__psunsigned_t)INT_GET(agf->agf_levels[XFS_BTNUM_BNO], | 503 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_flfirst), |
515 | ARCH_CONVERT), | 504 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_fllast), |
516 | (void *)(__psunsigned_t)INT_GET(agf->agf_levels[XFS_BTNUM_CNT], | 505 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_flcount), |
517 | ARCH_CONVERT), | 506 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_freeblks), |
518 | (void *)(__psunsigned_t)INT_GET(agf->agf_flfirst, ARCH_CONVERT), | 507 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_longest)); |
519 | (void *)(__psunsigned_t)INT_GET(agf->agf_fllast, ARCH_CONVERT), | ||
520 | (void *)(__psunsigned_t)INT_GET(agf->agf_flcount, ARCH_CONVERT), | ||
521 | (void *)(__psunsigned_t)INT_GET(agf->agf_freeblks, ARCH_CONVERT), | ||
522 | (void *)(__psunsigned_t)INT_GET(agf->agf_longest, ARCH_CONVERT)); | ||
523 | } | 508 | } |
524 | 509 | ||
525 | STATIC void | 510 | STATIC void |
@@ -612,12 +597,12 @@ xfs_alloc_ag_vextent( | |||
612 | if (!(args->wasfromfl)) { | 597 | if (!(args->wasfromfl)) { |
613 | 598 | ||
614 | agf = XFS_BUF_TO_AGF(args->agbp); | 599 | agf = XFS_BUF_TO_AGF(args->agbp); |
615 | INT_MOD(agf->agf_freeblks, ARCH_CONVERT, -(args->len)); | 600 | be32_add(&agf->agf_freeblks, -(args->len)); |
616 | xfs_trans_agblocks_delta(args->tp, | 601 | xfs_trans_agblocks_delta(args->tp, |
617 | -((long)(args->len))); | 602 | -((long)(args->len))); |
618 | args->pag->pagf_freeblks -= args->len; | 603 | args->pag->pagf_freeblks -= args->len; |
619 | ASSERT(INT_GET(agf->agf_freeblks, ARCH_CONVERT) | 604 | ASSERT(be32_to_cpu(agf->agf_freeblks) <= |
620 | <= INT_GET(agf->agf_length, ARCH_CONVERT)); | 605 | be32_to_cpu(agf->agf_length)); |
621 | TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS); | 606 | TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS); |
622 | xfs_alloc_log_agf(args->tp, args->agbp, | 607 | xfs_alloc_log_agf(args->tp, args->agbp, |
623 | XFS_AGF_FREEBLKS); | 608 | XFS_AGF_FREEBLKS); |
@@ -723,8 +708,7 @@ xfs_alloc_ag_vextent_exact( | |||
723 | 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, |
724 | args->agno, XFS_BTNUM_CNT, NULL, 0); | 709 | args->agno, XFS_BTNUM_CNT, NULL, 0); |
725 | ASSERT(args->agbno + args->len <= | 710 | ASSERT(args->agbno + args->len <= |
726 | INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_length, | 711 | be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length)); |
727 | ARCH_CONVERT)); | ||
728 | 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, |
729 | args->agbno, args->len, XFSA_FIXUP_BNO_OK))) { | 713 | args->agbno, args->len, XFSA_FIXUP_BNO_OK))) { |
730 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_ERROR); | 714 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_ERROR); |
@@ -897,8 +881,7 @@ xfs_alloc_ag_vextent_near( | |||
897 | goto error0; | 881 | goto error0; |
898 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); | 882 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); |
899 | ltend = ltbno + ltlen; | 883 | ltend = ltbno + ltlen; |
900 | 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)); |
901 | ARCH_CONVERT)); | ||
902 | args->len = blen; | 885 | args->len = blen; |
903 | if (!xfs_alloc_fix_minleft(args)) { | 886 | if (!xfs_alloc_fix_minleft(args)) { |
904 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); | 887 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); |
@@ -1253,8 +1236,7 @@ xfs_alloc_ag_vextent_near( | |||
1253 | ltlen, <new); | 1236 | ltlen, <new); |
1254 | ASSERT(ltnew >= ltbno); | 1237 | ASSERT(ltnew >= ltbno); |
1255 | ASSERT(ltnew + rlen <= ltend); | 1238 | ASSERT(ltnew + rlen <= ltend); |
1256 | 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)); |
1257 | ARCH_CONVERT)); | ||
1258 | args->agbno = ltnew; | 1240 | args->agbno = ltnew; |
1259 | 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, |
1260 | ltnew, rlen, XFSA_FIXUP_BNO_OK))) | 1242 | ltnew, rlen, XFSA_FIXUP_BNO_OK))) |
@@ -1417,8 +1399,7 @@ xfs_alloc_ag_vextent_size( | |||
1417 | args->agbno = rbno; | 1399 | args->agbno = rbno; |
1418 | XFS_WANT_CORRUPTED_GOTO( | 1400 | XFS_WANT_CORRUPTED_GOTO( |
1419 | args->agbno + args->len <= | 1401 | args->agbno + args->len <= |
1420 | INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_length, | 1402 | be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length), |
1421 | ARCH_CONVERT), | ||
1422 | error0); | 1403 | error0); |
1423 | TRACE_ALLOC("normal", args); | 1404 | TRACE_ALLOC("normal", args); |
1424 | return 0; | 1405 | return 0; |
@@ -1466,8 +1447,8 @@ xfs_alloc_ag_vextent_small( | |||
1466 | * freelist. | 1447 | * freelist. |
1467 | */ | 1448 | */ |
1468 | else if (args->minlen == 1 && args->alignment == 1 && !args->isfl && | 1449 | else if (args->minlen == 1 && args->alignment == 1 && !args->isfl && |
1469 | (INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_flcount, | 1450 | (be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_flcount) |
1470 | ARCH_CONVERT) > args->minleft)) { | 1451 | > args->minleft)) { |
1471 | if ((error = xfs_alloc_get_freelist(args->tp, args->agbp, &fbno))) | 1452 | if ((error = xfs_alloc_get_freelist(args->tp, args->agbp, &fbno))) |
1472 | goto error0; | 1453 | goto error0; |
1473 | if (fbno != NULLAGBLOCK) { | 1454 | if (fbno != NULLAGBLOCK) { |
@@ -1482,8 +1463,7 @@ xfs_alloc_ag_vextent_small( | |||
1482 | args->agbno = fbno; | 1463 | args->agbno = fbno; |
1483 | XFS_WANT_CORRUPTED_GOTO( | 1464 | XFS_WANT_CORRUPTED_GOTO( |
1484 | args->agbno + args->len <= | 1465 | args->agbno + args->len <= |
1485 | INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_length, | 1466 | be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length), |
1486 | ARCH_CONVERT), | ||
1487 | error0); | 1467 | error0); |
1488 | args->wasfromfl = 1; | 1468 | args->wasfromfl = 1; |
1489 | TRACE_ALLOC("freelist", args); | 1469 | TRACE_ALLOC("freelist", args); |
@@ -1757,12 +1737,12 @@ xfs_free_ag_extent( | |||
1757 | 1737 | ||
1758 | agf = XFS_BUF_TO_AGF(agbp); | 1738 | agf = XFS_BUF_TO_AGF(agbp); |
1759 | pag = &mp->m_perag[agno]; | 1739 | pag = &mp->m_perag[agno]; |
1760 | INT_MOD(agf->agf_freeblks, ARCH_CONVERT, len); | 1740 | be32_add(&agf->agf_freeblks, len); |
1761 | xfs_trans_agblocks_delta(tp, len); | 1741 | xfs_trans_agblocks_delta(tp, len); |
1762 | pag->pagf_freeblks += len; | 1742 | pag->pagf_freeblks += len; |
1763 | XFS_WANT_CORRUPTED_GOTO( | 1743 | XFS_WANT_CORRUPTED_GOTO( |
1764 | INT_GET(agf->agf_freeblks, ARCH_CONVERT) | 1744 | be32_to_cpu(agf->agf_freeblks) <= |
1765 | <= INT_GET(agf->agf_length, ARCH_CONVERT), | 1745 | be32_to_cpu(agf->agf_length), |
1766 | error0); | 1746 | error0); |
1767 | TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS); | 1747 | TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS); |
1768 | xfs_alloc_log_agf(tp, agbp, XFS_AGF_FREEBLKS); | 1748 | xfs_alloc_log_agf(tp, agbp, XFS_AGF_FREEBLKS); |
@@ -1909,18 +1889,18 @@ xfs_alloc_fix_freelist( | |||
1909 | */ | 1889 | */ |
1910 | agf = XFS_BUF_TO_AGF(agbp); | 1890 | agf = XFS_BUF_TO_AGF(agbp); |
1911 | need = XFS_MIN_FREELIST(agf, mp); | 1891 | need = XFS_MIN_FREELIST(agf, mp); |
1912 | delta = need > INT_GET(agf->agf_flcount, ARCH_CONVERT) ? | 1892 | delta = need > be32_to_cpu(agf->agf_flcount) ? |
1913 | (need - INT_GET(agf->agf_flcount, ARCH_CONVERT)) : 0; | 1893 | (need - be32_to_cpu(agf->agf_flcount)) : 0; |
1914 | /* | 1894 | /* |
1915 | * If there isn't enough total or single-extent, reject it. | 1895 | * If there isn't enough total or single-extent, reject it. |
1916 | */ | 1896 | */ |
1917 | longest = INT_GET(agf->agf_longest, ARCH_CONVERT); | 1897 | longest = be32_to_cpu(agf->agf_longest); |
1918 | longest = (longest > delta) ? (longest - delta) : | 1898 | longest = (longest > delta) ? (longest - delta) : |
1919 | (INT_GET(agf->agf_flcount, ARCH_CONVERT) > 0 || longest > 0); | 1899 | (be32_to_cpu(agf->agf_flcount) > 0 || longest > 0); |
1920 | if (args->minlen + args->alignment + args->minalignslop - 1 > longest || | 1900 | if (args->minlen + args->alignment + args->minalignslop - 1 > longest || |
1921 | (args->minleft && | 1901 | (args->minleft && |
1922 | (int)(INT_GET(agf->agf_freeblks, ARCH_CONVERT) + | 1902 | (int)(be32_to_cpu(agf->agf_freeblks) + |
1923 | INT_GET(agf->agf_flcount, ARCH_CONVERT) - need - args->total) < | 1903 | be32_to_cpu(agf->agf_flcount) - need - args->total) < |
1924 | (int)args->minleft)) { | 1904 | (int)args->minleft)) { |
1925 | xfs_trans_brelse(tp, agbp); | 1905 | xfs_trans_brelse(tp, agbp); |
1926 | args->agbp = NULL; | 1906 | args->agbp = NULL; |
@@ -1929,7 +1909,7 @@ xfs_alloc_fix_freelist( | |||
1929 | /* | 1909 | /* |
1930 | * Make the freelist shorter if it's too long. | 1910 | * Make the freelist shorter if it's too long. |
1931 | */ | 1911 | */ |
1932 | while (INT_GET(agf->agf_flcount, ARCH_CONVERT) > need) { | 1912 | while (be32_to_cpu(agf->agf_flcount) > need) { |
1933 | xfs_buf_t *bp; | 1913 | xfs_buf_t *bp; |
1934 | 1914 | ||
1935 | if ((error = xfs_alloc_get_freelist(tp, agbp, &bno))) | 1915 | if ((error = xfs_alloc_get_freelist(tp, agbp, &bno))) |
@@ -1956,9 +1936,9 @@ xfs_alloc_fix_freelist( | |||
1956 | /* | 1936 | /* |
1957 | * Make the freelist longer if it's too short. | 1937 | * Make the freelist longer if it's too short. |
1958 | */ | 1938 | */ |
1959 | while (INT_GET(agf->agf_flcount, ARCH_CONVERT) < need) { | 1939 | while (be32_to_cpu(agf->agf_flcount) < need) { |
1960 | targs.agbno = 0; | 1940 | targs.agbno = 0; |
1961 | targs.maxlen = need - INT_GET(agf->agf_flcount, ARCH_CONVERT); | 1941 | targs.maxlen = need - be32_to_cpu(agf->agf_flcount); |
1962 | /* | 1942 | /* |
1963 | * Allocate as many blocks as possible at once. | 1943 | * Allocate as many blocks as possible at once. |
1964 | */ | 1944 | */ |
@@ -2018,19 +1998,19 @@ xfs_alloc_get_freelist( | |||
2018 | */ | 1998 | */ |
2019 | mp = tp->t_mountp; | 1999 | mp = tp->t_mountp; |
2020 | if ((error = xfs_alloc_read_agfl(mp, tp, | 2000 | if ((error = xfs_alloc_read_agfl(mp, tp, |
2021 | INT_GET(agf->agf_seqno, ARCH_CONVERT), &agflbp))) | 2001 | be32_to_cpu(agf->agf_seqno), &agflbp))) |
2022 | return error; | 2002 | return error; |
2023 | agfl = XFS_BUF_TO_AGFL(agflbp); | 2003 | agfl = XFS_BUF_TO_AGFL(agflbp); |
2024 | /* | 2004 | /* |
2025 | * Get the block number and update the data structures. | 2005 | * Get the block number and update the data structures. |
2026 | */ | 2006 | */ |
2027 | 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); |
2028 | INT_MOD(agf->agf_flfirst, ARCH_CONVERT, 1); | 2008 | be32_add(&agf->agf_flfirst, 1); |
2029 | xfs_trans_brelse(tp, agflbp); | 2009 | xfs_trans_brelse(tp, agflbp); |
2030 | if (INT_GET(agf->agf_flfirst, ARCH_CONVERT) == XFS_AGFL_SIZE(mp)) | 2010 | if (be32_to_cpu(agf->agf_flfirst) == XFS_AGFL_SIZE(mp)) |
2031 | agf->agf_flfirst = 0; | 2011 | agf->agf_flfirst = 0; |
2032 | pag = &mp->m_perag[INT_GET(agf->agf_seqno, ARCH_CONVERT)]; | 2012 | pag = &mp->m_perag[be32_to_cpu(agf->agf_seqno)]; |
2033 | INT_MOD(agf->agf_flcount, ARCH_CONVERT, -1); | 2013 | be32_add(&agf->agf_flcount, -1); |
2034 | xfs_trans_agflist_delta(tp, -1); | 2014 | xfs_trans_agflist_delta(tp, -1); |
2035 | pag->pagf_flcount--; | 2015 | pag->pagf_flcount--; |
2036 | TRACE_MODAGF(NULL, agf, XFS_AGF_FLFIRST | XFS_AGF_FLCOUNT); | 2016 | TRACE_MODAGF(NULL, agf, XFS_AGF_FLFIRST | XFS_AGF_FLCOUNT); |
@@ -2045,7 +2025,7 @@ xfs_alloc_get_freelist( | |||
2045 | * the freeing transaction must be pushed to disk NOW by forcing | 2025 | * the freeing transaction must be pushed to disk NOW by forcing |
2046 | * to disk all iclogs up that transaction's LSN. | 2026 | * to disk all iclogs up that transaction's LSN. |
2047 | */ | 2027 | */ |
2048 | 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); |
2049 | return 0; | 2029 | return 0; |
2050 | } | 2030 | } |
2051 | 2031 | ||
@@ -2123,18 +2103,18 @@ xfs_alloc_put_freelist( | |||
2123 | mp = tp->t_mountp; | 2103 | mp = tp->t_mountp; |
2124 | 2104 | ||
2125 | if (!agflbp && (error = xfs_alloc_read_agfl(mp, tp, | 2105 | if (!agflbp && (error = xfs_alloc_read_agfl(mp, tp, |
2126 | INT_GET(agf->agf_seqno, ARCH_CONVERT), &agflbp))) | 2106 | be32_to_cpu(agf->agf_seqno), &agflbp))) |
2127 | return error; | 2107 | return error; |
2128 | agfl = XFS_BUF_TO_AGFL(agflbp); | 2108 | agfl = XFS_BUF_TO_AGFL(agflbp); |
2129 | INT_MOD(agf->agf_fllast, ARCH_CONVERT, 1); | 2109 | be32_add(&agf->agf_fllast, 1); |
2130 | if (INT_GET(agf->agf_fllast, ARCH_CONVERT) == XFS_AGFL_SIZE(mp)) | 2110 | if (be32_to_cpu(agf->agf_fllast) == XFS_AGFL_SIZE(mp)) |
2131 | agf->agf_fllast = 0; | 2111 | agf->agf_fllast = 0; |
2132 | pag = &mp->m_perag[INT_GET(agf->agf_seqno, ARCH_CONVERT)]; | 2112 | pag = &mp->m_perag[be32_to_cpu(agf->agf_seqno)]; |
2133 | INT_MOD(agf->agf_flcount, ARCH_CONVERT, 1); | 2113 | be32_add(&agf->agf_flcount, 1); |
2134 | xfs_trans_agflist_delta(tp, 1); | 2114 | xfs_trans_agflist_delta(tp, 1); |
2135 | pag->pagf_flcount++; | 2115 | pag->pagf_flcount++; |
2136 | ASSERT(INT_GET(agf->agf_flcount, ARCH_CONVERT) <= XFS_AGFL_SIZE(mp)); | 2116 | ASSERT(be32_to_cpu(agf->agf_flcount) <= XFS_AGFL_SIZE(mp)); |
2137 | blockp = &agfl->agfl_bno[INT_GET(agf->agf_fllast, ARCH_CONVERT)]; | 2117 | blockp = &agfl->agfl_bno[be32_to_cpu(agf->agf_fllast)]; |
2138 | INT_SET(*blockp, ARCH_CONVERT, bno); | 2118 | INT_SET(*blockp, ARCH_CONVERT, bno); |
2139 | TRACE_MODAGF(NULL, agf, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT); | 2119 | TRACE_MODAGF(NULL, agf, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT); |
2140 | 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); |
@@ -2181,14 +2161,12 @@ xfs_alloc_read_agf( | |||
2181 | */ | 2161 | */ |
2182 | agf = XFS_BUF_TO_AGF(bp); | 2162 | agf = XFS_BUF_TO_AGF(bp); |
2183 | agf_ok = | 2163 | agf_ok = |
2184 | INT_GET(agf->agf_magicnum, ARCH_CONVERT) == XFS_AGF_MAGIC && | 2164 | be32_to_cpu(agf->agf_magicnum) == XFS_AGF_MAGIC && |
2185 | XFS_AGF_GOOD_VERSION( | 2165 | XFS_AGF_GOOD_VERSION(be32_to_cpu(agf->agf_versionnum)) && |
2186 | INT_GET(agf->agf_versionnum, ARCH_CONVERT)) && | 2166 | be32_to_cpu(agf->agf_freeblks) <= be32_to_cpu(agf->agf_length) && |
2187 | INT_GET(agf->agf_freeblks, ARCH_CONVERT) <= | 2167 | be32_to_cpu(agf->agf_flfirst) < XFS_AGFL_SIZE(mp) && |
2188 | INT_GET(agf->agf_length, ARCH_CONVERT) && | 2168 | be32_to_cpu(agf->agf_fllast) < XFS_AGFL_SIZE(mp) && |
2189 | INT_GET(agf->agf_flfirst, ARCH_CONVERT) < XFS_AGFL_SIZE(mp) && | 2169 | be32_to_cpu(agf->agf_flcount) <= XFS_AGFL_SIZE(mp); |
2190 | INT_GET(agf->agf_fllast, ARCH_CONVERT) < XFS_AGFL_SIZE(mp) && | ||
2191 | INT_GET(agf->agf_flcount, ARCH_CONVERT) <= XFS_AGFL_SIZE(mp); | ||
2192 | 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, |
2193 | XFS_RANDOM_ALLOC_READ_AGF))) { | 2171 | XFS_RANDOM_ALLOC_READ_AGF))) { |
2194 | XFS_CORRUPTION_ERROR("xfs_alloc_read_agf", | 2172 | XFS_CORRUPTION_ERROR("xfs_alloc_read_agf", |
@@ -2198,13 +2176,13 @@ xfs_alloc_read_agf( | |||
2198 | } | 2176 | } |
2199 | pag = &mp->m_perag[agno]; | 2177 | pag = &mp->m_perag[agno]; |
2200 | if (!pag->pagf_init) { | 2178 | if (!pag->pagf_init) { |
2201 | pag->pagf_freeblks = INT_GET(agf->agf_freeblks, ARCH_CONVERT); | 2179 | pag->pagf_freeblks = be32_to_cpu(agf->agf_freeblks); |
2202 | pag->pagf_flcount = INT_GET(agf->agf_flcount, ARCH_CONVERT); | 2180 | pag->pagf_flcount = be32_to_cpu(agf->agf_flcount); |
2203 | pag->pagf_longest = INT_GET(agf->agf_longest, ARCH_CONVERT); | 2181 | pag->pagf_longest = be32_to_cpu(agf->agf_longest); |
2204 | pag->pagf_levels[XFS_BTNUM_BNOi] = | 2182 | pag->pagf_levels[XFS_BTNUM_BNOi] = |
2205 | INT_GET(agf->agf_levels[XFS_BTNUM_BNOi], ARCH_CONVERT); | 2183 | be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNOi]); |
2206 | pag->pagf_levels[XFS_BTNUM_CNTi] = | 2184 | pag->pagf_levels[XFS_BTNUM_CNTi] = |
2207 | INT_GET(agf->agf_levels[XFS_BTNUM_CNTi], ARCH_CONVERT); | 2185 | be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNTi]); |
2208 | spinlock_init(&pag->pagb_lock, "xfspagb"); | 2186 | spinlock_init(&pag->pagb_lock, "xfspagb"); |
2209 | pag->pagb_list = kmem_zalloc(XFS_PAGB_NUM_SLOTS * | 2187 | pag->pagb_list = kmem_zalloc(XFS_PAGB_NUM_SLOTS * |
2210 | sizeof(xfs_perag_busy_t), KM_SLEEP); | 2188 | sizeof(xfs_perag_busy_t), KM_SLEEP); |
@@ -2212,13 +2190,13 @@ xfs_alloc_read_agf( | |||
2212 | } | 2190 | } |
2213 | #ifdef DEBUG | 2191 | #ifdef DEBUG |
2214 | else if (!XFS_FORCED_SHUTDOWN(mp)) { | 2192 | else if (!XFS_FORCED_SHUTDOWN(mp)) { |
2215 | ASSERT(pag->pagf_freeblks == INT_GET(agf->agf_freeblks, ARCH_CONVERT)); | 2193 | ASSERT(pag->pagf_freeblks == be32_to_cpu(agf->agf_freeblks)); |
2216 | ASSERT(pag->pagf_flcount == INT_GET(agf->agf_flcount, ARCH_CONVERT)); | 2194 | ASSERT(pag->pagf_flcount == be32_to_cpu(agf->agf_flcount)); |
2217 | ASSERT(pag->pagf_longest == INT_GET(agf->agf_longest, ARCH_CONVERT)); | 2195 | ASSERT(pag->pagf_longest == be32_to_cpu(agf->agf_longest)); |
2218 | ASSERT(pag->pagf_levels[XFS_BTNUM_BNOi] == | 2196 | ASSERT(pag->pagf_levels[XFS_BTNUM_BNOi] == |
2219 | INT_GET(agf->agf_levels[XFS_BTNUM_BNOi], ARCH_CONVERT)); | 2197 | be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNOi])); |
2220 | ASSERT(pag->pagf_levels[XFS_BTNUM_CNTi] == | 2198 | ASSERT(pag->pagf_levels[XFS_BTNUM_CNTi] == |
2221 | INT_GET(agf->agf_levels[XFS_BTNUM_CNTi], ARCH_CONVERT)); | 2199 | be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNTi])); |
2222 | } | 2200 | } |
2223 | #endif | 2201 | #endif |
2224 | 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); |
@@ -2467,7 +2445,7 @@ xfs_free_extent( | |||
2467 | #ifdef DEBUG | 2445 | #ifdef DEBUG |
2468 | ASSERT(args.agbp != NULL); | 2446 | ASSERT(args.agbp != NULL); |
2469 | agf = XFS_BUF_TO_AGF(args.agbp); | 2447 | agf = XFS_BUF_TO_AGF(args.agbp); |
2470 | ASSERT(args.agbno + len <= INT_GET(agf->agf_length, ARCH_CONVERT)); | 2448 | ASSERT(args.agbno + len <= be32_to_cpu(agf->agf_length)); |
2471 | #endif | 2449 | #endif |
2472 | 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, |
2473 | len, 0); | 2451 | len, 0); |