Lines Matching +full:block +full:- +full:offset

1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
34 return ((struct xfs_dir3_data_hdr *)hdr)->best_free; in xfs_dir2_data_bestfree_p()
35 return hdr->bestfree; in xfs_dir2_data_bestfree_p()
47 xfs_dir2_data_entsize(mp, dep->namelen) - sizeof(__be16)); in xfs_dir2_data_entry_tag_p()
56 uint8_t ftype = dep->name[dep->namelen]; in xfs_dir2_data_get_ftype()
72 ASSERT(dep->namelen != 0); in xfs_dir2_data_put_ftype()
75 dep->name[dep->namelen] = ftype; in xfs_dir2_data_put_ftype()
79 * The number of leaf entries is limited by the size of the block and the amount
82 * the block right now.
88 return (geo->blksize - sizeof(struct xfs_dir2_block_tail) - in xfs_dir2_data_max_leaf_entries()
89 geo->data_entry_offset) / in xfs_dir2_data_max_leaf_entries()
94 * Check the consistency of the data block.
95 * The input can also be a block-format directory.
101 struct xfs_buf *bp) /* data block's buffer */ in __xfs_dir3_data_check()
105 xfs_dir2_block_tail_t *btp=NULL; /* block tail */ in __xfs_dir3_data_check()
107 xfs_dir2_data_hdr_t *hdr; /* data block header */ in __xfs_dir3_data_check()
113 xfs_dir2_leaf_entry_t *lep=NULL; /* block leaf entries */ in __xfs_dir3_data_check()
114 struct xfs_mount *mp = bp->b_mount; in __xfs_dir3_data_check()
117 unsigned int offset; in __xfs_dir3_data_check() local
119 struct xfs_da_geometry *geo = mp->m_dir_geo; in __xfs_dir3_data_check()
124 if (dp && !S_ISDIR(VFS_I(dp)->i_mode)) in __xfs_dir3_data_check()
127 hdr = bp->b_addr; in __xfs_dir3_data_check()
128 offset = geo->data_entry_offset; in __xfs_dir3_data_check()
130 switch (hdr->magic) { in __xfs_dir3_data_check()
136 if (be32_to_cpu(btp->count) >= in __xfs_dir3_data_check()
156 if (bf[0].offset) in __xfs_dir3_data_check()
161 if (bf[1].offset) in __xfs_dir3_data_check()
166 if (bf[2].offset) in __xfs_dir3_data_check()
178 while (offset < end) { in __xfs_dir3_data_check()
179 struct xfs_dir2_data_unused *dup = bp->b_addr + offset; in __xfs_dir3_data_check()
180 struct xfs_dir2_data_entry *dep = bp->b_addr + offset; in __xfs_dir3_data_check()
187 if (offset > end - xfs_dir2_data_unusedsize(1)) in __xfs_dir3_data_check()
195 if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { in __xfs_dir3_data_check()
199 be16_to_cpu(dup->length)); in __xfs_dir3_data_check()
202 if (be16_to_cpu(dup->length) != reclen) in __xfs_dir3_data_check()
204 if (offset + reclen > end) in __xfs_dir3_data_check()
207 offset) in __xfs_dir3_data_check()
213 i = (int)(dfp - bf); in __xfs_dir3_data_check()
218 if (be16_to_cpu(dup->length) > in __xfs_dir3_data_check()
222 offset += reclen; in __xfs_dir3_data_check()
229 * large enough for a dirent with a single-byte name? in __xfs_dir3_data_check()
231 if (offset > end - xfs_dir2_data_entsize(mp, 1)) in __xfs_dir3_data_check()
236 * If this is a block directory then make sure it's in __xfs_dir3_data_check()
237 * in the leaf section of the block. in __xfs_dir3_data_check()
240 if (dep->namelen == 0) in __xfs_dir3_data_check()
242 reclen = xfs_dir2_data_entsize(mp, dep->namelen); in __xfs_dir3_data_check()
243 if (offset + reclen > end) in __xfs_dir3_data_check()
245 if (!xfs_verify_dir_ino(mp, be64_to_cpu(dep->inumber))) in __xfs_dir3_data_check()
247 if (be16_to_cpu(*xfs_dir2_data_entry_tag_p(mp, dep)) != offset) in __xfs_dir3_data_check()
253 if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) || in __xfs_dir3_data_check()
254 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) { in __xfs_dir3_data_check()
255 addr = xfs_dir2_db_off_to_dataptr(geo, geo->datablk, in __xfs_dir3_data_check()
257 ((char *)dep - (char *)hdr)); in __xfs_dir3_data_check()
258 name.name = dep->name; in __xfs_dir3_data_check()
259 name.len = dep->namelen; in __xfs_dir3_data_check()
261 for (i = 0; i < be32_to_cpu(btp->count); i++) { in __xfs_dir3_data_check()
266 if (i >= be32_to_cpu(btp->count)) in __xfs_dir3_data_check()
269 offset += reclen; in __xfs_dir3_data_check()
276 if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) || in __xfs_dir3_data_check()
277 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) { in __xfs_dir3_data_check()
278 for (i = stale = 0; i < be32_to_cpu(btp->count); i++) { in __xfs_dir3_data_check()
283 be32_to_cpu(lep[i - 1].hashval)) in __xfs_dir3_data_check()
286 if (count != be32_to_cpu(btp->count) - be32_to_cpu(btp->stale)) in __xfs_dir3_data_check()
288 if (stale != be32_to_cpu(btp->stale)) in __xfs_dir3_data_check()
305 xfs_corruption_error(__func__, XFS_ERRLEVEL_LOW, dp->i_mount, in xfs_dir3_data_check()
306 bp->b_addr, BBTOB(bp->b_length), __FILE__, __LINE__, in xfs_dir3_data_check()
316 struct xfs_mount *mp = bp->b_mount; in xfs_dir3_data_verify()
317 struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr; in xfs_dir3_data_verify()
319 if (!xfs_verify_magic(bp, hdr3->magic)) in xfs_dir3_data_verify()
323 if (!uuid_equal(&hdr3->uuid, &mp->m_sb.sb_meta_uuid)) in xfs_dir3_data_verify()
325 if (be64_to_cpu(hdr3->blkno) != xfs_buf_daddr(bp)) in xfs_dir3_data_verify()
327 if (!xfs_log_check_lsn(mp, be64_to_cpu(hdr3->lsn))) in xfs_dir3_data_verify()
334 * Readahead of the first block of the directory when it is opened is completely
335 * oblivious to the format of the directory. Hence we can either get a block
342 struct xfs_dir2_data_hdr *hdr = bp->b_addr; in xfs_dir3_data_reada_verify()
344 switch (hdr->magic) { in xfs_dir3_data_reada_verify()
347 bp->b_ops = &xfs_dir3_block_buf_ops; in xfs_dir3_data_reada_verify()
348 bp->b_ops->verify_read(bp); in xfs_dir3_data_reada_verify()
352 bp->b_ops = &xfs_dir3_data_buf_ops; in xfs_dir3_data_reada_verify()
353 bp->b_ops->verify_read(bp); in xfs_dir3_data_reada_verify()
356 xfs_verifier_error(bp, -EFSCORRUPTED, __this_address); in xfs_dir3_data_reada_verify()
365 struct xfs_mount *mp = bp->b_mount; in xfs_dir3_data_read_verify()
370 xfs_verifier_error(bp, -EFSBADCRC, __this_address); in xfs_dir3_data_read_verify()
374 xfs_verifier_error(bp, -EFSCORRUPTED, fa); in xfs_dir3_data_read_verify()
382 struct xfs_mount *mp = bp->b_mount; in xfs_dir3_data_write_verify()
383 struct xfs_buf_log_item *bip = bp->b_log_item; in xfs_dir3_data_write_verify()
384 struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr; in xfs_dir3_data_write_verify()
389 xfs_verifier_error(bp, -EFSCORRUPTED, fa); in xfs_dir3_data_write_verify()
397 hdr3->lsn = cpu_to_be64(bip->bli_item.li_lsn); in xfs_dir3_data_write_verify()
424 struct xfs_mount *mp = bp->b_mount; in xfs_dir3_data_header_check()
427 struct xfs_dir3_data_hdr *hdr3 = bp->b_addr; in xfs_dir3_data_header_check()
429 if (hdr3->hdr.magic != cpu_to_be32(XFS_DIR3_DATA_MAGIC)) in xfs_dir3_data_header_check()
432 if (be64_to_cpu(hdr3->hdr.owner) != owner) in xfs_dir3_data_header_check()
463 return -EFSCORRUPTED; in xfs_dir3_data_read()
497 off = (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr); in xfs_dir2_data_freefind_verify()
501 * Check order, non-overlapping entries, and if we find the in xfs_dir2_data_freefind_verify()
505 if (!dfp->offset) { in xfs_dir2_data_freefind_verify()
506 if (dfp->length) in xfs_dir2_data_freefind_verify()
513 if (be16_to_cpu(dfp->offset) == off) { in xfs_dir2_data_freefind_verify()
515 if (dfp->length != dup->length) in xfs_dir2_data_freefind_verify()
517 } else if (be16_to_cpu(dfp->offset) > off) { in xfs_dir2_data_freefind_verify()
518 if (off + be16_to_cpu(dup->length) > in xfs_dir2_data_freefind_verify()
519 be16_to_cpu(dfp->offset)) in xfs_dir2_data_freefind_verify()
522 if (be16_to_cpu(dfp->offset) + in xfs_dir2_data_freefind_verify()
523 be16_to_cpu(dfp->length) > off) in xfs_dir2_data_freefind_verify()
527 be16_to_cpu(dfp->length) < be16_to_cpu(dup->length)) in xfs_dir2_data_freefind_verify()
530 be16_to_cpu(dfp[-1].length) < be16_to_cpu(dfp[0].length)) in xfs_dir2_data_freefind_verify()
540 * Given a data block and an unused entry from that block,
545 struct xfs_dir2_data_hdr *hdr, /* data block header */ in xfs_dir2_data_freefind()
550 xfs_dir2_data_aoff_t off; /* offset value needed */ in xfs_dir2_data_freefind()
552 off = (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr); in xfs_dir2_data_freefind()
558 if (be16_to_cpu(dup->length) < in xfs_dir2_data_freefind()
559 be16_to_cpu(bf[XFS_DIR2_DATA_FD_COUNT - 1].length)) in xfs_dir2_data_freefind()
565 if (!dfp->offset) in xfs_dir2_data_freefind()
567 if (be16_to_cpu(dfp->offset) == off) in xfs_dir2_data_freefind()
577 * Insert an unused-space entry into the bestfree table.
581 struct xfs_dir2_data_hdr *hdr, /* data block pointer */ in xfs_dir2_data_freeinsert()
588 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || in xfs_dir2_data_freeinsert()
589 hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) || in xfs_dir2_data_freeinsert()
590 hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC) || in xfs_dir2_data_freeinsert()
591 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)); in xfs_dir2_data_freeinsert()
593 new.length = dup->length; in xfs_dir2_data_freeinsert()
594 new.offset = cpu_to_be16((char *)dup - (char *)hdr); in xfs_dir2_data_freeinsert()
625 struct xfs_dir2_data_hdr *hdr, /* data block header */ in xfs_dir2_data_freeremove()
631 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || in xfs_dir2_data_freeremove()
632 hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) || in xfs_dir2_data_freeremove()
633 hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC) || in xfs_dir2_data_freeremove()
634 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)); in xfs_dir2_data_freeremove()
657 bf[2].offset = 0; in xfs_dir2_data_freeremove()
662 * Given a data block, reconstruct its bestfree map.
670 struct xfs_da_geometry *geo = mp->m_dir_geo; in xfs_dir2_data_freescan()
673 unsigned int offset = geo->data_entry_offset; in xfs_dir2_data_freescan() local
676 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || in xfs_dir2_data_freescan()
677 hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC) || in xfs_dir2_data_freescan()
678 hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) || in xfs_dir2_data_freescan()
679 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)); in xfs_dir2_data_freescan()
688 while (offset < end) { in xfs_dir2_data_freescan()
689 struct xfs_dir2_data_unused *dup = addr + offset; in xfs_dir2_data_freescan()
690 struct xfs_dir2_data_entry *dep = addr + offset; in xfs_dir2_data_freescan()
695 if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { in xfs_dir2_data_freescan()
696 ASSERT(offset == in xfs_dir2_data_freescan()
699 offset += be16_to_cpu(dup->length); in xfs_dir2_data_freescan()
706 ASSERT(offset == in xfs_dir2_data_freescan()
708 offset += xfs_dir2_data_entsize(mp, dep->namelen); in xfs_dir2_data_freescan()
713 * Initialize a data block at the given block number in the directory.
714 * Give back the buffer for the created block.
719 xfs_dir2_db_t blkno, /* logical dir block number */ in xfs_dir3_data_init()
720 struct xfs_buf **bpp) /* output block buffer */ in xfs_dir3_data_init()
722 struct xfs_trans *tp = args->trans; in xfs_dir3_data_init()
723 struct xfs_inode *dp = args->dp; in xfs_dir3_data_init()
724 struct xfs_mount *mp = dp->i_mount; in xfs_dir3_data_init()
725 struct xfs_da_geometry *geo = args->geo; in xfs_dir3_data_init()
734 * Get the buffer set up for the block. in xfs_dir3_data_init()
736 error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(args->geo, blkno), in xfs_dir3_data_init()
740 bp->b_ops = &xfs_dir3_data_buf_ops; in xfs_dir3_data_init()
746 hdr = bp->b_addr; in xfs_dir3_data_init()
748 struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr; in xfs_dir3_data_init()
751 hdr3->magic = cpu_to_be32(XFS_DIR3_DATA_MAGIC); in xfs_dir3_data_init()
752 hdr3->blkno = cpu_to_be64(xfs_buf_daddr(bp)); in xfs_dir3_data_init()
753 hdr3->owner = cpu_to_be64(args->owner); in xfs_dir3_data_init()
754 uuid_copy(&hdr3->uuid, &mp->m_sb.sb_meta_uuid); in xfs_dir3_data_init()
757 hdr->magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC); in xfs_dir3_data_init()
760 bf[0].offset = cpu_to_be16(geo->data_entry_offset); in xfs_dir3_data_init()
761 bf[0].length = cpu_to_be16(geo->blksize - geo->data_entry_offset); in xfs_dir3_data_init()
764 bf[i].offset = 0; in xfs_dir3_data_init()
768 * Set up an unused entry for the block's body. in xfs_dir3_data_init()
770 dup = bp->b_addr + geo->data_entry_offset; in xfs_dir3_data_init()
771 dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); in xfs_dir3_data_init()
772 dup->length = bf[0].length; in xfs_dir3_data_init()
773 *xfs_dir2_data_unused_tag_p(dup) = cpu_to_be16((char *)dup - (char *)hdr); in xfs_dir3_data_init()
785 * Log an active data entry from the block.
793 struct xfs_mount *mp = bp->b_mount; in xfs_dir2_data_log_entry()
794 struct xfs_dir2_data_hdr *hdr = bp->b_addr; in xfs_dir2_data_log_entry()
796 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || in xfs_dir2_data_log_entry()
797 hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC) || in xfs_dir2_data_log_entry()
798 hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) || in xfs_dir2_data_log_entry()
799 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)); in xfs_dir2_data_log_entry()
801 xfs_trans_log_buf(args->trans, bp, (uint)((char *)dep - (char *)hdr), in xfs_dir2_data_log_entry()
802 (uint)((char *)(xfs_dir2_data_entry_tag_p(mp, dep) + 1) - in xfs_dir2_data_log_entry()
803 (char *)hdr - 1)); in xfs_dir2_data_log_entry()
807 * Log a data block header.
815 struct xfs_dir2_data_hdr *hdr = bp->b_addr; in xfs_dir2_data_log_header()
817 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || in xfs_dir2_data_log_header()
818 hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC) || in xfs_dir2_data_log_header()
819 hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) || in xfs_dir2_data_log_header()
820 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)); in xfs_dir2_data_log_header()
823 xfs_trans_log_buf(args->trans, bp, 0, args->geo->data_entry_offset - 1); in xfs_dir2_data_log_header()
835 xfs_dir2_data_hdr_t *hdr = bp->b_addr; in xfs_dir2_data_log_unused()
837 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || in xfs_dir2_data_log_unused()
838 hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC) || in xfs_dir2_data_log_unused()
839 hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) || in xfs_dir2_data_log_unused()
840 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)); in xfs_dir2_data_log_unused()
845 xfs_trans_log_buf(args->trans, bp, (uint)((char *)dup - (char *)hdr), in xfs_dir2_data_log_unused()
846 (uint)((char *)&dup->length + sizeof(dup->length) - in xfs_dir2_data_log_unused()
847 1 - (char *)hdr)); in xfs_dir2_data_log_unused()
851 xfs_trans_log_buf(args->trans, bp, in xfs_dir2_data_log_unused()
852 (uint)((char *)xfs_dir2_data_unused_tag_p(dup) - (char *)hdr), in xfs_dir2_data_log_unused()
853 (uint)((char *)xfs_dir2_data_unused_tag_p(dup) - (char *)hdr + in xfs_dir2_data_log_unused()
854 sizeof(xfs_dir2_data_off_t) - 1)); in xfs_dir2_data_log_unused()
858 * Make a byte range in the data block unused.
865 xfs_dir2_data_aoff_t offset, /* starting byte offset */ in xfs_dir2_data_make_free() argument
870 xfs_dir2_data_hdr_t *hdr; /* data block pointer */ in xfs_dir2_data_make_free()
879 hdr = bp->b_addr; in xfs_dir2_data_make_free()
884 end = xfs_dir3_data_end_offset(args->geo, hdr); in xfs_dir2_data_make_free()
888 * If this isn't the start of the block, then back up to in xfs_dir2_data_make_free()
891 if (offset > args->geo->data_entry_offset) { in xfs_dir2_data_make_free()
894 tagp = (__be16 *)((char *)hdr + offset) - 1; in xfs_dir2_data_make_free()
896 if (be16_to_cpu(prevdup->freetag) != XFS_DIR2_DATA_FREE_TAG) in xfs_dir2_data_make_free()
901 * If this isn't the end of the block, see if the entry after in xfs_dir2_data_make_free()
904 if (offset + len < end) { in xfs_dir2_data_make_free()
906 (xfs_dir2_data_unused_t *)((char *)hdr + offset + len); in xfs_dir2_data_make_free()
907 if (be16_to_cpu(postdup->freetag) != XFS_DIR2_DATA_FREE_TAG) in xfs_dir2_data_make_free()
917 bf = xfs_dir2_data_bestfree_p(args->dp->i_mount, hdr); in xfs_dir2_data_make_free()
936 be16_add_cpu(&prevdup->length, len + be16_to_cpu(postdup->length)); in xfs_dir2_data_make_free()
938 cpu_to_be16((char *)prevdup - (char *)hdr); in xfs_dir2_data_make_free()
961 ASSERT(dfp->length == prevdup->length); in xfs_dir2_data_make_free()
971 be16_add_cpu(&prevdup->length, len); in xfs_dir2_data_make_free()
973 cpu_to_be16((char *)prevdup - (char *)hdr); in xfs_dir2_data_make_free()
988 needscan = be16_to_cpu(prevdup->length) > in xfs_dir2_data_make_free()
997 newdup = (xfs_dir2_data_unused_t *)((char *)hdr + offset); in xfs_dir2_data_make_free()
998 newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); in xfs_dir2_data_make_free()
999 newdup->length = cpu_to_be16(len + be16_to_cpu(postdup->length)); in xfs_dir2_data_make_free()
1001 cpu_to_be16((char *)newdup - (char *)hdr); in xfs_dir2_data_make_free()
1016 needscan = be16_to_cpu(newdup->length) > in xfs_dir2_data_make_free()
1024 newdup = (xfs_dir2_data_unused_t *)((char *)hdr + offset); in xfs_dir2_data_make_free()
1025 newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); in xfs_dir2_data_make_free()
1026 newdup->length = cpu_to_be16(len); in xfs_dir2_data_make_free()
1028 cpu_to_be16((char *)newdup - (char *)hdr); in xfs_dir2_data_make_free()
1040 xfs_dir2_data_aoff_t offset, in xfs_dir2_data_check_free() argument
1043 if (hdr->magic != cpu_to_be32(XFS_DIR2_DATA_MAGIC) && in xfs_dir2_data_check_free()
1044 hdr->magic != cpu_to_be32(XFS_DIR3_DATA_MAGIC) && in xfs_dir2_data_check_free()
1045 hdr->magic != cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) && in xfs_dir2_data_check_free()
1046 hdr->magic != cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) in xfs_dir2_data_check_free()
1048 if (be16_to_cpu(dup->freetag) != XFS_DIR2_DATA_FREE_TAG) in xfs_dir2_data_check_free()
1050 if (offset < (char *)dup - (char *)hdr) in xfs_dir2_data_check_free()
1052 if (offset + len > (char *)dup + be16_to_cpu(dup->length) - (char *)hdr) in xfs_dir2_data_check_free()
1054 if ((char *)dup - (char *)hdr != in xfs_dir2_data_check_free()
1060 /* Sanity-check a new bestfree entry. */
1069 if (dfp->length != newdup->length) in xfs_dir2_data_check_new_free()
1071 if (be16_to_cpu(dfp->offset) != (char *)newdup - (char *)hdr) in xfs_dir2_data_check_new_free()
1077 * Take a byte range out of an existing unused space and make it un-free.
1084 xfs_dir2_data_aoff_t offset, /* starting offset to use */ in xfs_dir2_data_use_free() argument
1089 xfs_dir2_data_hdr_t *hdr; /* data block header */ in xfs_dir2_data_use_free()
1100 hdr = bp->b_addr; in xfs_dir2_data_use_free()
1101 fa = xfs_dir2_data_check_free(hdr, dup, offset, len); in xfs_dir2_data_use_free()
1107 oldlen = be16_to_cpu(dup->length); in xfs_dir2_data_use_free()
1108 bf = xfs_dir2_data_bestfree_p(args->dp->i_mount, hdr); in xfs_dir2_data_use_free()
1114 matchfront = (char *)dup - (char *)hdr == offset; in xfs_dir2_data_use_free()
1115 matchback = (char *)dup + oldlen - (char *)hdr == offset + len; in xfs_dir2_data_use_free()
1124 needscan = (bf[2].offset != 0); in xfs_dir2_data_use_free()
1135 newdup = (xfs_dir2_data_unused_t *)((char *)hdr + offset + len); in xfs_dir2_data_use_free()
1136 newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); in xfs_dir2_data_use_free()
1137 newdup->length = cpu_to_be16(oldlen - len); in xfs_dir2_data_use_free()
1139 cpu_to_be16((char *)newdup - (char *)hdr); in xfs_dir2_data_use_free()
1165 newdup->length = cpu_to_be16(((char *)hdr + offset) - (char *)newdup); in xfs_dir2_data_use_free()
1167 cpu_to_be16((char *)newdup - (char *)hdr); in xfs_dir2_data_use_free()
1193 newdup->length = cpu_to_be16(((char *)hdr + offset) - (char *)newdup); in xfs_dir2_data_use_free()
1195 cpu_to_be16((char *)newdup - (char *)hdr); in xfs_dir2_data_use_free()
1197 newdup2 = (xfs_dir2_data_unused_t *)((char *)hdr + offset + len); in xfs_dir2_data_use_free()
1198 newdup2->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); in xfs_dir2_data_use_free()
1199 newdup2->length = cpu_to_be16(oldlen - len - be16_to_cpu(newdup->length)); in xfs_dir2_data_use_free()
1201 cpu_to_be16((char *)newdup2 - (char *)hdr); in xfs_dir2_data_use_free()
1226 xfs_corruption_error(__func__, XFS_ERRLEVEL_LOW, args->dp->i_mount, in xfs_dir2_data_use_free()
1229 return -EFSCORRUPTED; in xfs_dir2_data_use_free()
1232 /* Find the end of the entry data in a data/block format dir block. */
1240 switch (hdr->magic) { in xfs_dir3_data_end_offset()
1244 return p - (void *)hdr; in xfs_dir3_data_end_offset()
1247 return geo->blksize; in xfs_dir3_data_end_offset()