4322 }
4323 *idxp = page_idx;
4324 *erp_idxp = erp_idx;
4325 return(erp);
4326}
4327
4328
4329
4330
4331
4332void
4333xfs_iext_irec_init(
4334 xfs_ifork_t *ifp)
4335{
4336 xfs_ext_irec_t *erp;
4337 xfs_extnum_t nextents;
4338
4339 ASSERT(!(ifp->if_flags & XFS_IFEXTIREC));
4340 nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
4341 ASSERT(nextents <= XFS_LINEAR_EXTS);
4342
4343 erp = kmem_alloc(sizeof(xfs_ext_irec_t), KM_NOFS);
4344
4345 if (nextents == 0) {
4346 ifp->if_u1.if_extents = kmem_alloc(XFS_IEXT_BUFSZ, KM_NOFS);
4347 } else if (!ifp->if_real_bytes) {
4348 xfs_iext_inline_to_direct(ifp, XFS_IEXT_BUFSZ);
4349 } else if (ifp->if_real_bytes < XFS_IEXT_BUFSZ) {
4350 xfs_iext_realloc_direct(ifp, XFS_IEXT_BUFSZ);
4351 }
4352 erp->er_extbuf = ifp->if_u1.if_extents;
4353 erp->er_extcount = nextents;
4354 erp->er_extoff = 0;
4355
4356 ifp->if_flags |= XFS_IFEXTIREC;
4357 ifp->if_real_bytes = XFS_IEXT_BUFSZ;
4358 ifp->if_bytes = nextents * sizeof(xfs_bmbt_rec_t);
4359 ifp->if_u1.if_ext_irec = erp;
4360
4361 return;
4362}