|
|
| version 1.467, 2007/07/09 15:43:09 | version 1.468, 2007/08/02 16:04:40 |
|---|---|
| Line 67 STATIC int xfs_iformat_local(xfs_inode_t | Line 67 STATIC int xfs_iformat_local(xfs_inode_t |
| STATIC int xfs_iformat_extents(xfs_inode_t *, xfs_dinode_t *, int); | STATIC int xfs_iformat_extents(xfs_inode_t *, xfs_dinode_t *, int); |
| STATIC int xfs_iformat_btree(xfs_inode_t *, xfs_dinode_t *, int); | STATIC int xfs_iformat_btree(xfs_inode_t *, xfs_dinode_t *, int); |
| #ifdef DEBUG | #ifdef DEBUG |
| /* | /* |
| * Make sure that the extents in the given memory buffer | * Make sure that the extents in the given memory buffer |
| Line 77 STATIC void | Line 76 STATIC void |
| xfs_validate_extents( | xfs_validate_extents( |
| xfs_ifork_t *ifp, | xfs_ifork_t *ifp, |
| int nrecs, | int nrecs, |
| int disk, | |
| xfs_exntfmt_t fmt) | xfs_exntfmt_t fmt) |
| { | { |
| xfs_bmbt_rec_t *ep; | |
| xfs_bmbt_irec_t irec; | xfs_bmbt_irec_t irec; |
| xfs_bmbt_rec_t rec; | xfs_bmbt_rec_host_t rec; |
| int i; | int i; |
| for (i = 0; i < nrecs; i++) { | for (i = 0; i < nrecs; i++) { |
| ep = xfs_iext_get_ext(ifp, i); | xfs_bmbt_rec_host_t *ep = xfs_iext_get_ext(ifp, i); |
| rec.l0 = get_unaligned((__uint64_t*)&ep->l0); | rec.l0 = get_unaligned(&ep->l0); |
| rec.l1 = get_unaligned((__uint64_t*)&ep->l1); | rec.l1 = get_unaligned(&ep->l1); |
| if (disk) | xfs_bmbt_get_all(&rec, &irec); |
| xfs_bmbt_disk_get_all(&rec, &irec); | |
| else | |
| xfs_bmbt_get_all(&rec, &irec); | |
| if (fmt == XFS_EXTFMT_NOSTATE) | if (fmt == XFS_EXTFMT_NOSTATE) |
| ASSERT(irec.br_state == XFS_EXT_NORM); | ASSERT(irec.br_state == XFS_EXT_NORM); |
| } | } |
| } | } |
| #else /* DEBUG */ | #else /* DEBUG */ |
| #define xfs_validate_extents(ifp, nrecs, disk, fmt) | #define xfs_validate_extents(ifp, nrecs, fmt) |
| #endif /* DEBUG */ | #endif /* DEBUG */ |
| /* | /* |
| Line 602 xfs_iformat_extents( | Line 596 xfs_iformat_extents( |
| xfs_dinode_t *dip, | xfs_dinode_t *dip, |
| int whichfork) | int whichfork) |
| { | { |
| xfs_bmbt_rec_t *ep, *dp; | xfs_bmbt_rec_t *dp; |
| xfs_ifork_t *ifp; | xfs_ifork_t *ifp; |
| int nex; | int nex; |
| int size; | int size; |
| Line 637 xfs_iformat_extents( | Line 631 xfs_iformat_extents( |
| ifp->if_bytes = size; | ifp->if_bytes = size; |
| if (size) { | if (size) { |
| dp = (xfs_bmbt_rec_t *) XFS_DFORK_PTR(dip, whichfork); | dp = (xfs_bmbt_rec_t *) XFS_DFORK_PTR(dip, whichfork); |
| xfs_validate_extents(ifp, nex, 1, XFS_EXTFMT_INODE(ip)); | xfs_validate_extents(ifp, nex, XFS_EXTFMT_INODE(ip)); |
| for (i = 0; i < nex; i++, dp++) { | for (i = 0; i < nex; i++, dp++) { |
| ep = xfs_iext_get_ext(ifp, i); | xfs_bmbt_rec_host_t *ep = xfs_iext_get_ext(ifp, i); |
| ep->l0 = INT_GET(get_unaligned((__uint64_t*)&dp->l0), | ep->l0 = INT_GET(get_unaligned((__uint64_t*)&dp->l0), |
| ARCH_CONVERT); | ARCH_CONVERT); |
| ep->l1 = INT_GET(get_unaligned((__uint64_t*)&dp->l1), | ep->l1 = INT_GET(get_unaligned((__uint64_t*)&dp->l1), |
| Line 1048 xfs_iread_extents( | Line 1042 xfs_iread_extents( |
| ifp->if_flags &= ~XFS_IFEXTENTS; | ifp->if_flags &= ~XFS_IFEXTENTS; |
| return error; | return error; |
| } | } |
| xfs_validate_extents(ifp, nextents, 0, XFS_EXTFMT_INODE(ip)); | xfs_validate_extents(ifp, nextents, XFS_EXTFMT_INODE(ip)); |
| return 0; | return 0; |
| } | } |
| Line 2887 xfs_iunpin_wait( | Line 2881 xfs_iunpin_wait( |
| int | int |
| xfs_iextents_copy( | xfs_iextents_copy( |
| xfs_inode_t *ip, | xfs_inode_t *ip, |
| xfs_bmbt_rec_t *buffer, | xfs_bmbt_rec_t *dp, |
| int whichfork) | int whichfork) |
| { | { |
| int copied; | int copied; |
| xfs_bmbt_rec_t *dest_ep; | |
| xfs_bmbt_rec_t *ep; | |
| int i; | int i; |
| xfs_ifork_t *ifp; | xfs_ifork_t *ifp; |
| int nrecs; | int nrecs; |
| Line 2912 xfs_iextents_copy( | Line 2904 xfs_iextents_copy( |
| * the delayed ones. There must be at least one | * the delayed ones. There must be at least one |
| * non-delayed extent. | * non-delayed extent. |
| */ | */ |
| dest_ep = buffer; | |
| copied = 0; | copied = 0; |
| for (i = 0; i < nrecs; i++) { | for (i = 0; i < nrecs; i++) { |
| ep = xfs_iext_get_ext(ifp, i); | xfs_bmbt_rec_host_t *ep = xfs_iext_get_ext(ifp, i); |
| start_block = xfs_bmbt_get_startblock(ep); | start_block = xfs_bmbt_get_startblock(ep); |
| if (ISNULLSTARTBLOCK(start_block)) { | if (ISNULLSTARTBLOCK(start_block)) { |
| /* | /* |
| Line 2926 xfs_iextents_copy( | Line 2917 xfs_iextents_copy( |
| /* Translate to on disk format */ | /* Translate to on disk format */ |
| put_unaligned(INT_GET(ep->l0, ARCH_CONVERT), | put_unaligned(INT_GET(ep->l0, ARCH_CONVERT), |
| (__uint64_t*)&dest_ep->l0); | (__uint64_t*)&dp->l0); |
| put_unaligned(INT_GET(ep->l1, ARCH_CONVERT), | put_unaligned(INT_GET(ep->l1, ARCH_CONVERT), |
| (__uint64_t*)&dest_ep->l1); | (__uint64_t*)&dp->l1); |
| dest_ep++; | dp++; |
| copied++; | copied++; |
| } | } |
| ASSERT(copied != 0); | ASSERT(copied != 0); |
| xfs_validate_extents(ifp, copied, 1, XFS_EXTFMT_INODE(ip)); | xfs_validate_extents(ifp, copied, XFS_EXTFMT_INODE(ip)); |
| return (copied * (uint)sizeof(xfs_bmbt_rec_t)); | return (copied * (uint)sizeof(xfs_bmbt_rec_t)); |
| } | } |
| Line 3711 xfs_ilock_trace(xfs_inode_t *ip, int loc | Line 3702 xfs_ilock_trace(xfs_inode_t *ip, int loc |
| /* | /* |
| * Return a pointer to the extent record at file index idx. | * Return a pointer to the extent record at file index idx. |
| */ | */ |
| xfs_bmbt_rec_t * | xfs_bmbt_rec_host_t * |
| xfs_iext_get_ext( | xfs_iext_get_ext( |
| xfs_ifork_t *ifp, /* inode fork pointer */ | xfs_ifork_t *ifp, /* inode fork pointer */ |
| xfs_extnum_t idx) /* index of target extent */ | xfs_extnum_t idx) /* index of target extent */ |
| Line 3744 xfs_iext_insert( | Line 3735 xfs_iext_insert( |
| xfs_extnum_t count, /* number of inserted items */ | xfs_extnum_t count, /* number of inserted items */ |
| xfs_bmbt_irec_t *new) /* items to insert */ | xfs_bmbt_irec_t *new) /* items to insert */ |
| { | { |
| xfs_bmbt_rec_t *ep; /* extent record pointer */ | |
| xfs_extnum_t i; /* extent record index */ | xfs_extnum_t i; /* extent record index */ |
| ASSERT(ifp->if_flags & XFS_IFEXTENTS); | ASSERT(ifp->if_flags & XFS_IFEXTENTS); |
| xfs_iext_add(ifp, idx, count); | xfs_iext_add(ifp, idx, count); |
| for (i = idx; i < idx + count; i++, new++) { | for (i = idx; i < idx + count; i++, new++) |
| ep = xfs_iext_get_ext(ifp, i); | xfs_bmbt_set_all(xfs_iext_get_ext(ifp, i), new); |
| xfs_bmbt_set_all(ep, new); | |
| } | |
| } | } |
| /* | /* |
| Line 4203 xfs_iext_realloc_direct( | Line 4191 xfs_iext_realloc_direct( |
| rnew_size = xfs_iroundup(new_size); | rnew_size = xfs_iroundup(new_size); |
| } | } |
| if (rnew_size != ifp->if_real_bytes) { | if (rnew_size != ifp->if_real_bytes) { |
| ifp->if_u1.if_extents = (xfs_bmbt_rec_t *) | ifp->if_u1.if_extents = |
| kmem_realloc(ifp->if_u1.if_extents, | kmem_realloc(ifp->if_u1.if_extents, |
| rnew_size, | rnew_size, |
| ifp->if_real_bytes, | ifp->if_real_bytes, |
| Line 4266 xfs_iext_inline_to_direct( | Line 4254 xfs_iext_inline_to_direct( |
| xfs_ifork_t *ifp, /* inode fork pointer */ | xfs_ifork_t *ifp, /* inode fork pointer */ |
| int new_size) /* number of extents in file */ | int new_size) /* number of extents in file */ |
| { | { |
| ifp->if_u1.if_extents = (xfs_bmbt_rec_t *) | ifp->if_u1.if_extents = kmem_alloc(new_size, KM_SLEEP); |
| kmem_alloc(new_size, KM_SLEEP); | |
| memset(ifp->if_u1.if_extents, 0, new_size); | memset(ifp->if_u1.if_extents, 0, new_size); |
| if (ifp->if_bytes) { | if (ifp->if_bytes) { |
| memcpy(ifp->if_u1.if_extents, ifp->if_u2.if_inline_ext, | memcpy(ifp->if_u1.if_extents, ifp->if_u2.if_inline_ext, |
| Line 4310 void | Line 4297 void |
| xfs_iext_indirect_to_direct( | xfs_iext_indirect_to_direct( |
| xfs_ifork_t *ifp) /* inode fork pointer */ | xfs_ifork_t *ifp) /* inode fork pointer */ |
| { | { |
| xfs_bmbt_rec_t *ep; /* extent record pointer */ | xfs_bmbt_rec_host_t *ep; /* extent record pointer */ |
| xfs_extnum_t nextents; /* number of extents in file */ | xfs_extnum_t nextents; /* number of extents in file */ |
| int size; /* size of file extents */ | int size; /* size of file extents */ |
| Line 4362 xfs_iext_destroy( | Line 4349 xfs_iext_destroy( |
| /* | /* |
| * Return a pointer to the extent record for file system block bno. | * Return a pointer to the extent record for file system block bno. |
| */ | */ |
| xfs_bmbt_rec_t * /* pointer to found extent record */ | xfs_bmbt_rec_host_t * /* pointer to found extent record */ |
| xfs_iext_bno_to_ext( | xfs_iext_bno_to_ext( |
| xfs_ifork_t *ifp, /* inode fork pointer */ | xfs_ifork_t *ifp, /* inode fork pointer */ |
| xfs_fileoff_t bno, /* block number to search for */ | xfs_fileoff_t bno, /* block number to search for */ |
| xfs_extnum_t *idxp) /* index of target extent */ | xfs_extnum_t *idxp) /* index of target extent */ |
| { | { |
| xfs_bmbt_rec_t *base; /* pointer to first extent */ | xfs_bmbt_rec_host_t *base; /* pointer to first extent */ |
| xfs_filblks_t blockcount = 0; /* number of blocks in extent */ | xfs_filblks_t blockcount = 0; /* number of blocks in extent */ |
| xfs_bmbt_rec_t *ep = NULL; /* pointer to target extent */ | xfs_bmbt_rec_host_t *ep = NULL; /* pointer to target extent */ |
| xfs_ext_irec_t *erp = NULL; /* indirection array pointer */ | xfs_ext_irec_t *erp = NULL; /* indirection array pointer */ |
| int high; /* upper boundary in search */ | int high; /* upper boundary in search */ |
| xfs_extnum_t idx = 0; /* index of target extent */ | xfs_extnum_t idx = 0; /* index of target extent */ |
| Line 4545 xfs_iext_irec_init( | Line 4532 xfs_iext_irec_init( |
| kmem_alloc(sizeof(xfs_ext_irec_t), KM_SLEEP); | kmem_alloc(sizeof(xfs_ext_irec_t), KM_SLEEP); |
| if (nextents == 0) { | if (nextents == 0) { |
| ifp->if_u1.if_extents = (xfs_bmbt_rec_t *) | ifp->if_u1.if_extents = kmem_alloc(XFS_IEXT_BUFSZ, KM_SLEEP); |
| kmem_alloc(XFS_IEXT_BUFSZ, KM_SLEEP); | |
| } else if (!ifp->if_real_bytes) { | } else if (!ifp->if_real_bytes) { |
| xfs_iext_inline_to_direct(ifp, XFS_IEXT_BUFSZ); | xfs_iext_inline_to_direct(ifp, XFS_IEXT_BUFSZ); |
| } else if (ifp->if_real_bytes < XFS_IEXT_BUFSZ) { | } else if (ifp->if_real_bytes < XFS_IEXT_BUFSZ) { |
| Line 4594 xfs_iext_irec_new( | Line 4580 xfs_iext_irec_new( |
| /* Initialize new extent record */ | /* Initialize new extent record */ |
| erp = ifp->if_u1.if_ext_irec; | erp = ifp->if_u1.if_ext_irec; |
| erp[erp_idx].er_extbuf = (xfs_bmbt_rec_t *) | erp[erp_idx].er_extbuf = kmem_alloc(XFS_IEXT_BUFSZ, KM_SLEEP); |
| kmem_alloc(XFS_IEXT_BUFSZ, KM_SLEEP); | |
| ifp->if_real_bytes = nlists * XFS_IEXT_BUFSZ; | ifp->if_real_bytes = nlists * XFS_IEXT_BUFSZ; |
| memset(erp[erp_idx].er_extbuf, 0, XFS_IEXT_BUFSZ); | memset(erp[erp_idx].er_extbuf, 0, XFS_IEXT_BUFSZ); |
| erp[erp_idx].er_extcount = 0; | erp[erp_idx].er_extcount = 0; |
| Line 4727 void | Line 4712 void |
| xfs_iext_irec_compact_full( | xfs_iext_irec_compact_full( |
| xfs_ifork_t *ifp) /* inode fork pointer */ | xfs_ifork_t *ifp) /* inode fork pointer */ |
| { | { |
| xfs_bmbt_rec_t *ep, *ep_next; /* extent record pointers */ | xfs_bmbt_rec_host_t *ep, *ep_next; /* extent record pointers */ |
| xfs_ext_irec_t *erp, *erp_next; /* extent irec pointers */ | xfs_ext_irec_t *erp, *erp_next; /* extent irec pointers */ |
| int erp_idx = 0; /* extent irec index */ | int erp_idx = 0; /* extent irec index */ |
| int ext_avail; /* empty entries in ex list */ | int ext_avail; /* empty entries in ex list */ |