Commit a6f64d4aea0d0c8483e910c7dd2d1ee48e42245c

Authored by Christoph Hellwig
Committed by Tim Shimmin
1 parent d580ef6eaa

[XFS] split ondisk vs incore versions of xfs_bmbt_rec_t

currently xfs_bmbt_rec_t is used both for ondisk extents as well as
host-endian ones. This patch adds a new xfs_bmbt_rec_host_t for the native
endian ones and cleans up the fallout. There have been various endianess
issues in the tracing / debug printf code that are fixed by this patch.

SGI-PV: 968563
SGI-Modid: xfs-linux-melb:xfs-kern:29318a

Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: David Chinner <dgc@sgi.com>
Signed-off-by: Tim Shimmin <tes@sgi.com>

Showing 7 changed files with 95 additions and 127 deletions Side-by-side Diff

fs/xfs/quota/xfs_qm.c
... ... @@ -1717,7 +1717,6 @@
1717 1717 xfs_extnum_t idx; /* extent record index */
1718 1718 xfs_ifork_t *ifp; /* inode fork pointer */
1719 1719 xfs_extnum_t nextents; /* number of extent entries */
1720   - xfs_bmbt_rec_t *ep; /* pointer to an extent entry */
1721 1720 int error;
1722 1721  
1723 1722 ASSERT(XFS_IS_REALTIME_INODE(ip));
... ... @@ -1728,10 +1727,8 @@
1728 1727 }
1729 1728 rtblks = 0;
1730 1729 nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
1731   - for (idx = 0; idx < nextents; idx++) {
1732   - ep = xfs_iext_get_ext(ifp, idx);
1733   - rtblks += xfs_bmbt_get_blockcount(ep);
1734   - }
  1730 + for (idx = 0; idx < nextents; idx++)
  1731 + rtblks += xfs_bmbt_get_blockcount(xfs_iext_get_ext(ifp, idx));
1735 1732 *O_rtblks = (xfs_qcnt_t)rtblks;
1736 1733 return 0;
1737 1734 }
... ... @@ -248,7 +248,7 @@
248 248 * Else, *lastxp will be set to the index of the found
249 249 * entry; *gotp will contain the entry.
250 250 */
251   -STATIC xfs_bmbt_rec_t * /* pointer to found extent entry */
  251 +STATIC xfs_bmbt_rec_host_t * /* pointer to found extent entry */
