diff options
author | Christoph Hellwig <hch@infradead.org> | 2007-08-16 02:23:40 -0400 |
---|---|---|
committer | Tim Shimmin <tes@chook.melbourne.sgi.com> | 2007-10-15 02:25:51 -0400 |
commit | a6f64d4aea0d0c8483e910c7dd2d1ee48e42245c (patch) | |
tree | f3fb20bb6d816f6d674bd4c8bfa687b013443eaf /fs/xfs/xfs_inode.c | |
parent | d580ef6eaae6eaaef1e06c7d689fc9949faee9da (diff) |
[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>
Diffstat (limited to 'fs/xfs/xfs_inode.c')
-rw-r--r-- | fs/xfs/xfs_inode.c | 71 |
1 files changed, 28 insertions, 43 deletions
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index cdc4c28926d0..ef8c31a14c92 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c | |||
@@ -67,7 +67,6 @@ STATIC int xfs_iformat_local(xfs_inode_t *, xfs_dinode_t *, int, int); | |||
67 | STATIC int xfs_iformat_extents(xfs_inode_t *, xfs_dinode_t *, int); | 67 | STATIC int xfs_iformat_extents(xfs_inode_t *, xfs_dinode_t *, int); |
68 | STATIC int xfs_iformat_btree(xfs_inode_t *, xfs_dinode_t *, int); | 68 | STATIC int xfs_iformat_btree(xfs_inode_t *, xfs_dinode_t *, int); |
69 | 69 | ||
70 | |||
71 | #ifdef DEBUG | 70 | #ifdef DEBUG |
72 | /* | 71 | /* |
73 | * Make sure that the extents in the given memory buffer | 72 | * Make sure that the extents in the given memory buffer |
@@ -77,28 +76,23 @@ STATIC void | |||
77 | xfs_validate_extents( | 76 | xfs_validate_extents( |
78 | xfs_ifork_t *ifp, | 77 | xfs_ifork_t *ifp, |
79 | int nrecs, | 78 | int nrecs, |
80 | int disk, | ||
81 | xfs_exntfmt_t fmt) | 79 | xfs_exntfmt_t fmt) |
82 | { | 80 | { |
83 | xfs_bmbt_rec_t *ep; | ||
84 | xfs_bmbt_irec_t irec; | 81 | xfs_bmbt_irec_t irec; |
85 | xfs_bmbt_rec_t rec; | 82 | xfs_bmbt_rec_host_t rec; |
86 | int i; | 83 | int i; |
87 | 84 | ||
88 | for (i = 0; i < nrecs; i++) { | 85 | for (i = 0; i < nrecs; i++) { |
89 | ep = xfs_iext_get_ext(ifp, i); | 86 | xfs_bmbt_rec_host_t *ep = xfs_iext_get_ext(ifp, i); |
90 | rec.l0 = get_unaligned((__uint64_t*)&ep->l0); | 87 | rec.l0 = get_unaligned(&ep->l0); |
91 | rec.l1 = get_unaligned((__uint64_t*)&ep->l1); | 88 | rec.l1 = get_unaligned(&ep->l1); |
92 | if (disk) | 89 | xfs_bmbt_get_all(&rec, &irec); |
93 | xfs_bmbt_disk_get_all(&rec, &irec); | ||
94 | else | ||
95 | xfs_bmbt_get_all(&rec, &irec); | ||
96 | if (fmt == XFS_EXTFMT_NOSTATE) | 90 | if (fmt == XFS_EXTFMT_NOSTATE) |
97 | ASSERT(irec.br_state == XFS_EXT_NORM); | 91 | ASSERT(irec.br_state == XFS_EXT_NORM); |
98 | } | 92 | } |
99 | } | 93 | } |
100 | #else /* DEBUG */ | 94 | #else /* DEBUG */ |
101 | #define xfs_validate_extents(ifp, nrecs, disk, fmt) | 95 | #define xfs_validate_extents(ifp, nrecs, fmt) |
102 | #endif /* DEBUG */ | 96 | #endif /* DEBUG */ |
103 | 97 | ||
104 | /* | 98 | /* |
@@ -602,7 +596,7 @@ xfs_iformat_extents( | |||
602 | xfs_dinode_t *dip, | 596 | xfs_dinode_t *dip, |
603 | int whichfork) | 597 | int whichfork) |
604 | { | 598 | { |
605 | xfs_bmbt_rec_t *ep, *dp; | 599 | xfs_bmbt_rec_t *dp; |
606 | xfs_ifork_t *ifp; | 600 | xfs_ifork_t *ifp; |
607 | int nex; | 601 | int nex; |
608 | int size; | 602 | int size; |
@@ -637,9 +631,9 @@ xfs_iformat_extents( | |||
637 | ifp->if_bytes = size; | 631 | ifp->if_bytes = size; |
638 | if (size) { | 632 | if (size) { |
639 | dp = (xfs_bmbt_rec_t *) XFS_DFORK_PTR(dip, whichfork); | 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 | for (i = 0; i < nex; i++, dp++) { | 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 | ep->l0 = INT_GET(get_unaligned((__uint64_t*)&dp->l0), | 637 | ep->l0 = INT_GET(get_unaligned((__uint64_t*)&dp->l0), |
644 | ARCH_CONVERT); | 638 | ARCH_CONVERT); |
645 | ep->l1 = INT_GET(get_unaligned((__uint64_t*)&dp->l1), | 639 | ep->l1 = INT_GET(get_unaligned((__uint64_t*)&dp->l1), |
@@ -1048,7 +1042,7 @@ xfs_iread_extents( | |||
1048 | ifp->if_flags &= ~XFS_IFEXTENTS; | 1042 | ifp->if_flags &= ~XFS_IFEXTENTS; |
1049 | return error; | 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 | return 0; | 1046 | return 0; |
1053 | } | 1047 | } |
1054 | 1048 | ||
@@ -2887,12 +2881,10 @@ xfs_iunpin_wait( | |||
2887 | int | 2881 | int |
2888 | xfs_iextents_copy( | 2882 | xfs_iextents_copy( |
2889 | xfs_inode_t *ip, | 2883 | xfs_inode_t *ip, |
2890 | xfs_bmbt_rec_t *buffer, | 2884 | xfs_bmbt_rec_t *dp, |
2891 | int whichfork) | 2885 | int whichfork) |
2892 | { | 2886 | { |
2893 | int copied; | 2887 | int copied; |
2894 | xfs_bmbt_rec_t *dest_ep; | ||
2895 | xfs_bmbt_rec_t *ep; | ||
2896 | int i; | 2888 | int i; |
2897 | xfs_ifork_t *ifp; | 2889 | xfs_ifork_t *ifp; |
2898 | int nrecs; | 2890 | int nrecs; |
@@ -2912,10 +2904,9 @@ xfs_iextents_copy( | |||
2912 | * the delayed ones. There must be at least one | 2904 | * the delayed ones. There must be at least one |
2913 | * non-delayed extent. | 2905 | * non-delayed extent. |
2914 | */ | 2906 | */ |
2915 | dest_ep = buffer; | ||
2916 | copied = 0; | 2907 | copied = 0; |
2917 | for (i = 0; i < nrecs; i++) { | 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 | start_block = xfs_bmbt_get_startblock(ep); | 2910 | start_block = xfs_bmbt_get_startblock(ep); |
2920 | if (ISNULLSTARTBLOCK(start_block)) { | 2911 | if (ISNULLSTARTBLOCK(start_block)) { |
2921 | /* | 2912 | /* |
@@ -2926,14 +2917,14 @@ xfs_iextents_copy( | |||
2926 | 2917 | ||
2927 | /* Translate to on disk format */ | 2918 | /* Translate to on disk format */ |
2928 | put_unaligned(INT_GET(ep->l0, ARCH_CONVERT), | 2919 | put_unaligned(INT_GET(ep->l0, ARCH_CONVERT), |
2929 | (__uint64_t*)&dest_ep->l0); | 2920 | (__uint64_t*)&dp->l0); |
2930 | put_unaligned(INT_GET(ep->l1, ARCH_CONVERT), | 2921 | put_unaligned(INT_GET(ep->l1, ARCH_CONVERT), |
2931 | (__uint64_t*)&dest_ep->l1); | 2922 | (__uint64_t*)&dp->l1); |
2932 | dest_ep++; | 2923 | dp++; |
2933 | copied++; | 2924 | copied++; |
2934 | } | 2925 | } |
2935 | ASSERT(copied != 0); | 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 | return (copied * (uint)sizeof(xfs_bmbt_rec_t)); | 2929 | return (copied * (uint)sizeof(xfs_bmbt_rec_t)); |
2939 | } | 2930 | } |
@@ -3711,7 +3702,7 @@ xfs_ilock_trace(xfs_inode_t *ip, int lock, unsigned int lockflags, inst_t *ra) | |||
3711 | /* | 3702 | /* |
3712 | * Return a pointer to the extent record at file index idx. | 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 | xfs_iext_get_ext( | 3706 | xfs_iext_get_ext( |
3716 | xfs_ifork_t *ifp, /* inode fork pointer */ | 3707 | xfs_ifork_t *ifp, /* inode fork pointer */ |
3717 | xfs_extnum_t idx) /* index of target extent */ | 3708 | xfs_extnum_t idx) /* index of target extent */ |
@@ -3744,15 +3735,12 @@ xfs_iext_insert( | |||
3744 | xfs_extnum_t count, /* number of inserted items */ | 3735 | xfs_extnum_t count, /* number of inserted items */ |
3745 | xfs_bmbt_irec_t *new) /* items to insert */ | 3736 | xfs_bmbt_irec_t *new) /* items to insert */ |
3746 | { | 3737 | { |
3747 | xfs_bmbt_rec_t *ep; /* extent record pointer */ | ||
3748 | xfs_extnum_t i; /* extent record index */ | 3738 | xfs_extnum_t i; /* extent record index */ |
3749 | 3739 | ||
3750 | ASSERT(ifp->if_flags & XFS_IFEXTENTS); | 3740 | ASSERT(ifp->if_flags & XFS_IFEXTENTS); |
3751 | xfs_iext_add(ifp, idx, count); | 3741 | xfs_iext_add(ifp, idx, count); |
3752 | for (i = idx; i < idx + count; i++, new++) { | 3742 | for (i = idx; i < idx + count; i++, new++) |
3753 | ep = xfs_iext_get_ext(ifp, i); | 3743 | xfs_bmbt_set_all(xfs_iext_get_ext(ifp, i), new); |
3754 | xfs_bmbt_set_all(ep, new); | ||
3755 | } | ||
3756 | } | 3744 | } |
3757 | 3745 | ||
3758 | /* | 3746 | /* |
@@ -4203,7 +4191,7 @@ xfs_iext_realloc_direct( | |||
4203 | rnew_size = xfs_iroundup(new_size); | 4191 | rnew_size = xfs_iroundup(new_size); |
4204 | } | 4192 | } |
4205 | if (rnew_size != ifp->if_real_bytes) { | 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 | kmem_realloc(ifp->if_u1.if_extents, | 4195 | kmem_realloc(ifp->if_u1.if_extents, |
4208 | rnew_size, | 4196 | rnew_size, |
4209 | ifp->if_real_bytes, | 4197 | ifp->if_real_bytes, |
@@ -4266,8 +4254,7 @@ xfs_iext_inline_to_direct( | |||
4266 | xfs_ifork_t *ifp, /* inode fork pointer */ | 4254 | xfs_ifork_t *ifp, /* inode fork pointer */ |
4267 | int new_size) /* number of extents in file */ | 4255 | int new_size) /* number of extents in file */ |
4268 | { | 4256 | { |
4269 | ifp->if_u1.if_extents = (xfs_bmbt_rec_t *) | 4257 | ifp->if_u1.if_extents = kmem_alloc(new_size, KM_SLEEP); |
4270 | kmem_alloc(new_size, KM_SLEEP); | ||
4271 | memset(ifp->if_u1.if_extents, 0, new_size); | 4258 | memset(ifp->if_u1.if_extents, 0, new_size); |
4272 | if (ifp->if_bytes) { | 4259 | if (ifp->if_bytes) { |
4273 | memcpy(ifp->if_u1.if_extents, ifp->if_u2.if_inline_ext, | 4260 | memcpy(ifp->if_u1.if_extents, ifp->if_u2.if_inline_ext, |
@@ -4310,7 +4297,7 @@ void | |||
4310 | xfs_iext_indirect_to_direct( | 4297 | xfs_iext_indirect_to_direct( |
4311 | xfs_ifork_t *ifp) /* inode fork pointer */ | 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 | xfs_extnum_t nextents; /* number of extents in file */ | 4301 | xfs_extnum_t nextents; /* number of extents in file */ |
4315 | int size; /* size of file extents */ | 4302 | int size; /* size of file extents */ |
4316 | 4303 | ||
@@ -4362,15 +4349,15 @@ xfs_iext_destroy( | |||
4362 | /* | 4349 | /* |
4363 | * Return a pointer to the extent record for file system block bno. | 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 | xfs_iext_bno_to_ext( | 4353 | xfs_iext_bno_to_ext( |
4367 | xfs_ifork_t *ifp, /* inode fork pointer */ | 4354 | xfs_ifork_t *ifp, /* inode fork pointer */ |
4368 | xfs_fileoff_t bno, /* block number to search for */ | 4355 | xfs_fileoff_t bno, /* block number to search for */ |
4369 | xfs_extnum_t *idxp) /* index of target extent */ | 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 | xfs_filblks_t blockcount = 0; /* number of blocks in extent */ | 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 | xfs_ext_irec_t *erp = NULL; /* indirection array pointer */ | 4361 | xfs_ext_irec_t *erp = NULL; /* indirection array pointer */ |
4375 | int high; /* upper boundary in search */ | 4362 | int high; /* upper boundary in search */ |
4376 | xfs_extnum_t idx = 0; /* index of target extent */ | 4363 | xfs_extnum_t idx = 0; /* index of target extent */ |
@@ -4545,8 +4532,7 @@ xfs_iext_irec_init( | |||
4545 | kmem_alloc(sizeof(xfs_ext_irec_t), KM_SLEEP); | 4532 | kmem_alloc(sizeof(xfs_ext_irec_t), KM_SLEEP); |
4546 | 4533 | ||
4547 | if (nextents == 0) { | 4534 | if (nextents == 0) { |
4548 | ifp->if_u1.if_extents = (xfs_bmbt_rec_t *) | 4535 | ifp->if_u1.if_extents = kmem_alloc(XFS_IEXT_BUFSZ, KM_SLEEP); |
4549 | kmem_alloc(XFS_IEXT_BUFSZ, KM_SLEEP); | ||
4550 | } else if (!ifp->if_real_bytes) { | 4536 | } else if (!ifp->if_real_bytes) { |
4551 | xfs_iext_inline_to_direct(ifp, XFS_IEXT_BUFSZ); | 4537 | xfs_iext_inline_to_direct(ifp, XFS_IEXT_BUFSZ); |
4552 | } else if (ifp->if_real_bytes < XFS_IEXT_BUFSZ) { | 4538 | } else if (ifp->if_real_bytes < XFS_IEXT_BUFSZ) { |
@@ -4594,8 +4580,7 @@ xfs_iext_irec_new( | |||
4594 | 4580 | ||
4595 | /* Initialize new extent record */ | 4581 | /* Initialize new extent record */ |
4596 | erp = ifp->if_u1.if_ext_irec; | 4582 | erp = ifp->if_u1.if_ext_irec; |
4597 | erp[erp_idx].er_extbuf = (xfs_bmbt_rec_t *) | 4583 | erp[erp_idx].er_extbuf = kmem_alloc(XFS_IEXT_BUFSZ, KM_SLEEP); |
4598 | kmem_alloc(XFS_IEXT_BUFSZ, KM_SLEEP); | ||
4599 | ifp->if_real_bytes = nlists * XFS_IEXT_BUFSZ; | 4584 | ifp->if_real_bytes = nlists * XFS_IEXT_BUFSZ; |
4600 | memset(erp[erp_idx].er_extbuf, 0, XFS_IEXT_BUFSZ); | 4585 | memset(erp[erp_idx].er_extbuf, 0, XFS_IEXT_BUFSZ); |
4601 | erp[erp_idx].er_extcount = 0; | 4586 | erp[erp_idx].er_extcount = 0; |
@@ -4727,7 +4712,7 @@ void | |||
4727 | xfs_iext_irec_compact_full( | 4712 | xfs_iext_irec_compact_full( |
4728 | xfs_ifork_t *ifp) /* inode fork pointer */ | 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 | xfs_ext_irec_t *erp, *erp_next; /* extent irec pointers */ | 4716 | xfs_ext_irec_t *erp, *erp_next; /* extent irec pointers */ |
4732 | int erp_idx = 0; /* extent irec index */ | 4717 | int erp_idx = 0; /* extent irec index */ |
4733 | int ext_avail; /* empty entries in ex list */ | 4718 | int ext_avail; /* empty entries in ex list */ |