diff options
Diffstat (limited to 'fs/xfs/xfs_ialloc.c')
-rw-r--r-- | fs/xfs/xfs_ialloc.c | 133 |
1 files changed, 59 insertions, 74 deletions
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c index ce5fee9eaec5..8f3fae1aa98a 100644 --- a/fs/xfs/xfs_ialloc.c +++ b/fs/xfs/xfs_ialloc.c | |||
@@ -1,41 +1,26 @@ | |||
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 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | 19 | #include "xfs_fs.h" | |
35 | #include "xfs_macros.h" | ||
36 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
37 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
38 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
39 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
40 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
41 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
@@ -43,18 +28,17 @@ | |||
43 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
44 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
45 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
46 | #include "xfs_alloc_btree.h" | ||
47 | #include "xfs_bmap_btree.h" | 31 | #include "xfs_bmap_btree.h" |
32 | #include "xfs_alloc_btree.h" | ||
48 | #include "xfs_ialloc_btree.h" | 33 | #include "xfs_ialloc_btree.h" |
49 | #include "xfs_btree.h" | ||
50 | #include "xfs_ialloc.h" | ||
51 | #include "xfs_attr_sf.h" | ||
52 | #include "xfs_dir_sf.h" | 34 | #include "xfs_dir_sf.h" |
53 | #include "xfs_dir2_sf.h" | 35 | #include "xfs_dir2_sf.h" |
36 | #include "xfs_attr_sf.h" | ||
54 | #include "xfs_dinode.h" | 37 | #include "xfs_dinode.h" |
55 | #include "xfs_inode.h" | 38 | #include "xfs_inode.h" |
39 | #include "xfs_btree.h" | ||
40 | #include "xfs_ialloc.h" | ||
56 | #include "xfs_alloc.h" | 41 | #include "xfs_alloc.h" |
57 | #include "xfs_bit.h" | ||
58 | #include "xfs_rtalloc.h" | 42 | #include "xfs_rtalloc.h" |
59 | #include "xfs_error.h" | 43 | #include "xfs_error.h" |
60 | #include "xfs_bmap.h" | 44 | #include "xfs_bmap.h" |
@@ -194,8 +178,8 @@ xfs_ialloc_ag_alloc( | |||
194 | * Ideally they should be spaced out through the a.g. | 178 | * Ideally they should be spaced out through the a.g. |
195 | * For now, just allocate blocks up front. | 179 | * For now, just allocate blocks up front. |
196 | */ | 180 | */ |
197 | args.agbno = INT_GET(agi->agi_root, ARCH_CONVERT); | 181 | args.agbno = be32_to_cpu(agi->agi_root); |
198 | args.fsbno = XFS_AGB_TO_FSB(args.mp, INT_GET(agi->agi_seqno, ARCH_CONVERT), | 182 | args.fsbno = XFS_AGB_TO_FSB(args.mp, be32_to_cpu(agi->agi_seqno), |
199 | args.agbno); | 183 | args.agbno); |
200 | /* | 184 | /* |
201 | * Allocate a fixed-size extent of inodes. | 185 | * Allocate a fixed-size extent of inodes. |
@@ -217,9 +201,9 @@ xfs_ialloc_ag_alloc( | |||
217 | */ | 201 | */ |
218 | if (isaligned && args.fsbno == NULLFSBLOCK) { | 202 | if (isaligned && args.fsbno == NULLFSBLOCK) { |
219 | args.type = XFS_ALLOCTYPE_NEAR_BNO; | 203 | args.type = XFS_ALLOCTYPE_NEAR_BNO; |
220 | args.agbno = INT_GET(agi->agi_root, ARCH_CONVERT); | 204 | args.agbno = be32_to_cpu(agi->agi_root); |
221 | args.fsbno = XFS_AGB_TO_FSB(args.mp, | 205 | args.fsbno = XFS_AGB_TO_FSB(args.mp, |
222 | INT_GET(agi->agi_seqno, ARCH_CONVERT), args.agbno); | 206 | be32_to_cpu(agi->agi_seqno), args.agbno); |
223 | if (XFS_SB_VERSION_HASALIGN(&args.mp->m_sb) && | 207 | if (XFS_SB_VERSION_HASALIGN(&args.mp->m_sb) && |
224 | args.mp->m_sb.sb_inoalignmt >= | 208 | args.mp->m_sb.sb_inoalignmt >= |
225 | XFS_B_TO_FSBT(args.mp, XFS_INODE_CLUSTER_SIZE(args.mp))) | 209 | XFS_B_TO_FSBT(args.mp, XFS_INODE_CLUSTER_SIZE(args.mp))) |
@@ -274,7 +258,7 @@ xfs_ialloc_ag_alloc( | |||
274 | /* | 258 | /* |
275 | * Get the block. | 259 | * Get the block. |
276 | */ | 260 | */ |
277 | d = XFS_AGB_TO_DADDR(args.mp, INT_GET(agi->agi_seqno, ARCH_CONVERT), | 261 | d = XFS_AGB_TO_DADDR(args.mp, be32_to_cpu(agi->agi_seqno), |
278 | args.agbno + (j * blks_per_cluster)); | 262 | args.agbno + (j * blks_per_cluster)); |
279 | fbuf = xfs_trans_get_buf(tp, args.mp->m_ddev_targp, d, | 263 | fbuf = xfs_trans_get_buf(tp, args.mp->m_ddev_targp, d, |
280 | args.mp->m_bsize * blks_per_cluster, | 264 | args.mp->m_bsize * blks_per_cluster, |
@@ -294,17 +278,17 @@ xfs_ialloc_ag_alloc( | |||
294 | } | 278 | } |
295 | xfs_trans_inode_alloc_buf(tp, fbuf); | 279 | xfs_trans_inode_alloc_buf(tp, fbuf); |
296 | } | 280 | } |
297 | INT_MOD(agi->agi_count, ARCH_CONVERT, newlen); | 281 | be32_add(&agi->agi_count, newlen); |
298 | INT_MOD(agi->agi_freecount, ARCH_CONVERT, newlen); | 282 | be32_add(&agi->agi_freecount, newlen); |
299 | down_read(&args.mp->m_peraglock); | 283 | down_read(&args.mp->m_peraglock); |
300 | args.mp->m_perag[INT_GET(agi->agi_seqno, ARCH_CONVERT)].pagi_freecount += newlen; | 284 | args.mp->m_perag[be32_to_cpu(agi->agi_seqno)].pagi_freecount += newlen; |
301 | up_read(&args.mp->m_peraglock); | 285 | up_read(&args.mp->m_peraglock); |
302 | INT_SET(agi->agi_newino, ARCH_CONVERT, newino); | 286 | agi->agi_newino = cpu_to_be32(newino); |
303 | /* | 287 | /* |
304 | * Insert records describing the new inode chunk into the btree. | 288 | * Insert records describing the new inode chunk into the btree. |
305 | */ | 289 | */ |
306 | cur = xfs_btree_init_cursor(args.mp, tp, agbp, | 290 | cur = xfs_btree_init_cursor(args.mp, tp, agbp, |
307 | INT_GET(agi->agi_seqno, ARCH_CONVERT), | 291 | be32_to_cpu(agi->agi_seqno), |
308 | XFS_BTNUM_INO, (xfs_inode_t *)0, 0); | 292 | XFS_BTNUM_INO, (xfs_inode_t *)0, 0); |
309 | for (thisino = newino; | 293 | for (thisino = newino; |
310 | thisino < newino + newlen; | 294 | thisino < newino + newlen; |
@@ -544,7 +528,7 @@ xfs_dialloc( | |||
544 | return 0; | 528 | return 0; |
545 | } | 529 | } |
546 | agi = XFS_BUF_TO_AGI(agbp); | 530 | agi = XFS_BUF_TO_AGI(agbp); |
547 | ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC); | 531 | ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC); |
548 | } else { | 532 | } else { |
549 | /* | 533 | /* |
550 | * Continue where we left off before. In this case, we | 534 | * Continue where we left off before. In this case, we |
@@ -552,12 +536,12 @@ xfs_dialloc( | |||
552 | */ | 536 | */ |
553 | agbp = *IO_agbp; | 537 | agbp = *IO_agbp; |
554 | agi = XFS_BUF_TO_AGI(agbp); | 538 | agi = XFS_BUF_TO_AGI(agbp); |
555 | ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC); | 539 | ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC); |
556 | ASSERT(INT_GET(agi->agi_freecount, ARCH_CONVERT) > 0); | 540 | ASSERT(be32_to_cpu(agi->agi_freecount) > 0); |
557 | } | 541 | } |
558 | mp = tp->t_mountp; | 542 | mp = tp->t_mountp; |
559 | agcount = mp->m_sb.sb_agcount; | 543 | agcount = mp->m_sb.sb_agcount; |
560 | agno = INT_GET(agi->agi_seqno, ARCH_CONVERT); | 544 | agno = be32_to_cpu(agi->agi_seqno); |
561 | tagno = agno; | 545 | tagno = agno; |
562 | pagno = XFS_INO_TO_AGNO(mp, parent); | 546 | pagno = XFS_INO_TO_AGNO(mp, parent); |
563 | pagino = XFS_INO_TO_AGINO(mp, parent); | 547 | pagino = XFS_INO_TO_AGINO(mp, parent); |
@@ -605,7 +589,7 @@ xfs_dialloc( | |||
605 | * can commit the current transaction and call | 589 | * can commit the current transaction and call |
606 | * us again where we left off. | 590 | * us again where we left off. |
607 | */ | 591 | */ |
608 | ASSERT(INT_GET(agi->agi_freecount, ARCH_CONVERT) > 0); | 592 | ASSERT(be32_to_cpu(agi->agi_freecount) > 0); |
609 | *alloc_done = B_TRUE; | 593 | *alloc_done = B_TRUE; |
610 | *IO_agbp = agbp; | 594 | *IO_agbp = agbp; |
611 | *inop = NULLFSINO; | 595 | *inop = NULLFSINO; |
@@ -636,7 +620,7 @@ nextag: | |||
636 | if (error) | 620 | if (error) |
637 | goto nextag; | 621 | goto nextag; |
638 | agi = XFS_BUF_TO_AGI(agbp); | 622 | agi = XFS_BUF_TO_AGI(agbp); |
639 | ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC); | 623 | ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC); |
640 | } | 624 | } |
641 | /* | 625 | /* |
642 | * Here with an allocation group that has a free inode. | 626 | * Here with an allocation group that has a free inode. |
@@ -645,14 +629,14 @@ nextag: | |||
645 | */ | 629 | */ |
646 | agno = tagno; | 630 | agno = tagno; |
647 | *IO_agbp = NULL; | 631 | *IO_agbp = NULL; |
648 | cur = xfs_btree_init_cursor(mp, tp, agbp, INT_GET(agi->agi_seqno, ARCH_CONVERT), | 632 | cur = xfs_btree_init_cursor(mp, tp, agbp, be32_to_cpu(agi->agi_seqno), |
649 | XFS_BTNUM_INO, (xfs_inode_t *)0, 0); | 633 | XFS_BTNUM_INO, (xfs_inode_t *)0, 0); |
650 | /* | 634 | /* |
651 | * If pagino is 0 (this is the root inode allocation) use newino. | 635 | * If pagino is 0 (this is the root inode allocation) use newino. |
652 | * This must work because we've just allocated some. | 636 | * This must work because we've just allocated some. |
653 | */ | 637 | */ |
654 | if (!pagino) | 638 | if (!pagino) |
655 | pagino = INT_GET(agi->agi_newino, ARCH_CONVERT); | 639 | pagino = be32_to_cpu(agi->agi_newino); |
656 | #ifdef DEBUG | 640 | #ifdef DEBUG |
657 | if (cur->bc_nlevels == 1) { | 641 | if (cur->bc_nlevels == 1) { |
658 | int freecount = 0; | 642 | int freecount = 0; |
@@ -670,7 +654,7 @@ nextag: | |||
670 | goto error0; | 654 | goto error0; |
671 | } while (i == 1); | 655 | } while (i == 1); |
672 | 656 | ||
673 | ASSERT(freecount == INT_GET(agi->agi_freecount, ARCH_CONVERT) || | 657 | ASSERT(freecount == be32_to_cpu(agi->agi_freecount) || |
674 | XFS_FORCED_SHUTDOWN(mp)); | 658 | XFS_FORCED_SHUTDOWN(mp)); |
675 | } | 659 | } |
676 | #endif | 660 | #endif |
@@ -829,9 +813,9 @@ nextag: | |||
829 | * In a different a.g. from the parent. | 813 | * In a different a.g. from the parent. |
830 | * See if the most recently allocated block has any free. | 814 | * See if the most recently allocated block has any free. |
831 | */ | 815 | */ |
832 | else if (INT_GET(agi->agi_newino, ARCH_CONVERT) != NULLAGINO) { | 816 | else if (be32_to_cpu(agi->agi_newino) != NULLAGINO) { |
833 | if ((error = xfs_inobt_lookup_eq(cur, | 817 | if ((error = xfs_inobt_lookup_eq(cur, |
834 | INT_GET(agi->agi_newino, ARCH_CONVERT), 0, 0, &i))) | 818 | be32_to_cpu(agi->agi_newino), 0, 0, &i))) |
835 | goto error0; | 819 | goto error0; |
836 | if (i == 1 && | 820 | if (i == 1 && |
837 | (error = xfs_inobt_get_rec(cur, &rec.ir_startino, | 821 | (error = xfs_inobt_get_rec(cur, &rec.ir_startino, |
@@ -878,7 +862,7 @@ nextag: | |||
878 | if ((error = xfs_inobt_update(cur, rec.ir_startino, rec.ir_freecount, | 862 | if ((error = xfs_inobt_update(cur, rec.ir_startino, rec.ir_freecount, |
879 | rec.ir_free))) | 863 | rec.ir_free))) |
880 | goto error0; | 864 | goto error0; |
881 | INT_MOD(agi->agi_freecount, ARCH_CONVERT, -1); | 865 | be32_add(&agi->agi_freecount, -1); |
882 | xfs_ialloc_log_agi(tp, agbp, XFS_AGI_FREECOUNT); | 866 | xfs_ialloc_log_agi(tp, agbp, XFS_AGI_FREECOUNT); |
883 | down_read(&mp->m_peraglock); | 867 | down_read(&mp->m_peraglock); |
884 | mp->m_perag[tagno].pagi_freecount--; | 868 | mp->m_perag[tagno].pagi_freecount--; |
@@ -898,7 +882,7 @@ nextag: | |||
898 | if ((error = xfs_inobt_increment(cur, 0, &i))) | 882 | if ((error = xfs_inobt_increment(cur, 0, &i))) |
899 | goto error0; | 883 | goto error0; |
900 | } while (i == 1); | 884 | } while (i == 1); |
901 | ASSERT(freecount == INT_GET(agi->agi_freecount, ARCH_CONVERT) || | 885 | ASSERT(freecount == be32_to_cpu(agi->agi_freecount) || |
902 | XFS_FORCED_SHUTDOWN(mp)); | 886 | XFS_FORCED_SHUTDOWN(mp)); |
903 | } | 887 | } |
904 | #endif | 888 | #endif |
@@ -957,8 +941,11 @@ xfs_difree( | |||
957 | agino = XFS_INO_TO_AGINO(mp, inode); | 941 | agino = XFS_INO_TO_AGINO(mp, inode); |
958 | if (inode != XFS_AGINO_TO_INO(mp, agno, agino)) { | 942 | if (inode != XFS_AGINO_TO_INO(mp, agno, agino)) { |
959 | cmn_err(CE_WARN, | 943 | cmn_err(CE_WARN, |
960 | "xfs_difree: inode != XFS_AGINO_TO_INO() (%d != %d) on %s. Returning EINVAL.", | 944 | "xfs_difree: inode != XFS_AGINO_TO_INO() " |
961 | inode, XFS_AGINO_TO_INO(mp, agno, agino), mp->m_fsname); | 945 | "(%llu != %llu) on %s. Returning EINVAL.", |
946 | (unsigned long long)inode, | ||
947 | (unsigned long long)XFS_AGINO_TO_INO(mp, agno, agino), | ||
948 | mp->m_fsname); | ||
962 | ASSERT(0); | 949 | ASSERT(0); |
963 | return XFS_ERROR(EINVAL); | 950 | return XFS_ERROR(EINVAL); |
964 | } | 951 | } |
@@ -983,8 +970,8 @@ xfs_difree( | |||
983 | return error; | 970 | return error; |
984 | } | 971 | } |
985 | agi = XFS_BUF_TO_AGI(agbp); | 972 | agi = XFS_BUF_TO_AGI(agbp); |
986 | ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC); | 973 | ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC); |
987 | ASSERT(agbno < INT_GET(agi->agi_length, ARCH_CONVERT)); | 974 | ASSERT(agbno < be32_to_cpu(agi->agi_length)); |
988 | /* | 975 | /* |
989 | * Initialize the cursor. | 976 | * Initialize the cursor. |
990 | */ | 977 | */ |
@@ -1006,7 +993,7 @@ xfs_difree( | |||
1006 | goto error0; | 993 | goto error0; |
1007 | } | 994 | } |
1008 | } while (i == 1); | 995 | } while (i == 1); |
1009 | ASSERT(freecount == INT_GET(agi->agi_freecount, ARCH_CONVERT) || | 996 | ASSERT(freecount == be32_to_cpu(agi->agi_freecount) || |
1010 | XFS_FORCED_SHUTDOWN(mp)); | 997 | XFS_FORCED_SHUTDOWN(mp)); |
1011 | } | 998 | } |
1012 | #endif | 999 | #endif |
@@ -1055,8 +1042,8 @@ xfs_difree( | |||
1055 | * to be freed when the transaction is committed. | 1042 | * to be freed when the transaction is committed. |
1056 | */ | 1043 | */ |
1057 | ilen = XFS_IALLOC_INODES(mp); | 1044 | ilen = XFS_IALLOC_INODES(mp); |
1058 | INT_MOD(agi->agi_count, ARCH_CONVERT, -ilen); | 1045 | be32_add(&agi->agi_count, -ilen); |
1059 | INT_MOD(agi->agi_freecount, ARCH_CONVERT, -(ilen - 1)); | 1046 | be32_add(&agi->agi_freecount, -(ilen - 1)); |
1060 | xfs_ialloc_log_agi(tp, agbp, XFS_AGI_COUNT | XFS_AGI_FREECOUNT); | 1047 | xfs_ialloc_log_agi(tp, agbp, XFS_AGI_COUNT | XFS_AGI_FREECOUNT); |
1061 | down_read(&mp->m_peraglock); | 1048 | down_read(&mp->m_peraglock); |
1062 | mp->m_perag[agno].pagi_freecount -= ilen - 1; | 1049 | mp->m_perag[agno].pagi_freecount -= ilen - 1; |
@@ -1085,7 +1072,7 @@ xfs_difree( | |||
1085 | /* | 1072 | /* |
1086 | * Change the inode free counts and log the ag/sb changes. | 1073 | * Change the inode free counts and log the ag/sb changes. |
1087 | */ | 1074 | */ |
1088 | INT_MOD(agi->agi_freecount, ARCH_CONVERT, 1); | 1075 | be32_add(&agi->agi_freecount, 1); |
1089 | xfs_ialloc_log_agi(tp, agbp, XFS_AGI_FREECOUNT); | 1076 | xfs_ialloc_log_agi(tp, agbp, XFS_AGI_FREECOUNT); |
1090 | down_read(&mp->m_peraglock); | 1077 | down_read(&mp->m_peraglock); |
1091 | mp->m_perag[agno].pagi_freecount++; | 1078 | mp->m_perag[agno].pagi_freecount++; |
@@ -1111,7 +1098,7 @@ xfs_difree( | |||
1111 | goto error0; | 1098 | goto error0; |
1112 | } | 1099 | } |
1113 | } while (i == 1); | 1100 | } while (i == 1); |
1114 | ASSERT(freecount == INT_GET(agi->agi_freecount, ARCH_CONVERT) || | 1101 | ASSERT(freecount == be32_to_cpu(agi->agi_freecount) || |
1115 | XFS_FORCED_SHUTDOWN(mp)); | 1102 | XFS_FORCED_SHUTDOWN(mp)); |
1116 | } | 1103 | } |
1117 | #endif | 1104 | #endif |
@@ -1320,7 +1307,7 @@ xfs_ialloc_log_agi( | |||
1320 | xfs_agi_t *agi; /* allocation group header */ | 1307 | xfs_agi_t *agi; /* allocation group header */ |
1321 | 1308 | ||
1322 | agi = XFS_BUF_TO_AGI(bp); | 1309 | agi = XFS_BUF_TO_AGI(bp); |
1323 | ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC); | 1310 | ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC); |
1324 | #endif | 1311 | #endif |
1325 | /* | 1312 | /* |
1326 | * Compute byte offsets for the first and last fields. | 1313 | * Compute byte offsets for the first and last fields. |
@@ -1362,9 +1349,8 @@ xfs_ialloc_read_agi( | |||
1362 | */ | 1349 | */ |
1363 | agi = XFS_BUF_TO_AGI(bp); | 1350 | agi = XFS_BUF_TO_AGI(bp); |
1364 | agi_ok = | 1351 | agi_ok = |
1365 | INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC && | 1352 | be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC && |
1366 | XFS_AGI_GOOD_VERSION( | 1353 | XFS_AGI_GOOD_VERSION(be32_to_cpu(agi->agi_versionnum)); |
1367 | INT_GET(agi->agi_versionnum, ARCH_CONVERT)); | ||
1368 | if (unlikely(XFS_TEST_ERROR(!agi_ok, mp, XFS_ERRTAG_IALLOC_READ_AGI, | 1354 | if (unlikely(XFS_TEST_ERROR(!agi_ok, mp, XFS_ERRTAG_IALLOC_READ_AGI, |
1369 | XFS_RANDOM_IALLOC_READ_AGI))) { | 1355 | XFS_RANDOM_IALLOC_READ_AGI))) { |
1370 | XFS_CORRUPTION_ERROR("xfs_ialloc_read_agi", XFS_ERRLEVEL_LOW, | 1356 | XFS_CORRUPTION_ERROR("xfs_ialloc_read_agi", XFS_ERRLEVEL_LOW, |
@@ -1374,16 +1360,15 @@ xfs_ialloc_read_agi( | |||
1374 | } | 1360 | } |
1375 | pag = &mp->m_perag[agno]; | 1361 | pag = &mp->m_perag[agno]; |
1376 | if (!pag->pagi_init) { | 1362 | if (!pag->pagi_init) { |
1377 | pag->pagi_freecount = INT_GET(agi->agi_freecount, ARCH_CONVERT); | 1363 | pag->pagi_freecount = be32_to_cpu(agi->agi_freecount); |
1378 | pag->pagi_init = 1; | 1364 | pag->pagi_init = 1; |
1379 | } else { | 1365 | } else { |
1380 | /* | 1366 | /* |
1381 | * It's possible for these to be out of sync if | 1367 | * It's possible for these to be out of sync if |
1382 | * we are in the middle of a forced shutdown. | 1368 | * we are in the middle of a forced shutdown. |
1383 | */ | 1369 | */ |
1384 | ASSERT(pag->pagi_freecount == | 1370 | ASSERT(pag->pagi_freecount == be32_to_cpu(agi->agi_freecount) || |
1385 | INT_GET(agi->agi_freecount, ARCH_CONVERT) | 1371 | XFS_FORCED_SHUTDOWN(mp)); |
1386 | || XFS_FORCED_SHUTDOWN(mp)); | ||
1387 | } | 1372 | } |
1388 | 1373 | ||
1389 | #ifdef DEBUG | 1374 | #ifdef DEBUG |