aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_ialloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_ialloc.c')
-rw-r--r--fs/xfs/xfs_ialloc.c74
1 files changed, 36 insertions, 38 deletions
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index d8ceb3d1865f..8f3fae1aa98a 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -178,8 +178,8 @@ xfs_ialloc_ag_alloc(
178 * Ideally they should be spaced out through the a.g. 178 * Ideally they should be spaced out through the a.g.
179 * For now, just allocate blocks up front. 179 * For now, just allocate blocks up front.
180 */ 180 */
181 args.agbno = INT_GET(agi->agi_root, ARCH_CONVERT); 181 args.agbno = be32_to_cpu(agi->agi_root);
182 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),
183 args.agbno); 183 args.agbno);
184 /* 184 /*
185 * Allocate a fixed-size extent of inodes. 185 * Allocate a fixed-size extent of inodes.
@@ -201,9 +201,9 @@ xfs_ialloc_ag_alloc(
201 */ 201 */
202 if (isaligned && args.fsbno == NULLFSBLOCK) { 202 if (isaligned && args.fsbno == NULLFSBLOCK) {
203 args.type = XFS_ALLOCTYPE_NEAR_BNO; 203 args.type = XFS_ALLOCTYPE_NEAR_BNO;
204 args.agbno = INT_GET(agi->agi_root, ARCH_CONVERT); 204 args.agbno = be32_to_cpu(agi->agi_root);
205 args.fsbno = XFS_AGB_TO_FSB(args.mp, 205 args.fsbno = XFS_AGB_TO_FSB(args.mp,
206 INT_GET(agi->agi_seqno, ARCH_CONVERT), args.agbno); 206 be32_to_cpu(agi->agi_seqno), args.agbno);
207 if (XFS_SB_VERSION_HASALIGN(&args.mp->m_sb) && 207 if (XFS_SB_VERSION_HASALIGN(&args.mp->m_sb) &&
208 args.mp->m_sb.sb_inoalignmt >= 208 args.mp->m_sb.sb_inoalignmt >=
209 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)))
@@ -258,7 +258,7 @@ xfs_ialloc_ag_alloc(
258 /* 258 /*
259 * Get the block. 259 * Get the block.
260 */ 260 */
261 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),
262 args.agbno + (j * blks_per_cluster)); 262 args.agbno + (j * blks_per_cluster));
263 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,
264 args.mp->m_bsize * blks_per_cluster, 264 args.mp->m_bsize * blks_per_cluster,
@@ -278,17 +278,17 @@ xfs_ialloc_ag_alloc(
278 } 278 }
279 xfs_trans_inode_alloc_buf(tp, fbuf); 279 xfs_trans_inode_alloc_buf(tp, fbuf);
280 } 280 }
281 INT_MOD(agi->agi_count, ARCH_CONVERT, newlen); 281 be32_add(&agi->agi_count, newlen);
282 INT_MOD(agi->agi_freecount, ARCH_CONVERT, newlen); 282 be32_add(&agi->agi_freecount, newlen);
283 down_read(&args.mp->m_peraglock); 283 down_read(&args.mp->m_peraglock);
284 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;
285 up_read(&args.mp->m_peraglock); 285 up_read(&args.mp->m_peraglock);
286 INT_SET(agi->agi_newino, ARCH_CONVERT, newino); 286 agi->agi_newino = cpu_to_be32(newino);
287 /* 287 /*
288 * Insert records describing the new inode chunk into the btree. 288 * Insert records describing the new inode chunk into the btree.
289 */ 289 */
290 cur = xfs_btree_init_cursor(args.mp, tp, agbp, 290 cur = xfs_btree_init_cursor(args.mp, tp, agbp,
291 INT_GET(agi->agi_seqno, ARCH_CONVERT), 291 be32_to_cpu(agi->agi_seqno),
292 XFS_BTNUM_INO, (xfs_inode_t *)0, 0); 292 XFS_BTNUM_INO, (xfs_inode_t *)0, 0);
293 for (thisino = newino; 293 for (thisino = newino;
294 thisino < newino + newlen; 294 thisino < newino + newlen;
@@ -528,7 +528,7 @@ xfs_dialloc(
528 return 0; 528 return 0;
529 } 529 }
530 agi = XFS_BUF_TO_AGI(agbp); 530 agi = XFS_BUF_TO_AGI(agbp);
531 ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC); 531 ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC);
532 } else { 532 } else {
533 /* 533 /*
534 * Continue where we left off before. In this case, we 534 * Continue where we left off before. In this case, we
@@ -536,12 +536,12 @@ xfs_dialloc(
536 */ 536 */
537 agbp = *IO_agbp; 537 agbp = *IO_agbp;
538 agi = XFS_BUF_TO_AGI(agbp); 538 agi = XFS_BUF_TO_AGI(agbp);
539 ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC); 539 ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC);
540 ASSERT(INT_GET(agi->agi_freecount, ARCH_CONVERT) > 0); 540 ASSERT(be32_to_cpu(agi->agi_freecount) > 0);
541 } 541 }
542 mp = tp->t_mountp; 542 mp = tp->t_mountp;
543 agcount = mp->m_sb.sb_agcount; 543 agcount = mp->m_sb.sb_agcount;
544 agno = INT_GET(agi->agi_seqno, ARCH_CONVERT); 544 agno = be32_to_cpu(agi->agi_seqno);
545 tagno = agno; 545 tagno = agno;
546 pagno = XFS_INO_TO_AGNO(mp, parent); 546 pagno = XFS_INO_TO_AGNO(mp, parent);
547 pagino = XFS_INO_TO_AGINO(mp, parent); 547 pagino = XFS_INO_TO_AGINO(mp, parent);
@@ -589,7 +589,7 @@ xfs_dialloc(
589 * can commit the current transaction and call 589 * can commit the current transaction and call
590 * us again where we left off. 590 * us again where we left off.
591 */ 591 */
592 ASSERT(INT_GET(agi->agi_freecount, ARCH_CONVERT) > 0); 592 ASSERT(be32_to_cpu(agi->agi_freecount) > 0);
593 *alloc_done = B_TRUE; 593 *alloc_done = B_TRUE;
594 *IO_agbp = agbp; 594 *IO_agbp = agbp;
595 *inop = NULLFSINO; 595 *inop = NULLFSINO;
@@ -620,7 +620,7 @@ nextag:
620 if (error) 620 if (error)
621 goto nextag; 621 goto nextag;
622 agi = XFS_BUF_TO_AGI(agbp); 622 agi = XFS_BUF_TO_AGI(agbp);
623 ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC); 623 ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC);
624 } 624 }
625 /* 625 /*
626 * Here with an allocation group that has a free inode. 626 * Here with an allocation group that has a free inode.
@@ -629,14 +629,14 @@ nextag:
629 */ 629 */
630 agno = tagno; 630 agno = tagno;
631 *IO_agbp = NULL; 631 *IO_agbp = NULL;
632 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),
633 XFS_BTNUM_INO, (xfs_inode_t *)0, 0); 633 XFS_BTNUM_INO, (xfs_inode_t *)0, 0);
634 /* 634 /*
635 * 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.
636 * This must work because we've just allocated some. 636 * This must work because we've just allocated some.
637 */ 637 */
638 if (!pagino) 638 if (!pagino)
639 pagino = INT_GET(agi->agi_newino, ARCH_CONVERT); 639 pagino = be32_to_cpu(agi->agi_newino);
640#ifdef DEBUG 640#ifdef DEBUG
641 if (cur->bc_nlevels == 1) { 641 if (cur->bc_nlevels == 1) {
642 int freecount = 0; 642 int freecount = 0;
@@ -654,7 +654,7 @@ nextag:
654 goto error0; 654 goto error0;
655 } while (i == 1); 655 } while (i == 1);
656 656
657 ASSERT(freecount == INT_GET(agi->agi_freecount, ARCH_CONVERT) || 657 ASSERT(freecount == be32_to_cpu(agi->agi_freecount) ||
658 XFS_FORCED_SHUTDOWN(mp)); 658 XFS_FORCED_SHUTDOWN(mp));
659 } 659 }
660#endif 660#endif
@@ -813,9 +813,9 @@ nextag:
813 * In a different a.g. from the parent. 813 * In a different a.g. from the parent.
814 * See if the most recently allocated block has any free. 814 * See if the most recently allocated block has any free.
815 */ 815 */
816 else if (INT_GET(agi->agi_newino, ARCH_CONVERT) != NULLAGINO) { 816 else if (be32_to_cpu(agi->agi_newino) != NULLAGINO) {
817 if ((error = xfs_inobt_lookup_eq(cur, 817 if ((error = xfs_inobt_lookup_eq(cur,
818 INT_GET(agi->agi_newino, ARCH_CONVERT), 0, 0, &i))) 818 be32_to_cpu(agi->agi_newino), 0, 0, &i)))
819 goto error0; 819 goto error0;
820 if (i == 1 && 820 if (i == 1 &&
821 (error = xfs_inobt_get_rec(cur, &rec.ir_startino, 821 (error = xfs_inobt_get_rec(cur, &rec.ir_startino,
@@ -862,7 +862,7 @@ nextag:
862 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,
863 rec.ir_free))) 863 rec.ir_free)))
864 goto error0; 864 goto error0;
865 INT_MOD(agi->agi_freecount, ARCH_CONVERT, -1); 865 be32_add(&agi->agi_freecount, -1);
866 xfs_ialloc_log_agi(tp, agbp, XFS_AGI_FREECOUNT); 866 xfs_ialloc_log_agi(tp, agbp, XFS_AGI_FREECOUNT);
867 down_read(&mp->m_peraglock); 867 down_read(&mp->m_peraglock);
868 mp->m_perag[tagno].pagi_freecount--; 868 mp->m_perag[tagno].pagi_freecount--;
@@ -882,7 +882,7 @@ nextag:
882 if ((error = xfs_inobt_increment(cur, 0, &i))) 882 if ((error = xfs_inobt_increment(cur, 0, &i)))
883 goto error0; 883 goto error0;
884 } while (i == 1); 884 } while (i == 1);
885 ASSERT(freecount == INT_GET(agi->agi_freecount, ARCH_CONVERT) || 885 ASSERT(freecount == be32_to_cpu(agi->agi_freecount) ||
886 XFS_FORCED_SHUTDOWN(mp)); 886 XFS_FORCED_SHUTDOWN(mp));
887 } 887 }
888#endif 888#endif
@@ -970,8 +970,8 @@ xfs_difree(
970 return error; 970 return error;
971 } 971 }
972 agi = XFS_BUF_TO_AGI(agbp); 972 agi = XFS_BUF_TO_AGI(agbp);
973 ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC); 973 ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC);
974 ASSERT(agbno < INT_GET(agi->agi_length, ARCH_CONVERT)); 974 ASSERT(agbno < be32_to_cpu(agi->agi_length));
975 /* 975 /*
976 * Initialize the cursor. 976 * Initialize the cursor.
977 */ 977 */
@@ -993,7 +993,7 @@ xfs_difree(
993 goto error0; 993 goto error0;
994 } 994 }
995 } while (i == 1); 995 } while (i == 1);
996 ASSERT(freecount == INT_GET(agi->agi_freecount, ARCH_CONVERT) || 996 ASSERT(freecount == be32_to_cpu(agi->agi_freecount) ||
997 XFS_FORCED_SHUTDOWN(mp)); 997 XFS_FORCED_SHUTDOWN(mp));
998 } 998 }
999#endif 999#endif
@@ -1042,8 +1042,8 @@ xfs_difree(
1042 * to be freed when the transaction is committed. 1042 * to be freed when the transaction is committed.
1043 */ 1043 */
1044 ilen = XFS_IALLOC_INODES(mp); 1044 ilen = XFS_IALLOC_INODES(mp);
1045 INT_MOD(agi->agi_count, ARCH_CONVERT, -ilen); 1045 be32_add(&agi->agi_count, -ilen);
1046 INT_MOD(agi->agi_freecount, ARCH_CONVERT, -(ilen - 1)); 1046 be32_add(&agi->agi_freecount, -(ilen - 1));
1047 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);
1048 down_read(&mp->m_peraglock); 1048 down_read(&mp->m_peraglock);
1049 mp->m_perag[agno].pagi_freecount -= ilen - 1; 1049 mp->m_perag[agno].pagi_freecount -= ilen - 1;
@@ -1072,7 +1072,7 @@ xfs_difree(
1072 /* 1072 /*
1073 * Change the inode free counts and log the ag/sb changes. 1073 * Change the inode free counts and log the ag/sb changes.
1074 */ 1074 */
1075 INT_MOD(agi->agi_freecount, ARCH_CONVERT, 1); 1075 be32_add(&agi->agi_freecount, 1);
1076 xfs_ialloc_log_agi(tp, agbp, XFS_AGI_FREECOUNT); 1076 xfs_ialloc_log_agi(tp, agbp, XFS_AGI_FREECOUNT);
1077 down_read(&mp->m_peraglock); 1077 down_read(&mp->m_peraglock);
1078 mp->m_perag[agno].pagi_freecount++; 1078 mp->m_perag[agno].pagi_freecount++;
@@ -1098,7 +1098,7 @@ xfs_difree(
1098 goto error0; 1098 goto error0;
1099 } 1099 }
1100 } while (i == 1); 1100 } while (i == 1);
1101 ASSERT(freecount == INT_GET(agi->agi_freecount, ARCH_CONVERT) || 1101 ASSERT(freecount == be32_to_cpu(agi->agi_freecount) ||
1102 XFS_FORCED_SHUTDOWN(mp)); 1102 XFS_FORCED_SHUTDOWN(mp));
1103 } 1103 }
1104#endif 1104#endif
@@ -1307,7 +1307,7 @@ xfs_ialloc_log_agi(
1307 xfs_agi_t *agi; /* allocation group header */ 1307 xfs_agi_t *agi; /* allocation group header */
1308 1308
1309 agi = XFS_BUF_TO_AGI(bp); 1309 agi = XFS_BUF_TO_AGI(bp);
1310 ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC); 1310 ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC);
1311#endif 1311#endif
1312 /* 1312 /*
1313 * Compute byte offsets for the first and last fields. 1313 * Compute byte offsets for the first and last fields.
@@ -1349,9 +1349,8 @@ xfs_ialloc_read_agi(
1349 */ 1349 */
1350 agi = XFS_BUF_TO_AGI(bp); 1350 agi = XFS_BUF_TO_AGI(bp);
1351 agi_ok = 1351 agi_ok =
1352 INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC && 1352 be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC &&
1353 XFS_AGI_GOOD_VERSION( 1353 XFS_AGI_GOOD_VERSION(be32_to_cpu(agi->agi_versionnum));
1354 INT_GET(agi->agi_versionnum, ARCH_CONVERT));
1355 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,
1356 XFS_RANDOM_IALLOC_READ_AGI))) { 1355 XFS_RANDOM_IALLOC_READ_AGI))) {
1357 XFS_CORRUPTION_ERROR("xfs_ialloc_read_agi", XFS_ERRLEVEL_LOW, 1356 XFS_CORRUPTION_ERROR("xfs_ialloc_read_agi", XFS_ERRLEVEL_LOW,
@@ -1361,16 +1360,15 @@ xfs_ialloc_read_agi(
1361 } 1360 }
1362 pag = &mp->m_perag[agno]; 1361 pag = &mp->m_perag[agno];
1363 if (!pag->pagi_init) { 1362 if (!pag->pagi_init) {
1364 pag->pagi_freecount = INT_GET(agi->agi_freecount, ARCH_CONVERT); 1363 pag->pagi_freecount = be32_to_cpu(agi->agi_freecount);
1365 pag->pagi_init = 1; 1364 pag->pagi_init = 1;
1366 } else { 1365 } else {
1367 /* 1366 /*
1368 * It's possible for these to be out of sync if 1367 * It's possible for these to be out of sync if
1369 * we are in the middle of a forced shutdown. 1368 * we are in the middle of a forced shutdown.
1370 */ 1369 */
1371 ASSERT(pag->pagi_freecount == 1370 ASSERT(pag->pagi_freecount == be32_to_cpu(agi->agi_freecount) ||
1372 INT_GET(agi->agi_freecount, ARCH_CONVERT) 1371 XFS_FORCED_SHUTDOWN(mp));
1373 || XFS_FORCED_SHUTDOWN(mp));
1374 } 1372 }
1375 1373
1376#ifdef DEBUG 1374#ifdef DEBUG