Commit 61a258486795ff710cf4518b5a1729c965c32aa0

Authored by Christoph Hellwig
Committed by Tim Shimmin
1 parent e21010053a

[XFS] endianess annotations for xfs_inobt_rec_t / xfs_inobt_key_t

SGI-PV: 954580
SGI-Modid: xfs-linux-melb:xfs-kern:26556a

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nathan Scott <nathans@sgi.com>
Signed-off-by: Tim Shimmin <tes@sgi.com>

Showing 6 changed files with 51 additions and 46 deletions Side-by-side Diff

... ... @@ -170,7 +170,7 @@
170 170  
171 171 k1 = ak1;
172 172 k2 = ak2;
173   - ASSERT(INT_GET(k1->ir_startino, ARCH_CONVERT) < INT_GET(k2->ir_startino, ARCH_CONVERT));
  173 + ASSERT(be32_to_cpu(k1->ir_startino) < be32_to_cpu(k2->ir_startino));
174 174 break;
175 175 }
176 176 default:
... ... @@ -285,8 +285,8 @@
285 285  
286 286 r1 = ar1;
287 287 r2 = ar2;
288   - ASSERT(INT_GET(r1->ir_startino, ARCH_CONVERT) + XFS_INODES_PER_CHUNK <=
289   - INT_GET(r2->ir_startino, ARCH_CONVERT));
  288 + ASSERT(be32_to_cpu(r1->ir_startino) + XFS_INODES_PER_CHUNK <=
  289 + be32_to_cpu(r2->ir_startino));
290 290 break;
291 291 }
292 292 default:
... ... @@ -145,7 +145,7 @@
145 145 union {
146 146 xfs_alloc_rec_incore_t a;
147 147 xfs_bmbt_irec_t b;
148   - xfs_inobt_rec_t i;
  148 + xfs_inobt_rec_incore_t i;
149 149 } bc_rec; /* current insert/search record value */
150 150 struct xfs_buf *bc_bufs[XFS_BTREE_MAXLEVELS]; /* buf ptr per level */
151 151 int bc_ptrs[XFS_BTREE_MAXLEVELS]; /* key/record # */
... ... @@ -529,10 +529,10 @@
529 529 int offset; /* index of inode in chunk */
530 530 xfs_agino_t pagino; /* parent's a.g. relative inode # */
531 531 xfs_agnumber_t pagno; /* parent's allocation group number */
532   - xfs_inobt_rec_t rec; /* inode allocation record */
  532 + xfs_inobt_rec_incore_t rec; /* inode allocation record */
533 533 xfs_agnumber_t tagno; /* testing allocation group number */
534 534 xfs_btree_cur_t *tcur; /* temp cursor */
535   - xfs_inobt_rec_t trec; /* temp inode allocation record */
  535 + xfs_inobt_rec_incore_t trec; /* temp inode allocation record */
