提交 62479f57 编写于 作者: C Christoph Hellwig 提交者: Darrick J. Wong

xfs: cleanup xfs_dir2_data_freescan_int

Use an offset as the main means for iteration, and only do pointer
arithmetics to find the data/unused entries.
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
上级 8073af51
...@@ -567,11 +567,10 @@ xfs_dir2_data_freescan_int( ...@@ -567,11 +567,10 @@ xfs_dir2_data_freescan_int(
struct xfs_dir2_data_hdr *hdr, struct xfs_dir2_data_hdr *hdr,
int *loghead) int *loghead)
{ {
xfs_dir2_data_entry_t *dep; /* active data entry */ struct xfs_dir2_data_free *bf = ops->data_bestfree_p(hdr);
xfs_dir2_data_unused_t *dup; /* unused data entry */ void *addr = hdr;
struct xfs_dir2_data_free *bf; unsigned int offset = ops->data_entry_offset;
char *endp; /* end of block's data */ unsigned int end;
char *p; /* current entry pointer */
ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC) || hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC) ||
...@@ -581,37 +580,30 @@ xfs_dir2_data_freescan_int( ...@@ -581,37 +580,30 @@ xfs_dir2_data_freescan_int(
/* /*
* Start by clearing the table. * Start by clearing the table.
*/ */
bf = ops->data_bestfree_p(hdr);
memset(bf, 0, sizeof(*bf) * XFS_DIR2_DATA_FD_COUNT); memset(bf, 0, sizeof(*bf) * XFS_DIR2_DATA_FD_COUNT);
*loghead = 1; *loghead = 1;
/*
* Set up pointers. end = xfs_dir3_data_endp(geo, addr) - addr;
*/ while (offset < end) {
p = (char *)ops->data_entry_p(hdr); struct xfs_dir2_data_unused *dup = addr + offset;
endp = xfs_dir3_data_endp(geo, hdr); struct xfs_dir2_data_entry *dep = addr + offset;
/*
* Loop over the block's entries.
*/
while (p < endp) {
dup = (xfs_dir2_data_unused_t *)p;
/* /*
* If it's a free entry, insert it. * If it's a free entry, insert it.
*/ */
if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) {
ASSERT((char *)dup - (char *)hdr == ASSERT(offset ==
be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup))); be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup)));
xfs_dir2_data_freeinsert(hdr, bf, dup, loghead); xfs_dir2_data_freeinsert(hdr, bf, dup, loghead);
p += be16_to_cpu(dup->length); offset += be16_to_cpu(dup->length);
continue;
} }
/* /*
* For active entries, check their tags and skip them. * For active entries, check their tags and skip them.
*/ */
else { ASSERT(offset == be16_to_cpu(*ops->data_entry_tag_p(dep)));
dep = (xfs_dir2_data_entry_t *)p; offset += ops->data_entsize(dep->namelen);
ASSERT((char *)dep - (char *)hdr ==
be16_to_cpu(*ops->data_entry_tag_p(dep)));
p += ops->data_entsize(dep->namelen);
}
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册