xfs_inode_t *dp; /* directory inode */
xfs_dir2_data_unused_t *dup; /* block unused entry */
int error; /* error return value */
- xfs_dir2_data_unused_t *enddup; /* unused at end of data */
+ xfs_dir2_data_unused_t *enddup=NULL; /* unused at end of data */
xfs_dahash_t hash; /* hash value of found entry */
int high; /* high index for binary srch */
int highstale; /* high stale index */
- int lfloghigh; /* last final leaf to log */
- int lfloglow; /* first final leaf to log */
+ int lfloghigh=0; /* last final leaf to log */
+ int lfloglow=0; /* first final leaf to log */
int len; /* length of the new entry */
int low; /* low index for binary srch */
int lowstale; /* low stale index */
- int mid; /* midpoint for binary srch */
+ int mid=0; /* midpoint for binary srch */
xfs_mount_t *mp; /* filesystem mount point */
int needlog; /* need to log header */
int needscan; /* need to rescan freespace */
/*
* Read the (one and only) directory block into dabuf bp.
*/
- if (error =
- xfs_da_read_buf(tp, dp, mp->m_dirdatablk, -1, &bp, XFS_DATA_FORK)) {
-#pragma mips_frequency_hint NEVER
+ if ((error =
+ xfs_da_read_buf(tp, dp, mp->m_dirdatablk, -1, &bp, XFS_DATA_FORK))) {
return error;
}
ASSERT(bp != NULL);
* Check the magic number, corrupted if wrong.
*/
if (INT_GET(block->hdr.magic, ARCH_CONVERT) != XFS_DIR2_BLOCK_MAGIC) {
-#pragma mips_frequency_hint NEVER
xfs_da_brelse(tp, bp);
return XFS_ERROR(EFSCORRUPTED);
}
/*
* No stale entries? Need space for entry and new leaf.
*/
- if (INT_GET(btp->stale, ARCH_CONVERT) == 0) {
+ if (INT_ISZERO(btp->stale, ARCH_CONVERT)) {
/*
* Tag just before the first leaf entry.
*/
* to hold the new leaf too?
*/
if (INT_GET(dup->length, ARCH_CONVERT) < len + (uint)sizeof(*blp)) {
-#pragma mips_frequency_hint NEVER
/*
* Yes, we use the second-largest
* entry instead if it works.
* just check its length.
*/
if (INT_GET(dup->length, ARCH_CONVERT) < len) {
-#pragma mips_frequency_hint NEVER
dup = NULL;
}
}
* Will need to compact to make this work.
*/
else {
-#pragma mips_frequency_hint NEVER
/*
* Tag just before the first leaf entry.
*/
* If we don't have space for the new entry & leaf ...
*/
if (!dup) {
-#pragma mips_frequency_hint NEVER
/*
* Not trying to actually do anything, or don't have
* a space reservation: return no-space.
* XXX should be the one closest to mid but mid is not yet computed.
*/
if (compact) {
-#pragma mips_frequency_hint NEVER
int fromidx; /* source leaf index */
int toidx; /* target leaf index */
high = mid - 1;
}
while (mid >= 0 && INT_GET(blp[mid].hashval, ARCH_CONVERT) >= args->hashval) {
-#pragma mips_frequency_hint NEVER
mid--;
}
/*
* No stale entries, will use enddup space to hold new leaf.
*/
- if (INT_GET(btp->stale, ARCH_CONVERT) == 0) {
+ if (INT_ISZERO(btp->stale, ARCH_CONVERT)) {
/*
* Mark the space needed for the new leaf entry, now in use.
*/
* Get the buffer, look up the entry.
* If not found (ENOENT) then return, have no buffer.
*/
- if (error = xfs_dir2_block_lookup_int(args, &bp, &ent))
+ if ((error = xfs_dir2_block_lookup_int(args, &bp, &ent)))
return error;
dp = args->dp;
mp = dp->i_mount;
/*
* Read the buffer, return error if we can't get it.
*/
- if (error =
- xfs_da_read_buf(tp, dp, mp->m_dirdatablk, -1, &bp, XFS_DATA_FORK)) {
-#pragma mips_frequency_hint NEVER
+ if ((error =
+ xfs_da_read_buf(tp, dp, mp->m_dirdatablk, -1, &bp, XFS_DATA_FORK))) {
return error;
}
ASSERT(bp != NULL);
* Back up to the first one with the right hash value.
*/
while (mid > 0 && INT_GET(blp[mid - 1].hashval, ARCH_CONVERT) == args->hashval) {
-#pragma mips_frequency_hint NEVER
mid--;
}
/*
* Look up the entry in the block. Gets the buffer and entry index.
* It will always be there, the vnodeops level does a lookup first.
*/
- if (error = xfs_dir2_block_lookup_int(args, &bp, &ent)) {
-#pragma mips_frequency_hint NEVER
+ if ((error = xfs_dir2_block_lookup_int(args, &bp, &ent))) {
return error;
}
dp = args->dp;
* Lookup the entry in the directory. Get buffer and entry index.
* This will always succeed since the caller has already done a lookup.
*/
- if (error = xfs_dir2_block_lookup_int(args, &bp, &ent)) {
-#pragma mips_frequency_hint NEVER
+ if ((error = xfs_dir2_block_lookup_int(args, &bp, &ent))) {
return error;
}
dp = args->dp;
bestsp = XFS_DIR2_LEAF_BESTS_P_ARCH(ltp, ARCH_CONVERT);
if (INT_GET(bestsp[INT_GET(ltp->bestcount, ARCH_CONVERT) - 1], ARCH_CONVERT) ==
mp->m_dirblksize - (uint)sizeof(block->hdr)) {
-#pragma mips_frequency_hint NEVER
- if (error =
+ if ((error =
xfs_dir2_leaf_trim_data(args, lbp,
- (xfs_dir2_db_t)(INT_GET(ltp->bestcount, ARCH_CONVERT) - 1)))
+ (xfs_dir2_db_t)(INT_GET(ltp->bestcount, ARCH_CONVERT) - 1))))
goto out;
} else {
error = 0;
if (dbp == NULL &&
(error = xfs_da_read_buf(tp, dp, mp->m_dirdatablk, -1, &dbp,
XFS_DATA_FORK))) {
-#pragma mips_frequency_hint NEVER
goto out;
}
block = dbp->data;
*/
btp = XFS_DIR2_BLOCK_TAIL_P(mp, block);
INT_SET(btp->count, ARCH_CONVERT, INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT));
- INT_SET(btp->stale, ARCH_CONVERT, 0);
+ INT_ZERO(btp->stale, ARCH_CONVERT);
xfs_dir2_block_log_tail(tp, dbp);
/*
* Initialize the block leaf area. We compact out stale entries.
error = xfs_da_shrink_inode(args, mp->m_dirleafblk, lbp);
lbp = NULL;
if (error) {
-#pragma mips_frequency_hint NEVER
goto out;
}
/*
xfs_dir2_leaf_entry_t *blp; /* block leaf entries */
xfs_dabuf_t *bp; /* block buffer */
xfs_dir2_block_tail_t *btp; /* block tail pointer */
- char buf[XFS_DIR2_SF_MAX_SIZE]; /* sf buffer */
+ char *buf; /* sf buffer */
+ int buf_len;
xfs_dir2_data_entry_t *dep; /* data entry pointer */
xfs_inode_t *dp; /* incore directory inode */
int dummy; /* trash */
* Bomb out if the shortform directory is way too short.
*/
if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) {
-#pragma mips_frequency_hint NEVER
ASSERT(XFS_FORCED_SHUTDOWN(mp));
return XFS_ERROR(EIO);
}
* Copy the directory into the stack buffer.
* Then pitch the incore inode data so we can make extents.
*/
+
+ buf_len = dp->i_df.if_bytes;
+ buf = kmem_alloc(dp->i_df.if_bytes, KM_SLEEP);
+
bcopy(sfp, buf, dp->i_df.if_bytes);
xfs_idata_realloc(dp, -dp->i_df.if_bytes, XFS_DATA_FORK);
dp->i_d.di_size = 0;
*/
error = xfs_dir2_grow_inode(args, XFS_DIR2_DATA_SPACE, &blkno);
if (error) {
-#pragma mips_frequency_hint NEVER
+ kmem_free(buf, buf_len);
return error;
}
/*
*/
error = xfs_dir2_data_init(args, blkno, &bp);
if (error) {
-#pragma mips_frequency_hint NEVER
+ kmem_free(buf, buf_len);
return error;
}
block = bp->data;
else
sfep = XFS_DIR2_SF_NEXTENTRY(sfp, sfep);
}
+ /* Done with the temporary buffer */
+ kmem_free(buf, buf_len);
/*
* Sort the leaf entries by hash value.
*/