536 536  
537 537  
538 538 if (*IO_agbp == NULL) {
... ... @@ -945,7 +945,7 @@
945 945 int ilen; /* inodes in an inode cluster */
946 946 xfs_mount_t *mp; /* mount structure for filesystem */
947 947 int off; /* offset of inode in inode chunk */
948   - xfs_inobt_rec_t rec; /* btree record */
  948 + xfs_inobt_rec_incore_t rec; /* btree record */
949 949  
950 950 mp = tp->t_mountp;
951 951  
fs/xfs/xfs_ialloc_btree.c
... ... @@ -568,7 +568,7 @@
568 568 /*
569 569 * Make a key out of the record data to be inserted, and save it.
570 570 */
571   - key.ir_startino = recp->ir_startino; /* INT_: direct copy */
  571 + key.ir_startino = recp->ir_startino;
572 572 optr = ptr = cur->bc_ptrs[level];
573 573 /*
574 574 * If we're off the left edge, return failure.
... ... @@ -641,7 +641,7 @@
641 641 return error;
642 642 #endif
643 643 ptr = cur->bc_ptrs[level];
644   - nrec.ir_startino = nkey.ir_startino; /* INT_: direct copy */
  644 + nrec.ir_startino = nkey.ir_startino;
645 645 } else {
646 646 /*
647 647 * Otherwise the insert fails.
648 648  
... ... @@ -950,12 +950,12 @@
950 950 xfs_inobt_key_t *kkp;
951 951  
952 952 kkp = kkbase + keyno - 1;
953   - startino = INT_GET(kkp->ir_startino, ARCH_CONVERT);
  953 + startino = be32_to_cpu(kkp->ir_startino);
954 954 } else {
955 955 xfs_inobt_rec_t *krp;
956 956  
957 957 krp = krbase + keyno - 1;
958   - startino = INT_GET(krp->ir_startino, ARCH_CONVERT);
  958 + startino = be32_to_cpu(krp->ir_startino);
959 959 }
960 960 /*
961 961 * Compute difference to get next direction.
... ... @@ -1160,7 +1160,7 @@
1160 1160 } else {
1161 1161 memmove(rrp, rrp + 1, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp));
1162 1162 xfs_inobt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs));
1163   - key.ir_startino = rrp->ir_startino; /* INT_: direct copy */
  1163 + key.ir_startino = rrp->ir_startino;
1164 1164 rkp = &key;
1165 1165 }
1166 1166 /*
1167 1167  
... ... @@ -1301,9 +1301,9 @@
1301 1301 kp[1] = *XFS_INOBT_KEY_ADDR(right, 1, cur); /* INT_: struct copy */
1302 1302 } else {
1303 1303 rp = XFS_INOBT_REC_ADDR(left, 1, cur);
1304   - INT_COPY(kp[0].ir_startino, rp->ir_startino, ARCH_CONVERT);
  1304 + kp[0].ir_startino = rp->ir_startino;
1305 1305 rp = XFS_INOBT_REC_ADDR(right, 1, cur);
1306   - INT_COPY(kp[1].ir_startino, rp->ir_startino, ARCH_CONVERT);
  1306 + kp[1].ir_startino = rp->ir_startino;
1307 1307 }
1308 1308 xfs_inobt_log_keys(cur, nbp, 1, 2);
1309 1309 /*
... ... @@ -1420,7 +1420,7 @@
1420 1420 memmove(rrp + 1, rrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp));
1421 1421 *rrp = *lrp;
1422 1422 xfs_inobt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1);
1423   - key.ir_startino = rrp->ir_startino; /* INT_: direct copy */
  1423 + key.ir_startino = rrp->ir_startino;
1424 1424 rkp = &key;
1425 1425 }
1426 1426 /*
... ... @@ -1559,7 +1559,7 @@
1559 1559 rrp = XFS_INOBT_REC_ADDR(right, 1, cur);
1560 1560 memcpy(rrp, lrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp));
1561 1561 xfs_inobt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs));
1562   - keyp->ir_startino = rrp->ir_startino; /* INT_: direct copy */
  1562 + keyp->ir_startino = rrp->ir_startino;
1563 1563 }
1564 1564 /*
1565 1565 * Find the left block number by looking in the buffer.
... ... @@ -1813,9 +1813,9 @@
1813 1813 * Point to the record and extract its data.
1814 1814 */
1815 1815 rec = XFS_INOBT_REC_ADDR(block, ptr, cur);
1816   - *ino = INT_GET(rec->ir_startino, ARCH_CONVERT);
1817   - *fcnt = INT_GET(rec->ir_freecount, ARCH_CONVERT);
1818   - *free = INT_GET(rec->ir_free, ARCH_CONVERT);
  1816 + *ino = be32_to_cpu(rec->ir_startino);
  1817 + *fcnt = be32_to_cpu(rec->ir_freecount);
  1818 + *free = be64_to_cpu(rec->ir_free);
1819 1819 *stat = 1;
1820 1820 return 0;
1821 1821 }
... ... @@ -1930,9 +1930,9 @@
1930 1930  
1931 1931 level = 0;
1932 1932 nbno = NULLAGBLOCK;
1933   - INT_SET(nrec.ir_startino, ARCH_CONVERT, cur->bc_rec.i.ir_startino);
1934   - INT_SET(nrec.ir_freecount, ARCH_CONVERT, cur->bc_rec.i.ir_freecount);
1935   - INT_SET(nrec.ir_free, ARCH_CONVERT, cur->bc_rec.i.ir_free);
  1933 + nrec.ir_startino = cpu_to_be32(cur->bc_rec.i.ir_startino);
  1934 + nrec.ir_freecount = cpu_to_be32(cur->bc_rec.i.ir_freecount);
  1935 + nrec.ir_free = cpu_to_be64(cur->bc_rec.i.ir_free);