252 252 xfs_bmap_search_extents(
253 253 xfs_inode_t *ip, /* incore inode pointer */
254 254 xfs_fileoff_t bno, /* block number searched for */
... ... @@ -273,21 +273,6 @@
273 273  
274 274 #ifdef XFS_BMAP_TRACE
275 275 /*
276   - * Add a bmap trace buffer entry. Base routine for the others.
277   - */
278   -STATIC void
279   -xfs_bmap_trace_addentry(
280   - int opcode, /* operation */
281   - const char *fname, /* function name */
282   - char *desc, /* operation description */
283   - xfs_inode_t *ip, /* incore inode pointer */
284   - xfs_extnum_t idx, /* index of entry(ies) */
285   - xfs_extnum_t cnt, /* count of entries, 1 or 2 */
286   - xfs_bmbt_rec_t *r1, /* first record */
287   - xfs_bmbt_rec_t *r2, /* second record or null */
288   - int whichfork); /* data or attr fork */
289   -
290   -/*
291 276 * Add bmap trace entry prior to a call to xfs_iext_remove.
292 277 */
293 278 STATIC void
... ... @@ -714,7 +699,7 @@
714 699 {
715 700 xfs_btree_cur_t *cur; /* btree cursor */
716 701 int diff; /* temp value */
717   - xfs_bmbt_rec_t *ep; /* extent entry for idx */
  702 + xfs_bmbt_rec_host_t *ep; /* extent entry for idx */
718 703 int error; /* error return value */
719 704 int i; /* temp state */
720 705 xfs_ifork_t *ifp; /* inode fork pointer */
... ... @@ -1270,7 +1255,7 @@
1270 1255 xfs_extdelta_t *delta) /* Change made to incore extents */
1271 1256 {
1272 1257 xfs_btree_cur_t *cur; /* btree cursor */
1273   - xfs_bmbt_rec_t *ep; /* extent entry for idx */
  1258 + xfs_bmbt_rec_host_t *ep; /* extent entry for idx */
1274 1259 int error; /* error return value */
1275 1260 int i; /* temp state */
1276 1261 xfs_ifork_t *ifp; /* inode fork pointer */
... ... @@ -1823,7 +1808,7 @@
1823 1808 xfs_extdelta_t *delta, /* Change made to incore extents */
1824 1809 int rsvd) /* OK to allocate reserved blocks */
1825 1810 {
1826   - xfs_bmbt_rec_t *ep; /* extent record for idx */
  1811 + xfs_bmbt_rec_host_t *ep; /* extent record for idx */
1827 1812 xfs_ifork_t *ifp; /* inode fork pointer */
1828 1813 xfs_bmbt_irec_t left; /* left neighbor extent entry */
1829 1814 xfs_filblks_t newlen=0; /* new indirect size */
... ... @@ -2012,7 +1997,7 @@
2012 1997 xfs_extdelta_t *delta, /* Change made to incore extents */
2013 1998 int whichfork) /* data or attr fork */
2014 1999 {
2015   - xfs_bmbt_rec_t *ep; /* pointer to extent entry ins. point */
  2000 + xfs_bmbt_rec_host_t *ep; /* pointer to extent entry ins. point */
2016 2001 int error; /* error return value */
2017 2002 int i; /* temp state */
2018 2003 xfs_ifork_t *ifp; /* inode fork pointer */
... ... @@ -3070,7 +3055,7 @@
3070 3055 xfs_fileoff_t del_endoff; /* first offset past del */
3071 3056 int delay; /* current block is delayed allocated */
3072 3057 int do_fx; /* free extent at end of routine */
3073   - xfs_bmbt_rec_t *ep; /* current extent entry pointer */
  3058 + xfs_bmbt_rec_host_t *ep; /* current extent entry pointer */
3074 3059 int error; /* error return value */
3075 3060 int flags; /* inode logging flags */
3076 3061 xfs_bmbt_irec_t got; /* current extent entry */
... ... @@ -3418,7 +3403,7 @@
3418 3403 xfs_bmbt_rec_t *arp; /* child record pointer */
3419 3404 xfs_bmbt_block_t *block; /* btree root block */
3420 3405 xfs_btree_cur_t *cur; /* bmap btree cursor */
3421   - xfs_bmbt_rec_t *ep; /* extent record pointer */
  3406 + xfs_bmbt_rec_host_t *ep; /* extent record pointer */
3422 3407 int error; /* error return value */
3423 3408 xfs_extnum_t i, cnt; /* extent record index */
3424 3409 xfs_ifork_t *ifp; /* inode fork pointer */
... ... @@ -3590,7 +3575,7 @@
3590 3575 if (ifp->if_bytes) {
3591 3576 xfs_alloc_arg_t args; /* allocation arguments */
3592 3577 xfs_buf_t *bp; /* buffer for extent block */
3593   - xfs_bmbt_rec_t *ep; /* extent record pointer */
  3578 + xfs_bmbt_rec_host_t *ep;/* extent record pointer */
3594 3579  
3595 3580 args.tp = tp;
3596 3581 args.mp = ip->i_mount;
... ... @@ -3655,7 +3640,7 @@
3655 3640 * entry (null if none). Else, *lastxp will be set to the index
3656 3641 * of the found entry; *gotp will contain the entry.
3657 3642 */
3658   -xfs_bmbt_rec_t * /* pointer to found extent entry */
  3643 +xfs_bmbt_rec_host_t * /* pointer to found extent entry */
3659 3644 xfs_bmap_search_multi_extents(
3660 3645 xfs_ifork_t *ifp, /* inode fork pointer */
3661 3646 xfs_fileoff_t bno, /* block number searched for */
... ... @@ -3664,7 +3649,7 @@
3664 3649 xfs_bmbt_irec_t *gotp, /* out: extent entry found */
3665 3650 xfs_bmbt_irec_t *prevp) /* out: previous extent entry found */
3666 3651 {
3667   - xfs_bmbt_rec_t *ep; /* extent record pointer */
  3652 + xfs_bmbt_rec_host_t *ep; /* extent record pointer */
3668 3653 xfs_extnum_t lastx; /* last extent index */
3669 3654  
3670 3655 /*
... ... @@ -3706,7 +3691,7 @@
3706 3691 * Else, *lastxp will be set to the index of the found
3707 3692 * entry; *gotp will contain the entry.
3708 3693 */
3709   -STATIC xfs_bmbt_rec_t * /* pointer to found extent entry */
  3694 +STATIC xfs_bmbt_rec_host_t * /* pointer to found extent entry */
3710 3695 xfs_bmap_search_extents(
3711 3696 xfs_inode_t *ip, /* incore inode pointer */
3712 3697 xfs_fileoff_t bno, /* block number searched for */
... ... @@ -3717,7 +3702,7 @@
3717 3702 xfs_bmbt_irec_t *prevp) /* out: previous extent entry found */
3718 3703 {
3719 3704 xfs_ifork_t *ifp; /* inode fork pointer */
3720   - xfs_bmbt_rec_t *ep; /* extent record pointer */
  3705 + xfs_bmbt_rec_host_t *ep; /* extent record pointer */
3721 3706  
3722 3707 XFS_STATS_INC(xs_look_exlist);
3723 3708 ifp = XFS_IFORK_PTR(ip, fork);
3724 3709  
... ... @@ -3757,11 +3742,11 @@
3757 3742 xfs_inode_t *ip, /* incore inode pointer */
3758 3743 xfs_extnum_t idx, /* index of entry(ies) */
3759 3744 xfs_extnum_t cnt, /* count of entries, 1 or 2 */
3760   - xfs_bmbt_rec_t *r1, /* first record */
3761   - xfs_bmbt_rec_t *r2, /* second record or null */
  3745 + xfs_bmbt_rec_host_t *r1, /* first record */
  3746 + xfs_bmbt_rec_host_t *r2, /* second record or null */
3762 3747 int whichfork) /* data or attr fork */
3763 3748 {
3764   - xfs_bmbt_rec_t tr2;
  3749 + xfs_bmbt_rec_host_t tr2;
3765 3750  
3766 3751 ASSERT(cnt == 1 || cnt == 2);
3767 3752 ASSERT(r1 != NULL);
... ... @@ -3842,8 +3827,8 @@
3842 3827 xfs_bmbt_irec_t *r2, /* inserted record 2 or null */
3843 3828 int whichfork) /* data or attr fork */
3844 3829 {
3845   - xfs_bmbt_rec_t tr1; /* compressed record 1 */
3846   - xfs_bmbt_rec_t tr2; /* compressed record 2 if needed */
  3830 + xfs_bmbt_rec_host_t tr1; /* compressed record 1 */
  3831 + xfs_bmbt_rec_host_t tr2; /* compressed record 2 if needed */
3847 3832  
3848 3833 xfs_bmbt_set_all(&tr1, r1);
3849 3834 if (cnt == 2) {
... ... @@ -4316,7 +4301,6 @@
4316 4301 xfs_fileoff_t *first_unused, /* unused block */
4317 4302 int whichfork) /* data or attr fork */
4318 4303 {
4319   - xfs_bmbt_rec_t *ep; /* pointer to an extent entry */
4320 4304 int error; /* error return value */
4321 4305 int idx; /* extent record index */
4322 4306 xfs_ifork_t *ifp; /* inode fork pointer */
... ... @@ -4340,7 +4324,7 @@
4340 4324 lowest = *first_unused;
4341 4325 nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
4342 4326 for (idx = 0, lastaddr = 0, max = lowest; idx < nextents; idx++) {
4343   - ep = xfs_iext_get_ext(ifp, idx);
  4327 + xfs_bmbt_rec_host_t *ep = xfs_iext_get_ext(ifp, idx);
4344 4328 off = xfs_bmbt_get_startoff(ep);
4345 4329 /*
4346 4330 * See if the hole before this extent will work.
... ... @@ -4371,7 +4355,7 @@
4371 4355 {
4372 4356 xfs_fileoff_t bno; /* input file offset */
4373 4357 int eof; /* hit end of file */
4374   - xfs_bmbt_rec_t *ep; /* pointer to last extent */
  4358 + xfs_bmbt_rec_host_t *ep; /* pointer to last extent */
4375 4359 int error; /* error return value */
4376 4360 xfs_bmbt_irec_t got; /* current extent value */
4377 4361 xfs_ifork_t *ifp; /* inode fork pointer */
... ... @@ -4417,7 +4401,7 @@
4417 4401 xfs_fileoff_t *last_block, /* last block */
4418 4402 int whichfork) /* data or attr fork */
4419 4403 {
4420   - xfs_bmbt_rec_t *ep; /* pointer to last extent */
  4404 + xfs_bmbt_rec_host_t *ep; /* pointer to last extent */
4421 4405 int error; /* error return value */
4422 4406 xfs_ifork_t *ifp; /* inode fork pointer */
4423 4407 xfs_extnum_t nextents; /* number of extent entries */
... ... @@ -4454,7 +4438,7 @@
4454 4438 xfs_inode_t *ip, /* incore inode */
4455 4439 int whichfork) /* data or attr fork */
4456 4440 {
4457   - xfs_bmbt_rec_t *ep; /* ptr to fork's extent */
  4441 + xfs_bmbt_rec_host_t *ep; /* ptr to fork's extent */
4458 4442 xfs_ifork_t *ifp; /* inode fork pointer */
4459 4443 int rval; /* return value */
4460 4444 xfs_bmbt_irec_t s; /* internal version of extent */
... ... @@ -4549,7 +4533,7 @@
4549 4533 * Loop over all leaf nodes. Copy information to the extent records.
4550 4534 */
4551 4535 for (;;) {
4552   - xfs_bmbt_rec_t *frp, *trp;
  4536 + xfs_bmbt_rec_t *frp;
4553 4537 xfs_fsblock_t nextbno;
4554 4538 xfs_extnum_t num_recs;
4555 4539 xfs_extnum_t start;
... ... @@ -4581,7 +4565,7 @@
4581 4565 frp = XFS_BTREE_REC_ADDR(xfs_bmbt, block, 1);
4582 4566 start = i;
4583 4567 for (j = 0; j < num_recs; j++, i++, frp++) {
4584   - trp = xfs_iext_get_ext(ifp, i);
  4568 + xfs_bmbt_rec_host_t *trp = xfs_iext_get_ext(ifp, i);
4585 4569 trp->l0 = INT_GET(frp->l0, ARCH_CONVERT);
4586 4570 trp->l1 = INT_GET(frp->l1, ARCH_CONVERT);
4587 4571 }
... ... @@ -4631,7 +4615,7 @@
4631 4615 xfs_extnum_t cnt, /* count of entries in the list */
4632 4616 int whichfork) /* data or attr fork */
4633 4617 {
4634   - xfs_bmbt_rec_t *ep; /* current extent record */
  4618 + xfs_bmbt_rec_host_t *ep; /* current extent record */
4635 4619 xfs_extnum_t idx; /* extent record index */
4636 4620 xfs_ifork_t *ifp; /* inode fork pointer */
4637 4621 xfs_bmbt_irec_t s; /* file extent record */
... ... @@ -4727,7 +4711,7 @@
4727 4711 xfs_btree_cur_t *cur; /* bmap btree cursor */
4728 4712 xfs_fileoff_t end; /* end of mapped file region */
4729 4713 int eof; /* we've hit the end of extents */
4730   - xfs_bmbt_rec_t *ep; /* extent record pointer */
  4714 + xfs_bmbt_rec_host_t *ep; /* extent record pointer */
4731 4715 int error; /* error return */
4732 4716 xfs_bmbt_irec_t got; /* current file extent record */
4733 4717 xfs_ifork_t *ifp; /* inode fork pointer */
... ... @@ -5378,7 +5362,7 @@
5378 5362 xfs_btree_cur_t *cur; /* bmap btree cursor */
5379 5363 xfs_bmbt_irec_t del; /* extent being deleted */
5380 5364 int eof; /* is deleting at eof */
5381   - xfs_bmbt_rec_t *ep; /* extent record pointer */
  5365 + xfs_bmbt_rec_host_t *ep; /* extent record pointer */
5382 5366 int error; /* error return value */
5383 5367 xfs_extnum_t extno; /* extent number in list */
5384 5368 xfs_bmbt_irec_t got; /* current extent record */
... ... @@ -6004,7 +5988,7 @@
6004 5988 {
6005 5989 int error; /* error return value */
6006 5990 xfs_ifork_t *ifp; /* inode fork pointer */
6007   - xfs_bmbt_rec_t *lastrec; /* extent record pointer */
  5991 + xfs_bmbt_rec_host_t *lastrec; /* extent record pointer */
6008 5992 xfs_extnum_t nextents; /* number of file extents */
6009 5993 xfs_bmbt_irec_t s; /* expanded extent record */
6010 5994  
... ... @@ -6048,7 +6032,7 @@
6048 6032 xfs_fsblock_t blockcount; /* extent block count */
6049 6033 int error; /* error return value */
6050 6034 xfs_ifork_t *ifp; /* inode fork pointer */
6051   - xfs_bmbt_rec_t *lastrec; /* extent record pointer */
  6035 + xfs_bmbt_rec_host_t *lastrec; /* extent record pointer */
6052 6036 xfs_extnum_t nextents; /* number of file extents */
6053 6037 xfs_fileoff_t startoff; /* extent starting file offset */
6054 6038  
6055 6039  
... ... @@ -6495,10 +6479,9 @@
6495 6479 int *count)
6496 6480 {
6497 6481 int b;
6498   - xfs_bmbt_rec_t *frp;
6499 6482  
6500 6483 for (b = 0; b < numrecs; b++) {
6501   - frp = xfs_iext_get_ext(ifp, idx + b);
  6484 + xfs_bmbt_rec_host_t *frp = xfs_iext_get_ext(ifp, idx + b);
6502 6485 *count += xfs_bmbt_get_blockcount(frp);
6503 6486 }
6504 6487 return 0;
... ... @@ -378,7 +378,7 @@
378 378 * entry (null if none). Else, *lastxp will be set to the index
379 379 * of the found entry; *gotp will contain the entry.
380 380 */
381   -xfs_bmbt_rec_t *
  381 +xfs_bmbt_rec_host_t *
382 382 xfs_bmap_search_multi_extents(struct xfs_ifork *, xfs_fileoff_t, int *,
383 383 xfs_extnum_t *, xfs_bmbt_irec_t *, xfs_bmbt_irec_t *);
384 384  
fs/xfs/xfs_bmap_btree.c
... ... @@ -260,13 +260,14 @@
260 260 char *s,
261 261 int line)
262 262 {
263   - xfs_bmbt_rec_t r;
  263 + xfs_bmbt_rec_host_t r;
264 264  
265 265 xfs_bmbt_set_all(&r, &cur->bc_rec.b);
266 266 xfs_bmbt_trace_enter(func, cur, s, XFS_BMBT_KTRACE_CUR, line,
267 267 (cur->bc_nlevels << 24) | (cur->bc_private.b.flags << 16) |
268 268 cur->bc_private.b.allocated,
269   - INT_GET(r.l0, ARCH_CONVERT) >> 32, (int)INT_GET(r.l0, ARCH_CONVERT), INT_GET(r.l1, ARCH_CONVERT) >> 32, (int)INT_GET(r.l1, ARCH_CONVERT),
  269 + r.l0 >> 32, (int)r.l0,
  270 + r.l1 >> 32, (int)r.l1,
270 271 (unsigned long)cur->bc_bufs[0], (unsigned long)cur->bc_bufs[1],
271 272 (unsigned long)cur->bc_bufs[2], (unsigned long)cur->bc_bufs[3],
272 273 (cur->bc_ptrs[0] << 16) | cur->bc_ptrs[1],
... ... @@ -1826,7 +1827,7 @@
1826 1827  
1827 1828 void
1828 1829 xfs_bmbt_get_all(
1829   - xfs_bmbt_rec_t *r,
  1830 + xfs_bmbt_rec_host_t *r,
1830 1831 xfs_bmbt_irec_t *s)
1831 1832 {
1832 1833 __xfs_bmbt_get_all(r->l0, r->l1, s);
... ... @@ -1862,7 +1863,7 @@
1862 1863 */
1863 1864 xfs_filblks_t
1864 1865 xfs_bmbt_get_blockcount(
1865   - xfs_bmbt_rec_t *r)
  1866 + xfs_bmbt_rec_host_t *r)
1866 1867 {
1867 1868 return (xfs_filblks_t)(r->l1 & XFS_MASK64LO(21));
1868 1869 }
... ... @@ -1872,7 +1873,7 @@
1872 1873 */
1873 1874 xfs_fsblock_t
1874 1875 xfs_bmbt_get_startblock(
1875   - xfs_bmbt_rec_t *r)
  1876 + xfs_bmbt_rec_host_t *r)
1876 1877 {
1877 1878 #if XFS_BIG_BLKNOS
1878 1879 return (((xfs_fsblock_t)r->l0 & XFS_MASK64LO(9)) << 43) |
... ... @@ -1896,7 +1897,7 @@
1896 1897 */
1897 1898 xfs_fileoff_t
1898 1899 xfs_bmbt_get_startoff(
1899   - xfs_bmbt_rec_t *r)
  1900 + xfs_bmbt_rec_host_t *r)
1900 1901 {
1901 1902 return ((xfs_fileoff_t)r->l0 &
1902 1903 XFS_MASK64LO(64 - BMBT_EXNTFLAG_BITLEN)) >> 9;
... ... @@ -1904,7 +1905,7 @@
1904 1905  
1905 1906 xfs_exntst_t
1906 1907 xfs_bmbt_get_state(
1907   - xfs_bmbt_rec_t *r)
  1908 + xfs_bmbt_rec_host_t *r)
1908 1909 {
1909 1910 int ext_flag;
1910 1911  
... ... @@ -2294,7 +2295,7 @@
2294 2295 */
2295 2296 void
2296 2297 xfs_bmbt_set_all(
2297   - xfs_bmbt_rec_t *r,
  2298 + xfs_bmbt_rec_host_t *r,
2298 2299 xfs_bmbt_irec_t *s)
2299 2300 {
2300 2301 int extent_flag;
... ... @@ -2336,7 +2337,7 @@
2336 2337 */
2337 2338 void
2338 2339 xfs_bmbt_set_allf(
2339   - xfs_bmbt_rec_t *r,
  2340 + xfs_bmbt_rec_host_t *r,
2340 2341 xfs_fileoff_t o,
2341 2342 xfs_fsblock_t b,
2342 2343 xfs_filblks_t c,
... ... @@ -2468,7 +2469,7 @@
2468 2469 */
2469 2470 void
2470 2471 xfs_bmbt_set_blockcount(
2471   - xfs_bmbt_rec_t *r,
  2472 + xfs_bmbt_rec_host_t *r,
2472 2473 xfs_filblks_t v)
2473 2474 {
2474 2475 ASSERT((v & XFS_MASK64HI(43)) == 0);
... ... @@ -2481,7 +2482,7 @@
2481 2482 */
2482 2483 void
2483 2484 xfs_bmbt_set_startblock(
2484   - xfs_bmbt_rec_t *r,
  2485 + xfs_bmbt_rec_host_t *r,
2485 2486 xfs_fsblock_t v)
2486 2487 {
2487 2488 #if XFS_BIG_BLKNOS
... ... @@ -2509,7 +2510,7 @@
2509 2510 */
2510 2511 void
2511 2512 xfs_bmbt_set_startoff(
2512   - xfs_bmbt_rec_t *r,
  2513 + xfs_bmbt_rec_host_t *r,
2513 2514 xfs_fileoff_t v)
2514 2515 {
2515 2516 ASSERT((v & XFS_MASK64HI(9)) == 0);
... ... @@ -2523,7 +2524,7 @@
2523 2524 */
2524 2525 void
2525 2526 xfs_bmbt_set_state(
2526   - xfs_bmbt_rec_t *r,
  2527 + xfs_bmbt_rec_host_t *r,
2527 2528 xfs_exntst_t v)
2528 2529 {
2529 2530 ASSERT(v == XFS_EXT_NORM || v == XFS_EXT_UNWRITTEN);
2530 2531  
... ... @@ -2624,10 +2625,8 @@
2624 2625 xfs_extnum_t idx,
2625 2626 xfs_extnum_t num)
2626 2627 {
2627   - xfs_bmbt_rec_t *ep;
2628   -
2629 2628 for (; num > 0; num--, idx++) {
2630   - ep = xfs_iext_get_ext(ifp, idx);
  2629 + xfs_bmbt_rec_host_t *ep = xfs_iext_get_ext(ifp, idx);
2631 2630 if ((ep->l0 >>
2632 2631 (64 - BMBT_EXNTFLAG_BITLEN)) != 0) {
2633 2632 ASSERT(0);
fs/xfs/xfs_bmap_btree.h
... ... @@ -89,6 +89,10 @@
89 89 typedef __uint64_t xfs_bmbt_rec_base_t; /* use this for casts */
90 90 typedef xfs_bmbt_rec_64_t xfs_bmbt_rec_t, xfs_bmdr_rec_t;
91 91  
  92 +typedef struct xfs_bmbt_rec_host {
  93 + __uint64_t l0, l1;
  94 +} xfs_bmbt_rec_host_t;
  95 +
92 96 /*
93 97 * Values and macros for delayed-allocation startblock fields.
94 98 */
95 99  
... ... @@ -281,13 +285,13 @@
281 285 extern void xfs_bmdr_to_bmbt(xfs_bmdr_block_t *, int, xfs_bmbt_block_t *, int);
282 286 extern int xfs_bmbt_decrement(struct xfs_btree_cur *, int, int *);
283 287 extern int xfs_bmbt_delete(struct xfs_btree_cur *, int *);
284   -extern void xfs_bmbt_get_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s);
  288 +extern void xfs_bmbt_get_all(xfs_bmbt_rec_host_t *r, xfs_bmbt_irec_t *s);
285 289 extern xfs_bmbt_block_t *xfs_bmbt_get_block(struct xfs_btree_cur *cur,
286 290 int, struct xfs_buf **bpp);
287   -extern xfs_filblks_t xfs_bmbt_get_blockcount(xfs_bmbt_rec_t *r);
288   -extern xfs_fsblock_t xfs_bmbt_get_startblock(xfs_bmbt_rec_t *r);
289   -extern xfs_fileoff_t xfs_bmbt_get_startoff(xfs_bmbt_rec_t *r);
290   -extern xfs_exntst_t xfs_bmbt_get_state(xfs_bmbt_rec_t *r);
  291 +extern xfs_filblks_t xfs_bmbt_get_blockcount(xfs_bmbt_rec_host_t *r);
  292 +extern xfs_fsblock_t xfs_bmbt_get_startblock(xfs_bmbt_rec_host_t *r);
  293 +extern xfs_fileoff_t xfs_bmbt_get_startoff(xfs_bmbt_rec_host_t *r);
  294 +extern xfs_exntst_t xfs_bmbt_get_state(xfs_bmbt_rec_host_t *r);
291 295  
292 296 #ifndef XFS_NATIVE_HOST
293 297 extern void xfs_bmbt_disk_get_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s);
294 298  
... ... @@ -315,13 +319,13 @@
315 319 */
316 320 extern int xfs_bmbt_newroot(struct xfs_btree_cur *cur, int *lflags, int *stat);
317 321  
318   -extern void xfs_bmbt_set_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s);
319   -extern void xfs_bmbt_set_allf(xfs_bmbt_rec_t *r, xfs_fileoff_t o,
  322 +extern void xfs_bmbt_set_all(xfs_bmbt_rec_host_t *r, xfs_bmbt_irec_t *s);
  323 +extern void xfs_bmbt_set_allf(xfs_bmbt_rec_host_t *r, xfs_fileoff_t o,
320 324 xfs_fsblock_t b, xfs_filblks_t c, xfs_exntst_t v);
321   -extern void xfs_bmbt_set_blockcount(xfs_bmbt_rec_t *r, xfs_filblks_t v);
322   -extern void xfs_bmbt_set_startblock(xfs_bmbt_rec_t *r, xfs_fsblock_t v);
323   -extern void xfs_bmbt_set_startoff(xfs_bmbt_rec_t *r, xfs_fileoff_t v);
324   -extern void xfs_bmbt_set_state(xfs_bmbt_rec_t *r, xfs_exntst_t v);
  325 +extern void xfs_bmbt_set_blockcount(xfs_bmbt_rec_host_t *r, xfs_filblks_t v);
  326 +extern void xfs_bmbt_set_startblock(xfs_bmbt_rec_host_t *r, xfs_fsblock_t v);
  327 +extern void xfs_bmbt_set_startoff(xfs_bmbt_rec_host_t *r, xfs_fileoff_t v);
  328 +extern void xfs_bmbt_set_state(xfs_bmbt_rec_host_t *r, xfs_exntst_t v);
325 329  
326 330 #ifndef XFS_NATIVE_HOST
327 331 extern void xfs_bmbt_disk_set_all(xfs_bmbt_rec_t *r, xfs_bmbt_irec_t *s);
... ... @@ -67,7 +67,6 @@
67 67 STATIC int xfs_iformat_extents(xfs_inode_t *, xfs_dinode_t *, int);
68 68 STATIC int xfs_iformat_btree(xfs_inode_t *, xfs_dinode_t *, int);
69 69  
70   -
71 70 #ifdef DEBUG
72 71 /*
73 72 * Make sure that the extents in the given memory buffer
74 73  
75 74  
76 75  
77 76  
... ... @@ -77,28 +76,23 @@
77 76 xfs_validate_extents(
78 77 xfs_ifork_t *ifp,
79 78 int nrecs,
80   - int disk,
81 79 xfs_exntfmt_t fmt)
82 80 {
83   - xfs_bmbt_rec_t *ep;
84 81 xfs_bmbt_irec_t irec;
85   - xfs_bmbt_rec_t rec;
  82 + xfs_bmbt_rec_host_t rec;
86 83 int i;
87 84  
88 85 for (i = 0; i < nrecs; i++) {
89   - ep = xfs_iext_get_ext(ifp, i);
90   - rec.l0 = get_unaligned((__uint64_t*)&ep->l0);
91   - rec.l1 = get_unaligned((__uint64_t*)&ep->l1);
92   - if (disk)
93   - xfs_bmbt_disk_get_all(&rec, &irec);
94   - else
95   - xfs_bmbt_get_all(&rec, &irec);
  86 + xfs_bmbt_rec_host_t *ep = xfs_iext_get_ext(ifp, i);
  87 + rec.l0 = get_unaligned(&ep->l0);
  88 + rec.l1 = get_unaligned(&ep->l1);
  89 + xfs_bmbt_get_all(&rec, &irec);
96 90 if (fmt == XFS_EXTFMT_NOSTATE)
97 91 ASSERT(irec.br_state == XFS_EXT_NORM);
98 92 }
99 93 }
100 94 #else /* DEBUG */
101   -#define xfs_validate_extents(ifp, nrecs, disk, fmt)
  95 +#define xfs_validate_extents(ifp, nrecs, fmt)
102 96 #endif /* DEBUG */
103 97  
104 98 /*
... ... @@ -602,7 +596,7 @@
602 596 xfs_dinode_t *dip,
603 597 int whichfork)
604 598 {
605   - xfs_bmbt_rec_t *ep, *dp;
  599 + xfs_bmbt_rec_t *dp;
606 600 xfs_ifork_t *ifp;
607 601 int nex;
608 602 int size;
609 603  
... ... @@ -637,9 +631,9 @@
637 631 ifp->if_bytes = size;
638 632 if (size) {
639 633 dp = (xfs_bmbt_rec_t *) XFS_DFORK_PTR(dip, whichfork);
640   - xfs_validate_extents(ifp, nex, 1, XFS_EXTFMT_INODE(ip));
  634 + xfs_validate_extents(ifp, nex, XFS_EXTFMT_INODE(ip));
641 635 for (i = 0; i < nex; i++, dp++) {
642   - ep = xfs_iext_get_ext(ifp, i);
  636 + xfs_bmbt_rec_host_t *ep = xfs_iext_get_ext(ifp, i);
643 637 ep->l0 = INT_GET(get_unaligned((__uint64_t*)&dp->l0),
644 638 ARCH_CONVERT);
645 639 ep->l1 = INT_GET(get_unaligned((__uint64_t*)&dp->l1),
... ... @@ -1048,7 +1042,7 @@
1048 1042 ifp->if_flags &= ~XFS_IFEXTENTS;
1049 1043 return error;
1050 1044 }
1051   - xfs_validate_extents(ifp, nextents, 0, XFS_EXTFMT_INODE(ip));
  1045 + xfs_validate_extents(ifp, nextents, XFS_EXTFMT_INODE(ip));
1052 1046 return 0;
1053 1047 }
1054 1048  
1055 1049  
... ... @@ -2887,12 +2881,10 @@
2887 2881 int
2888 2882 xfs_iextents_copy(
2889 2883 xfs_inode_t *ip,
2890   - xfs_bmbt_rec_t *buffer,
  2884 + xfs_bmbt_rec_t *dp,
2891 2885 int whichfork)
2892 2886 {
2893 2887 int copied;
2894   - xfs_bmbt_rec_t *dest_ep;
2895   - xfs_bmbt_rec_t *ep;
2896 2888 int i;
2897 2889 xfs_ifork_t *ifp;
2898 2890 int nrecs;
2899 2891  
... ... @@ -2912,10 +2904,9 @@
2912 2904 * the delayed ones. There must be at least one
2913 2905 * non-delayed extent.
2914 2906 */
2915   - dest_ep = buffer;
2916 2907 copied = 0;
2917 2908 for (i = 0; i < nrecs; i++) {
2918   - ep = xfs_iext_get_ext(ifp, i);
  2909 + xfs_bmbt_rec_host_t *ep = xfs_iext_get_ext(ifp, i);
2919 2910 start_block = xfs_bmbt_get_startblock(ep);
2920 2911 if (ISNULLSTARTBLOCK(start_block)) {
2921 2912 /*
2922 2913  
2923 2914  
... ... @@ -2926,14 +2917,14 @@
2926 2917  
2927 2918 /* Translate to on disk format */
2928 2919 put_unaligned(INT_GET(ep->l0, ARCH_CONVERT),
2929   - (__uint64_t*)&dest_ep->l0);
  2920 + (__uint64_t*)&dp->l0);
2930 2921 put_unaligned(INT_GET(ep->l1, ARCH_CONVERT),
2931   - (__uint64_t*)&dest_ep->l1);
2932   - dest_ep++;
  2922 + (__uint64_t*)&dp->l1);
  2923 + dp++;
2933 2924 copied++;
2934 2925 }
2935 2926 ASSERT(copied != 0);
2936   - xfs_validate_extents(ifp, copied, 1, XFS_EXTFMT_INODE(ip));
  2927 + xfs_validate_extents(ifp, copied, XFS_EXTFMT_INODE(ip));
2937 2928  
2938 2929 return (copied * (uint)sizeof(xfs_bmbt_rec_t));
2939 2930 }
... ... @@ -3711,7 +3702,7 @@
3711 3702 /*
3712 3703 * Return a pointer to the extent record at file index idx.
3713 3704 */
3714   -xfs_bmbt_rec_t *
  3705 +xfs_bmbt_rec_host_t *
3715 3706 xfs_iext_get_ext(
3716 3707 xfs_ifork_t *ifp, /* inode fork pointer */
3717 3708 xfs_extnum_t idx) /* index of target extent */
3718 3709  
... ... @@ -3744,15 +3735,12 @@
3744 3735 xfs_extnum_t count, /* number of inserted items */
3745 3736 xfs_bmbt_irec_t *new) /* items to insert */
3746 3737 {
3747   - xfs_bmbt_rec_t *ep; /* extent record pointer */
3748 3738 xfs_extnum_t i; /* extent record index */
3749 3739  
3750 3740 ASSERT(ifp->if_flags & XFS_IFEXTENTS);
3751 3741 xfs_iext_add(ifp, idx, count);
3752   - for (i = idx; i < idx + count; i++, new++) {
3753   - ep = xfs_iext_get_ext(ifp, i);
3754   - xfs_bmbt_set_all(ep, new);
3755   - }
  3742 + for (i = idx; i < idx + count; i++, new++)
  3743 + xfs_bmbt_set_all(xfs_iext_get_ext(ifp, i), new);
3756 3744 }
3757 3745  
3758 3746 /*
... ... @@ -4203,7 +4191,7 @@
4203 4191 rnew_size = xfs_iroundup(new_size);
4204 4192 }
4205 4193 if (rnew_size != ifp->if_real_bytes) {
4206   - ifp->if_u1.if_extents = (xfs_bmbt_rec_t *)
  4194 + ifp->if_u1.if_extents =
4207 4195 kmem_realloc(ifp->if_u1.if_extents,
4208 4196 rnew_size,
4209 4197 ifp->if_real_bytes,
... ... @@ -4266,8 +4254,7 @@
4266 4254 xfs_ifork_t *ifp, /* inode fork pointer */
4267 4255 int new_size) /* number of extents in file */
4268 4256 {
4269   - ifp->if_u1.if_extents = (xfs_bmbt_rec_t *)
4270   - kmem_alloc(new_size, KM_SLEEP);
  4257 + ifp->if_u1.if_extents = kmem_alloc(new_size, KM_SLEEP);
4271 4258 memset(ifp->if_u1.if_extents, 0, new_size);
4272 4259 if (ifp->if_bytes) {
4273 4260 memcpy(ifp->if_u1.if_extents, ifp->if_u2.if_inline_ext,
... ... @@ -4310,7 +4297,7 @@
4310 4297 xfs_iext_indirect_to_direct(
4311 4298 xfs_ifork_t *ifp) /* inode fork pointer */
4312 4299 {
4313   - xfs_bmbt_rec_t *ep; /* extent record pointer */
  4300 + xfs_bmbt_rec_host_t *ep; /* extent record pointer */
4314 4301 xfs_extnum_t nextents; /* number of extents in file */
4315 4302 int size; /* size of file extents */
4316 4303  
4317 4304  
4318 4305  
... ... @@ -4362,15 +4349,15 @@
4362 4349 /*
4363 4350 * Return a pointer to the extent record for file system block bno.
4364 4351 */
4365   -xfs_bmbt_rec_t * /* pointer to found extent record */
  4352 +xfs_bmbt_rec_host_t * /* pointer to found extent record */
4366 4353 xfs_iext_bno_to_ext(
4367 4354 xfs_ifork_t *ifp, /* inode fork pointer */
4368 4355 xfs_fileoff_t bno, /* block number to search for */
4369 4356 xfs_extnum_t *idxp) /* index of target extent */
4370 4357 {
4371   - xfs_bmbt_rec_t *base; /* pointer to first extent */
  4358 + xfs_bmbt_rec_host_t *base; /* pointer to first extent */
4372 4359 xfs_filblks_t blockcount = 0; /* number of blocks in extent */
4373   - xfs_bmbt_rec_t *ep = NULL; /* pointer to target extent */
  4360 + xfs_bmbt_rec_host_t *ep = NULL; /* pointer to target extent */
4374 4361 xfs_ext_irec_t *erp = NULL; /* indirection array pointer */
4375 4362 int high; /* upper boundary in search */
4376 4363 xfs_extnum_t idx = 0; /* index of target extent */
... ... @@ -4545,8 +4532,7 @@
4545 4532 kmem_alloc(sizeof(xfs_ext_irec_t), KM_SLEEP);
4546 4533  
4547 4534 if (nextents == 0) {
4548   - ifp->if_u1.if_extents = (xfs_bmbt_rec_t *)
4549   - kmem_alloc(XFS_IEXT_BUFSZ, KM_SLEEP);
  4535 + ifp->if_u1.if_extents = kmem_alloc(XFS_IEXT_BUFSZ, KM_SLEEP);
4550 4536 } else if (!ifp->if_real_bytes) {
4551 4537 xfs_iext_inline_to_direct(ifp, XFS_IEXT_BUFSZ);
4552 4538 } else if (ifp->if_real_bytes < XFS_IEXT_BUFSZ) {
... ... @@ -4594,8 +4580,7 @@
4594 4580  
4595 4581 /* Initialize new extent record */
4596 4582 erp = ifp->if_u1.if_ext_irec;
4597   - erp[erp_idx].er_extbuf = (xfs_bmbt_rec_t *)
4598   - kmem_alloc(XFS_IEXT_BUFSZ, KM_SLEEP);
  4583 + erp[erp_idx].er_extbuf = kmem_alloc(XFS_IEXT_BUFSZ, KM_SLEEP);
4599 4584 ifp->if_real_bytes = nlists * XFS_IEXT_BUFSZ;
4600 4585 memset(erp[erp_idx].er_extbuf, 0, XFS_IEXT_BUFSZ);
4601 4586 erp[erp_idx].er_extcount = 0;
... ... @@ -4727,7 +4712,7 @@
4727 4712 xfs_iext_irec_compact_full(
4728 4713 xfs_ifork_t *ifp) /* inode fork pointer */
4729 4714 {
4730   - xfs_bmbt_rec_t *ep, *ep_next; /* extent record pointers */
  4715 + xfs_bmbt_rec_host_t *ep, *ep_next; /* extent record pointers */
4731 4716 xfs_ext_irec_t *erp, *erp_next; /* extent irec pointers */
4732 4717 int erp_idx = 0; /* extent irec index */
4733 4718 int ext_avail; /* empty entries in ex list */
... ... @@ -44,7 +44,7 @@
44 44 * it is possible that a third level of indirection may be required.
45 45 */
46 46 typedef struct xfs_ext_irec {
47   - xfs_bmbt_rec_t *er_extbuf; /* block of extent records */
  47 + xfs_bmbt_rec_host_t *er_extbuf; /* block of extent records */
48 48 xfs_extnum_t er_extoff; /* extent offset in file */
49 49 xfs_extnum_t er_extcount; /* number of extents in page/block */
50 50 } xfs_ext_irec_t;
51 51  
... ... @@ -65,12 +65,12 @@
65 65 unsigned char if_ext_max; /* max # of extent records */
66 66 xfs_extnum_t if_lastex; /* last if_extents used */
67 67 union {
68   - xfs_bmbt_rec_t *if_extents; /* linear map file exts */
  68 + xfs_bmbt_rec_host_t *if_extents;/* linear map file exts */
69 69 xfs_ext_irec_t *if_ext_irec; /* irec map file exts */
70 70 char *if_data; /* inline file data */
71 71 } if_u1;
72 72 union {
73   - xfs_bmbt_rec_t if_inline_ext[XFS_INLINE_EXTS];
  73 + xfs_bmbt_rec_host_t if_inline_ext[XFS_INLINE_EXTS];
74 74 /* very small file extents */
75 75 char if_inline_data[XFS_INLINE_DATA];
76 76 /* very small file data */
... ... @@ -549,7 +549,7 @@
549 549  
550 550 void xfs_synchronize_atime(xfs_inode_t *);
551 551  
552   -xfs_bmbt_rec_t *xfs_iext_get_ext(xfs_ifork_t *, xfs_extnum_t);
  552 +xfs_bmbt_rec_host_t *xfs_iext_get_ext(xfs_ifork_t *, xfs_extnum_t);
553 553 void xfs_iext_insert(xfs_ifork_t *, xfs_extnum_t, xfs_extnum_t,
554 554 xfs_bmbt_irec_t *);
555 555 void xfs_iext_add(xfs_ifork_t *, xfs_extnum_t, int);
... ... @@ -564,7 +564,7 @@
564 564 void xfs_iext_direct_to_inline(xfs_ifork_t *, xfs_extnum_t);
565 565 void xfs_iext_inline_to_direct(xfs_ifork_t *, int);
566 566 void xfs_iext_destroy(xfs_ifork_t *);
567   -xfs_bmbt_rec_t *xfs_iext_bno_to_ext(xfs_ifork_t *, xfs_fileoff_t, int *);
  567 +xfs_bmbt_rec_host_t *xfs_iext_bno_to_ext(xfs_ifork_t *, xfs_fileoff_t, int *);
568 568 xfs_ext_irec_t *xfs_iext_bno_to_irec(xfs_ifork_t *, xfs_fileoff_t, int *);
569 569 xfs_ext_irec_t *xfs_iext_idx_to_irec(xfs_ifork_t *, xfs_extnum_t *, int *, int);
570 570 void xfs_iext_irec_init(xfs_ifork_t *);