1936 1936 ncur = (xfs_btree_cur_t *)0;
1937 1937 pcur = cur;
1938 1938 /*
... ... @@ -2060,9 +2060,9 @@
2060 2060 /*
2061 2061 * Fill in the new contents and log them.
2062 2062 */
2063   - INT_SET(rp->ir_startino, ARCH_CONVERT, ino);
2064   - INT_SET(rp->ir_freecount, ARCH_CONVERT, fcnt);
2065   - INT_SET(rp->ir_free, ARCH_CONVERT, free);
  2063 + rp->ir_startino = cpu_to_be32(ino);
  2064 + rp->ir_freecount = cpu_to_be32(fcnt);
  2065 + rp->ir_free = cpu_to_be64(free);
2066 2066 xfs_inobt_log_recs(cur, bp, ptr, ptr);
2067 2067 /*
2068 2068 * Updating first record in leaf. Pass new key value up to our parent.
... ... @@ -2070,7 +2070,7 @@
2070 2070 if (ptr == 1) {
2071 2071 xfs_inobt_key_t key; /* key containing [ino] */
2072 2072  
2073   - INT_SET(key.ir_startino, ARCH_CONVERT, ino);
  2073 + key.ir_startino = cpu_to_be32(ino);
2074 2074 if ((error = xfs_inobt_updkey(cur, &key, 1)))
2075 2075 return error;
2076 2076 }
fs/xfs/xfs_ialloc_btree.h
... ... @@ -47,19 +47,24 @@
47 47 /*
48 48 * Data record structure
49 49 */
50   -typedef struct xfs_inobt_rec
51   -{
  50 +typedef struct xfs_inobt_rec {
  51 + __be32 ir_startino; /* starting inode number */
  52 + __be32 ir_freecount; /* count of free inodes (set bits) */
  53 + __be64 ir_free; /* free inode mask */
  54 +} xfs_inobt_rec_t;
  55 +
  56 +typedef struct xfs_inobt_rec_incore {
52 57 xfs_agino_t ir_startino; /* starting inode number */
53 58 __int32_t ir_freecount; /* count of free inodes (set bits) */
54 59 xfs_inofree_t ir_free; /* free inode mask */
55   -} xfs_inobt_rec_t;
  60 +} xfs_inobt_rec_incore_t;
56 61  
  62 +
57 63 /*
58 64 * Key structure
59 65 */
60   -typedef struct xfs_inobt_key
61   -{
62   - xfs_agino_t ir_startino; /* starting inode number */
  66 +typedef struct xfs_inobt_key {
  67 + __be32 ir_startino; /* starting inode number */
63 68 } xfs_inobt_key_t;
64 69  
65 70 /* btree pointer type */
... ... @@ -77,7 +82,7 @@
77 82 #define XFS_INOBT_IS_FREE(rp,i) \
78 83 (((rp)->ir_free & XFS_INOBT_MASK(i)) != 0)
79 84 #define XFS_INOBT_IS_FREE_DISK(rp,i) \
80   - ((INT_GET((rp)->ir_free,ARCH_CONVERT) & XFS_INOBT_MASK(i)) != 0)
  85 + ((be64_to_cpu((rp)->ir_free) & XFS_INOBT_MASK(i)) != 0)
81 86 #define XFS_INOBT_SET_FREE(rp,i) ((rp)->ir_free |= XFS_INOBT_MASK(i))
82 87 #define XFS_INOBT_CLR_FREE(rp,i) ((rp)->ir_free &= ~XFS_INOBT_MASK(i))
83 88  
... ... @@ -395,9 +395,9 @@
395 395 gcnt++;
396 396 }
397 397 gfree |= XFS_INOBT_MASKN(0, chunkidx);
398   - INT_SET(irbp->ir_startino, ARCH_CONVERT, gino);
399   - INT_SET(irbp->ir_freecount, ARCH_CONVERT, gcnt);
400   - INT_SET(irbp->ir_free, ARCH_CONVERT, gfree);
  398 + irbp->ir_startino = cpu_to_be32(gino);
  399 + irbp->ir_freecount = cpu_to_be32(gcnt);
  400 + irbp->ir_free = cpu_to_be64(gfree);
401 401 irbp++;
402 402 agino = gino + XFS_INODES_PER_CHUNK;
403 403 icount = XFS_INODES_PER_CHUNK - gcnt;
... ... @@ -453,9 +453,9 @@
453 453 * If this chunk has any allocated inodes, save it.
454 454 */
455 455 if (gcnt < XFS_INODES_PER_CHUNK) {
456   - INT_SET(irbp->ir_startino, ARCH_CONVERT, gino);
457   - INT_SET(irbp->ir_freecount, ARCH_CONVERT, gcnt);
458   - INT_SET(irbp->ir_free, ARCH_CONVERT, gfree);
  456 + irbp->ir_startino = cpu_to_be32(gino);
  457 + irbp->ir_freecount = cpu_to_be32(gcnt);
  458 + irbp->ir_free = cpu_to_be64(gfree);
459 459 irbp++;
460 460 icount += XFS_INODES_PER_CHUNK - gcnt;
461 461 }
462 462  
... ... @@ -488,14 +488,14 @@
488 488 * inodes in that cluster.
489 489 */
490 490 for (agbno = XFS_AGINO_TO_AGBNO(mp,
491   - INT_GET(irbp[1].ir_startino, ARCH_CONVERT)),
  491 + be32_to_cpu(irbp[1].ir_startino)),
492 492 chunkidx = 0;
493 493 chunkidx < XFS_INODES_PER_CHUNK;
494 494 chunkidx += nicluster,
495 495 agbno += nbcluster) {
496 496 if (XFS_INOBT_MASKN(chunkidx,
497 497 nicluster) &
498   - ~(INT_GET(irbp[1].ir_free, ARCH_CONVERT)))
  498 + ~(be64_to_cpu(irbp[1].ir_free)))
499 499 xfs_btree_reada_bufs(mp, agno,
500 500 agbno, nbcluster);
501 501 }
502 502  
... ... @@ -503,9 +503,9 @@
503 503 /*
504 504 * Now process this chunk of inodes.
505 505 */
506   - for (agino = INT_GET(irbp->ir_startino, ARCH_CONVERT), chunkidx = 0, clustidx = 0;
  506 + for (agino = be32_to_cpu(irbp->ir_startino), chunkidx = 0, clustidx = 0;
507 507 ubleft > 0 &&
508   - INT_GET(irbp->ir_freecount, ARCH_CONVERT) < XFS_INODES_PER_CHUNK;
  508 + be32_to_cpu(irbp->ir_freecount) < XFS_INODES_PER_CHUNK;
509 509 chunkidx++, clustidx++, agino++) {
510 510 ASSERT(chunkidx < XFS_INODES_PER_CHUNK);
511 511 /*
... ... @@ -525,7 +525,7 @@
525 525 */
526 526 if ((chunkidx & (nicluster - 1)) == 0) {
527 527 agbno = XFS_AGINO_TO_AGBNO(mp,
528   - INT_GET(irbp->ir_startino, ARCH_CONVERT)) +
  528 + be32_to_cpu(irbp->ir_startino)) +
529 529 ((chunkidx & nimask) >>
530 530 mp->m_sb.sb_inopblog);
531 531  
532 532  
... ... @@ -564,13 +564,13 @@
564 564 /*
565 565 * Skip if this inode is free.
566 566 */
567   - if (XFS_INOBT_MASK(chunkidx) & INT_GET(irbp->ir_free, ARCH_CONVERT))
  567 + if (XFS_INOBT_MASK(chunkidx) & be64_to_cpu(irbp->ir_free))
568 568 continue;
569 569 /*
570 570 * Count used inodes as free so we can tell
571 571 * when the chunk is used up.
572 572 */
573   - INT_MOD(irbp->ir_freecount, ARCH_CONVERT, +1);
  573 + be32_add(&irbp->ir_freecount, 1);
574 574 ino = XFS_AGINO_TO_INO(mp, agno, agino);
575 575 bno = XFS_AGB_TO_DADDR(mp, agno, agbno);
576 576 if (flags & BULKSTAT_FG_QUICK) {